Class SwingUtils

java.lang.Object
VASSAL.tools.swing.SwingUtils

public class SwingUtils
extends Object
  • Field Details

    • FONT_HINTS

      public static final Map<?,​?> 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

      public static AffineTransform descaleTransform​(AffineTransform t)
    • isLeftMouseButton

      @Deprecated public static boolean isLeftMouseButton​(MouseEvent e)
      Deprecated.
      Returns:
      whether the event is effectively for the left button.
    • isRightMouseButton

      @Deprecated public static boolean isRightMouseButton​(MouseEvent e)
      Deprecated.
      Returns:
      whether the event is effectively for the right button.
    • isControlDown

      @Deprecated public static boolean isControlDown​(MouseEvent e)
      Deprecated.
      The situation where this was needed with mouse events is now handled by isSelectionToggle(MouseEvent).
      Returns:
      whether the event effectively has Control down.
    • isContextMouseButtonDown

      public static boolean isContextMouseButtonDown​(MouseEvent e)
      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

      public static boolean isMainMouseButtonDown​(MouseEvent e)
      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

      public static boolean isSelectionToggle​(MouseEvent e)
      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

      public static boolean isModifierKeyDown​(KeyEvent e)
      Parameters:
      e - Key event
      Returns:
      true if CTRL+keystroke on non-Mac or Command+keystroke on Mac
    • systemToGeneric

      public static KeyStroke systemToGeneric​(KeyStroke k)
      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

      public static KeyStroke genericToSystem​(KeyStroke k)
      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

      public static KeyStroke getKeyStrokeForEvent​(KeyEvent e)
      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

      public static boolean isDragTrigger​(DragGestureEvent e)
      Returns:
      whether the drag is non-mouse or effectively from the left button
    • getScreenBounds

      public static Rectangle getScreenBounds​(Component c)
      Returns:
      size of screen accounting for the screen insets (e.g., Windows taskbar)