com.tensegrity.gui.swing
Class SwingKeyStrokeBuilder

java.lang.Object
  extended bycom.tensegrity.gui.swing.SwingKeyStrokeBuilder
All Implemented Interfaces:
KeyStrokeBuilder

public class SwingKeyStrokeBuilder
extends java.lang.Object
implements KeyStrokeBuilder

An instance of this class which allows building a KeyStroke instance from the string representations of a key code and modifiers. Please refer to the documentation of the buildKeyStroke(String, String) method for more information regarding these string representations formats. The aim of this class is to provide a mean for developers to define commands short cut keys through property files.

Version:
$Id: SwingKeyStrokeBuilder.java,v 1.2 2004/02/12 09:58:10 SebastienGuyon Exp $
Author:
S�bastien Guyon

Nested Class Summary
 
Nested classes inherited from class com.tensegrity.gui.KeyStrokeBuilder
KeyStrokeBuilder.keyStrokeBuilderException
 
Field Summary
static java.lang.String KEYEVENT_CLASS
          Constant representing the KeyEvent class' full name
 
Fields inherited from interface com.tensegrity.gui.KeyStrokeBuilder
KEYCODE_PREFIX, KEYSTROKE_CLASS, MODIFIER_SUFFIX, MODIFIERS_SEPARATOR, VALID_MODIFIERS
 
Method Summary
 boolean assertModifier(java.lang.String modifier)
           Simple utility method returning true if the parameter is a valid modifier, false otherwise.
 KeyStroke buildKeyStroke(java.lang.String keyCode, java.lang.String modifiers)
           This method builds and returns a KeyStroke instance using the passed string representation of keycode and modifiers.
protected static SwingKeyStrokeBuilder getInstance()
           Returns the singleton instance
 int retrieveKeycodeIntValue(java.lang.String keycode)
           This method accepts the string representation of a key code as parameter and returns the corresponding integer representation.
 int retrieveModifiersIntValue(java.lang.String modifiers)
           This method accepts the string representation of modifiers as parameter and returns the corresponding integer representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEYEVENT_CLASS

public static final java.lang.String KEYEVENT_CLASS
Constant representing the KeyEvent class' full name

See Also:
Constant Field Values
Method Detail

getInstance

protected static SwingKeyStrokeBuilder getInstance()

Returns the singleton instance

Returns:
the singleton instance

retrieveKeycodeIntValue

public int retrieveKeycodeIntValue(java.lang.String keycode)
                            throws KeyStrokeBuilder.keyStrokeBuilderException

This method accepts the string representation of a key code as parameter and returns the corresponding integer representation. The integer representation is in fact the corresponding constant value of the KeyEvent class. Note that there is a tight coupling between the valid 'keycode' parameters accepted by this method and the constants starting with the prefix KeyStrokeBuilder.KEYCODE_PREFIX in the KeyEvent class. Valid parameters should have a corresponding value in KeyEvent, when the prefix KeyStrokeBuilder.KEYCODE_PREFIX is added at their beginning.

Specified by:
retrieveKeycodeIntValue in interface KeyStrokeBuilder
Parameters:
keycode - this is the String representation of a key code.
Returns:
the corresponding integer representation of the passed parameter. The integer representation is in fact the corresponding constant value of the KeyEvent class.
Throws:
keyStrokeBuilderException
KeyStrokeBuilder.keyStrokeBuilderException

assertModifier

public boolean assertModifier(java.lang.String modifier)

Simple utility method returning true if the parameter is a valid modifier, false otherwise.

Specified by:
assertModifier in interface KeyStrokeBuilder
Parameters:
modifier - this is the String representation for a modifier.
Returns:
true if the parameter is a valid modifier, false otherwise.
See Also:
{@link #VALID_MODIFIERS}

retrieveModifiersIntValue

public int retrieveModifiersIntValue(java.lang.String modifiers)
                              throws KeyStrokeBuilder.keyStrokeBuilderException

This method accepts the string representation of modifiers as parameter and returns the corresponding integer representation. The integer representation is in fact the corresponding constant value of the KeyStroke class. Note that there is a tight coupling between the valid 'modifiers' parameters accepted by this method and constants defined in the KeyStroke class.

Valid parameters are therefore one of KeyStrokeBuilder.VALID_MODIFIERS. Modifiers must be separated with the KeyStrokeBuilder.MODIFIERS_SEPARATOR separator.

Specified by:
retrieveModifiersIntValue in interface KeyStrokeBuilder
Parameters:
modifiers - a String representation of modifiers.
Returns:
the corresponding integer representation of the passed parameter.
Throws:
keyStrokeBuilderException
KeyStrokeBuilder.keyStrokeBuilderException

buildKeyStroke

public KeyStroke buildKeyStroke(java.lang.String keyCode,
                                java.lang.String modifiers)
                         throws KeyStrokeBuilder.keyStrokeBuilderException

This method builds and returns a KeyStroke instance using the passed string representation of keycode and modifiers. See retrieveKeycodeIntValue(String) and retrieveModifiersIntValue(String) for more information regarding the parameters valid formats.

Specified by:
buildKeyStroke in interface KeyStrokeBuilder
Parameters:
keyCode - a string representation of a key code
modifiers - a string representation of modifiers
Returns:
a KeyStroke instance
Throws:
keyStrokeBuilderException - this exception is thrown is the KeyStroke is not succesfully created.
KeyStrokeBuilder.keyStrokeBuilderException


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.