Class SwingEventConstantMapper
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.builder.event.SwingEventConstantMapper
-
public final class SwingEventConstantMapper extends Object
An utility class for converting Swing-specific constants related to events to the toolkit-independent constants used by the JGUIraffe library.
When dealing with events there are frequently constants involved, for instance bit masks for modifier keys, mouse buttons, etc. The JGUIraffe library provides corresponding constants for its own event model. The Swing-specific adapter implementations have to translate these constants to the values and data structures used by Swing. This is the main purpose of this class.
This is a static utility class, no instance can be created. It provides methods for constant conversions for several types of constants. The methods follow a typical naming pattern: They start with
convert
and end with the type of constants that are converted. The middle part of the name determines the parameter that is passed to the method. This can be eitherSwing
for a Swing-specific constant orStandard
for a constant defined by JGUIraffe. The return value is a constant of the opposite type. For instance, the methodconvertSwingModifiers()
expects Swing-specific keyboard modifiers and converts them into constants used by JGUIraffe. The counterpart of this method is namedconvertStandardModifiers()
.- Version:
- $Id: SwingEventConstantMapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
convertStandardButtons(int button)
Converts standard mouse button indices to Swing-specific button constants.static int
convertStandardKey(net.sf.jguiraffe.gui.builder.event.Keys key)
Converts a standard key code to the Swing-specific equivalent.static int
convertStandardModifiers(Set<net.sf.jguiraffe.gui.builder.event.Modifiers> modifiers)
Converts standard keyboard modifiers into Swing-specific modifiers.static int
convertSwingButtons(int button)
Converts Swing-specific mouse button indices to standard button constants.static net.sf.jguiraffe.gui.builder.event.Keys
convertSwingKey(int key)
Converts a Swing-specific key code to a standardKeys
enumeration constant.static Set<net.sf.jguiraffe.gui.builder.event.Modifiers>
convertSwingModifiers(int modifiers)
Converts Swing-specific keyboard modifiers into standard modifiers.
-
-
-
Method Detail
-
convertSwingModifiers
public static Set<net.sf.jguiraffe.gui.builder.event.Modifiers> convertSwingModifiers(int modifiers)
Converts Swing-specific keyboard modifiers into standard modifiers.- Parameters:
modifiers
- the Swing-specific bit mask with modifiers- Returns:
- the corresponding set with standard modifiers
-
convertStandardModifiers
public static int convertStandardModifiers(Set<net.sf.jguiraffe.gui.builder.event.Modifiers> modifiers)
Converts standard keyboard modifiers into Swing-specific modifiers.- Parameters:
modifiers
- the set with standard modifiers- Returns:
- the Swing-specific bit mask with modifiers
-
convertSwingButtons
public static int convertSwingButtons(int button)
Converts Swing-specific mouse button indices to standard button constants. If the index is invalid, the constant for no button is returned.- Parameters:
button
- the button index- Returns:
- the corresponding standard button constant
-
convertStandardButtons
public static int convertStandardButtons(int button)
Converts standard mouse button indices to Swing-specific button constants. If the index is invalid, the constant for no button is returned.- Parameters:
button
- the button index- Returns:
- the corresponding Swing button constant
-
convertSwingKey
public static net.sf.jguiraffe.gui.builder.event.Keys convertSwingKey(int key)
Converts a Swing-specific key code to a standardKeys
enumeration constant. Result can be null if the code cannot be converted.- Parameters:
key
- the Swing-specific key code- Returns:
- the corresponding
Keys
constant or null
-
convertStandardKey
public static int convertStandardKey(net.sf.jguiraffe.gui.builder.event.Keys key)
Converts a standard key code to the Swing-specific equivalent. If null is passed in, an exception is thrown.- Parameters:
key
- the standard key- Returns:
- the corresponding Swing-specific key code
-
-