Class GuiSizesHelper


  • public final class GuiSizesHelper
    extends java.lang.Object
    Support class to handle size information of Gui elements This is needed, because display resolution may vary a lot and a common set of sizes won't work for all users alike.
    Since:
    12682 (moved from gui.util package), 10358
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static float screenDPI
      cache value for screen resolution
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GuiSizesHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Dimension getDimensionDpiAdjusted​(java.awt.Dimension dim)
      Returns a resolution adapted Dimension
      static float getPixelDensity()
      Returns coefficient of monitor pixel density.
      private static float getScreenDPI()
      Request the screen resolution (cached)
      static double getSizeDpiAdjusted​(double size)
      Returns a resolution adapted size
      static float getSizeDpiAdjusted​(float size)
      Returns a resolution adapted size
      static int getSizeDpiAdjusted​(int size)
      Returns a resolution adapted size
      static boolean isHiDPI()
      Check if a high DPI resolution is used
      static void setPixelDensity​(float pixelDensity)
      Sets coefficient of monitor pixel density.
      • Methods inherited from class java.lang.Object

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

      • screenDPI

        private static volatile float screenDPI
        cache value for screen resolution
    • Method Detail

      • getScreenDPI

        private static float getScreenDPI()
        Request the screen resolution (cached)
        Returns:
        screen resolution in DPI
      • getPixelDensity

        public static float getPixelDensity()
        Returns coefficient of monitor pixel density. All hardcoded sizes must be multiplied by this value.
        Returns:
        float value. 1 - means standard monitor, 2 and high - "retina" display.
      • setPixelDensity

        public static void setPixelDensity​(float pixelDensity)
        Sets coefficient of monitor pixel density.
        Parameters:
        pixelDensity - coefficient of monitor pixel density to be set.
      • isHiDPI

        public static boolean isHiDPI()
        Check if a high DPI resolution is used
        Returns:
        true for HIDPI screens
      • getSizeDpiAdjusted

        public static int getSizeDpiAdjusted​(int size)
        Returns a resolution adapted size
        Parameters:
        size - Size value to adapt (base size is a low DPI screen)
        Returns:
        adapted size (may be unmodified)
      • getSizeDpiAdjusted

        public static float getSizeDpiAdjusted​(float size)
        Returns a resolution adapted size
        Parameters:
        size - Size value to adapt (base size is a low DPI screen)
        Returns:
        adapted size (may be unmodified)
      • getSizeDpiAdjusted

        public static double getSizeDpiAdjusted​(double size)
        Returns a resolution adapted size
        Parameters:
        size - Size value to adapt (base size is a low DPI screen)
        Returns:
        adapted size (may be unmodified)
      • getDimensionDpiAdjusted

        public static java.awt.Dimension getDimensionDpiAdjusted​(java.awt.Dimension dim)
        Returns a resolution adapted Dimension
        Parameters:
        dim - Dimension value to adapt (base size is a low DPI screen)
        Returns:
        adapted dimension (may be unmodified)