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 either
Swing
for a Swing-specific constant or Standard
for a
constant defined by JGUIraffe. The return value is a constant of the
opposite type. For instance, the method convertSwingModifiers()
expects Swing-specific keyboard modifiers and converts them into constants
used by JGUIraffe. The counterpart of this method is named convertStandardModifiers()
.
Modifier and Type | Method and Description |
---|---|
static int |
convertStandardButtons(int button)
Converts standard mouse button indices to Swing-specific button
constants.
|
static int |
convertStandardKey(Keys key)
Converts a standard key code to the Swing-specific equivalent.
|
static int |
convertStandardModifiers(Set<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 Keys |
convertSwingKey(int key)
Converts a Swing-specific key code to a standard
Keys enumeration
constant. |
static Set<Modifiers> |
convertSwingModifiers(int modifiers)
Converts Swing-specific keyboard modifiers into standard modifiers.
|
public static Set<Modifiers> convertSwingModifiers(int modifiers)
modifiers
- the Swing-specific bit mask with modifierspublic static int convertStandardModifiers(Set<Modifiers> modifiers)
modifiers
- the set with standard modifierspublic static int convertSwingButtons(int button)
button
- the button indexpublic static int convertStandardButtons(int button)
button
- the button indexpublic static Keys convertSwingKey(int key)
Keys
enumeration
constant. Result can be null if the code cannot be converted.key
- the Swing-specific key codeKeys
constant or nullpublic static int convertStandardKey(Keys key)
key
- the standard keyCopyright © 2016 The JGUIraffe Team. All rights reserved.