Package VASSAL.tools.swing
Class SwingUtils
java.lang.Object
VASSAL.tools.swing.SwingUtils
public class SwingUtils extends Object
-
Field Summary
Fields Modifier and Type Field Description static Map<?,?>
FONT_HINTS
-
Constructor Summary
Constructors Constructor Description SwingUtils()
-
Method Summary
Modifier and Type Method Description static AffineTransform
descaleTransform(AffineTransform t)
static KeyStroke
genericToSystem(KeyStroke k)
static KeyStroke
getKeyStrokeForEvent(KeyEvent e)
static Rectangle
getScreenBounds(Component c)
static boolean
isContextMouseButtonDown(MouseEvent e)
static boolean
isControlDown(MouseEvent e)
Deprecated.static boolean
isDragTrigger(DragGestureEvent e)
static boolean
isLeftMouseButton(MouseEvent e)
Deprecated.in favor ofisMainMouseButtonDown(MouseEvent)
static boolean
isMacLegacy()
Supports swapping most Control and Command button functions on Mac so as not to punish long-time users for our "old non-standard implementations"static boolean
isMainMouseButtonDown(MouseEvent e)
static boolean
isModifierKeyDown(KeyEvent e)
static boolean
isRightMouseButton(MouseEvent e)
Deprecated.in favor ofisContextMouseButtonDown(MouseEvent)
static boolean
isSelectionToggle(MouseEvent e)
static void
setMacLegacy(boolean b)
Supports swapping most Control and Command button functions on Mac so as not to punish long-time users for our "old non-standard implementations"static KeyStroke
systemToGeneric(KeyStroke k)
-
Field Details
-
FONT_HINTS
-
-
Constructor Details
-
SwingUtils
public SwingUtils()
-
-
Method Details
-
isMacLegacy
public static boolean isMacLegacy()Supports swapping most Control and Command button functions on Mac so as not to punish long-time users for our "old non-standard implementations" -
setMacLegacy
public static void setMacLegacy(boolean b)Supports swapping most Control and Command button functions on Mac so as not to punish long-time users for our "old non-standard implementations" -
descaleTransform
-
isLeftMouseButton
Deprecated.in favor ofisMainMouseButtonDown(MouseEvent)
- Returns:
- whether the event is effectively for the left button.
-
isRightMouseButton
Deprecated.in favor ofisContextMouseButtonDown(MouseEvent)
- Returns:
- whether the event is effectively for the right button.
-
isControlDown
Deprecated.The situation where this was needed with mouse events is now handled byisSelectionToggle(MouseEvent)
.- Returns:
- whether the event effectively has Control down.
-
isContextMouseButtonDown
- Returns:
- whether the event has the key/mouse combo for Context Menu active, whether it would raise one "right now" or not. (normally plain right mouse button, but some funky mac bonuses)
-
isMainMouseButtonDown
- Returns:
- whether the event has the key/mouse combo for selecting things down (normally just plain left mouse button, but on Mac only if not pretending to be right button)
-
isSelectionToggle
- Returns:
- whether the event has the key/mouse combo toggling targets in and out of selection (normally Ctrl+Click on most platforms, normally Command+Click on Mac)
-
isModifierKeyDown
- Parameters:
e
- Key event- Returns:
- true if CTRL+keystroke on non-Mac or Command+keystroke on Mac
-
systemToGeneric
- Returns:
- translation of keystroke from local system to platform-independent Vassal keystroke (to handle Mac platform support) The main idea here is that on Macs we want the common shortcut keys represented by e.g. Ctrl+C on Windows and Linux platforms to be represented by Command+C on the Mac, and likewise when module designers on Mac implement a Command+C shortcut we want that to appear as Ctrl+C for the same module running on other platforms. But we also support a "legacy" preference to allow Mac users used to Vassal 3.2.17 and prior mappings to continue with them.
-
genericToSystem
- Returns:
- translation of keystroke from platform-independent Vassal to local system (to handle Mac platform support) The main idea here is that on Macs we want the common shortcut keys represented by e.g. Ctrl+C on Windows and Linux platforms to be represented by Command+C on the Mac, and likewise when module designers on Mac implement a Command+C shortcut we want that to appear as Ctrl+C for the same module running on other platforms. But we also support a "legacy" preference to allow Mac users used to Vassal 3.2.17 and prior mappings to continue with them.
-
getKeyStrokeForEvent
- Returns:
- translation of KeyEvent (local system) to Vassal (to handle Mac platform support) The main idea here is that on Macs we want the common shortcut keys represented by e.g. Ctrl+C on Windows and Linux platforms to be represented by Command+C on the Mac, and likewise when module designers on Mac implement a Command+C shortcut we want that to appear as Ctrl+C for the same module running on other platforms. But we also support a "legacy" preference to allow Mac users used to Vassal 3.2.17 and prior mappings to continue with them.
-
isDragTrigger
- Returns:
- whether the drag is non-mouse or effectively from the left button
-
getScreenBounds
- Returns:
- size of screen accounting for the screen insets (e.g., Windows taskbar)
-
isSelectionToggle(MouseEvent)
.