Class GUIUtils

java.lang.Object
org.pepsoft.util.GUIUtils

public class GUIUtils extends Object
System properties you can set before this class is initialised:

org.pepsoft.util.GUIUtils.disableScaling - set to true to force the scale to 100%
org.pepsoft.snapshotVersion - set to true to cause the UI scale preference to be loaded from a separate, snapshot setting

Created by pepijn on 13-Jan-17.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 92-96 dpi screens.
    static final float
    The detected system default UI scale.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 96 dpi screens.
    static int
    How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 92-96 dpi screens.
    static void
    scaleLookAndFeel(float scale)
    Adjusts the UIManager defaults to show the Java 2D UI at the specified scale.
    static void
    scaleToUI(Container container)
     
    Scale an image according to UI_SCALE.
    scaleToUI(Image image, boolean smooth)
    Scale an image according to UI_SCALE_FLOAT or UI_SCALE.
    static void
     
    static void
    setUIScale(float uiScale)
    Override the detected system default UI scale.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SYSTEM_UI_SCALE_FLOAT

      public static final float SYSTEM_UI_SCALE_FLOAT
      The detected system default UI scale.

      Note: for now UI scaling is only activated on Windows, until the current support on Mac and Linux can be investigated.

    • SYSTEM_UI_SCALE

      public static final int SYSTEM_UI_SCALE
      How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 92-96 dpi screens.

      This is UI_SCALE_FLOAT rounded to the nearest integer and is intended for small images that don't scale well to non integer factors such as icons.

      Note: for now UI scaling is only activated on Windows, until the current support on Mac and Linux can be investigated.

  • Constructor Details

    • GUIUtils

      public GUIUtils()
  • Method Details

    • scaleToUI

      public static BufferedImage scaleToUI(Image image)
      Scale an image according to UI_SCALE. Nearest neighbour scaling is used, in other words no smoothing or interpolation is applied.
      Parameters:
      image - The image to scale.
      Returns:
      The original image if UI_SCALE is 1, or an appropriately scaled copy otherwise.
    • scaleToUI

      public static BufferedImage scaleToUI(Image image, boolean smooth)
      Scale an image according to UI_SCALE_FLOAT or UI_SCALE.
      Parameters:
      image - The image to scale.
      smooth - Whether to do smooth scaling. When this is true, the image is scaled to the floating point UI scale using bicubic scaling. When it is false, it is scaled to the UI scale rounded to the nearest integer, using nearest neighbour scaling.
      Returns:
      The original image if UI_SCALE is 1, or an appropriately scaled copy otherwise.
    • scaleToUI

      public static void scaleToUI(Container container)
    • scaleWindow

      public static void scaleWindow(Window window)
    • scaleLookAndFeel

      public static void scaleLookAndFeel(float scale)
      Adjusts the UIManager defaults to show the Java 2D UI at the specified scale.
    • setUIScale

      public static void setUIScale(float uiScale)
      Override the detected system default UI scale.
      Parameters:
      uiScale - The UI scale to use instead of the detected system default.
    • getUIScale

      public static float getUIScale()
      How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 96 dpi screens.

      Note: for now UI scaling is only activated on Windows, until the current support on Mac and Linux can be investigated.

    • getUIScaleInt

      public static int getUIScaleInt()
      How many times to scale pixel sizes to display at approximately the originally intended size for assets which were designed for 92-96 dpi screens.

      This is getUIScale() rounded to the nearest integer and is intended for small images that don't scale well to non integer factors such as icons.

      Note: for now UI scaling is only activated on Windows, until the current support on Mac and Linux can be investigated.