Class GuiSizesHelper


  • public final class GuiSizesHelper
    extends 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 wont work for all users alike.
    Since:
    12682 (moved from gui.util package), 10358
    • Field Detail

      • screenDPI

        private static 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 Dimension getDimensionDpiAdjusted​(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)