com.tensegrity.gui
Interface KeyStrokeBuilder

All Known Implementing Classes:
SwingKeyStrokeBuilder, SwtKeyStrokeBuilder

public interface 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: KeyStrokeBuilder.java,v 1.2 2004/08/27 14:30:50 SebastienGuyon Exp $
Author:
S�bastien Guyon

Nested Class Summary
static class KeyStrokeBuilder.keyStrokeBuilderException
           Exception indicating that an error occured when trying to build a KeyStroke with an instance of KeyStrokeBuilder
 
Field Summary
static java.lang.String KEYCODE_PREFIX
          Constant representing the keycodes' prefix
static java.lang.String KEYSTROKE_CLASS
          Constant representing the KeyStroke class' full name
static java.lang.String MODIFIER_SUFFIX
          Constant representing the modifiers' suffix
static java.lang.String MODIFIERS_SEPARATOR
          Constant representing the separator used for modifiers in the property files
static java.lang.String[] VALID_MODIFIERS
          Constant defining the possible KeyStroke 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.
 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.
 

Field Detail

KEYSTROKE_CLASS

public static final java.lang.String KEYSTROKE_CLASS
Constant representing the KeyStroke class' full name

See Also:
Constant Field Values

KEYCODE_PREFIX

public static final java.lang.String KEYCODE_PREFIX
Constant representing the keycodes' prefix

See Also:
Constant Field Values

MODIFIER_SUFFIX

public static final java.lang.String MODIFIER_SUFFIX
Constant representing the modifiers' suffix

See Also:
Constant Field Values

MODIFIERS_SEPARATOR

public static final java.lang.String MODIFIERS_SEPARATOR
Constant representing the separator used for modifiers in the property files

See Also:
Constant Field Values

VALID_MODIFIERS

public static final java.lang.String[] VALID_MODIFIERS
Constant defining the possible KeyStroke modifiers

Method Detail

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 KEYCODE_PREFIX in the KeyEvent class. Valid parameters should have a corresponding value in KeyEvent, when the prefix KEYCODE_PREFIX is added at their beginning.

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:
KeyStrokeBuilder.keyStrokeBuilderException - this exception is thrown if the routine fails. It should however not happen.

assertModifier

public boolean assertModifier(java.lang.String modifier)

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

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 VALID_MODIFIERS. Modifiers must be separated with the MODIFIERS_SEPARATOR separator.

Parameters:
modifiers - a String representation of modifiers.
Returns:
the corresponding integer representation of the passed parameter.
Throws:
KeyStrokeBuilder.keyStrokeBuilderException - this exception is thrown if the routine fails. It should however not happen.

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.

Parameters:
keyCode - a string representation of a key code
modifiers - a string representation of modifiers
Returns:
a KeyStroke instance
Throws:
KeyStrokeBuilder.keyStrokeBuilderException - this exception is thrown if the KeyStroke is not successfully created.


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