Package com.actelion.research.gui.hidpi
Class HiDPIHelper
- java.lang.Object
-
- com.actelion.research.gui.hidpi.HiDPIHelper
-
public class HiDPIHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description HiDPIHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.swing.Icon
createDisabledIcon(java.lang.String fileName, int rotation)
static javax.swing.Icon
createIcon(java.lang.String fileName, int rotation)
static java.awt.image.BufferedImage
createImage(java.lang.String fileName)
Creates an image from the fileName.static java.awt.image.BufferedImage
createLaFCompatibleImage(java.lang.String fileName)
Creates an image from the fileName.static float
getIconScaleFactor()
static float
getRetinaScaleFactor()
Macintosh retina display support for Java 7 and newer.static java.awt.Color
getThemeColor(int no)
static float
getUIScaleFactor()
For Windows and Linux this method returns the user defined UI scaling factor.static int
scale(float value)
This is a convenience method that scales the passed int value with getUIScaleFactor() and returns the rounded result.static java.awt.Image
scale(java.awt.image.BufferedImage image)
static int
scaleRetinaAndUI(float value)
This is a convenience method that scales the passed int value with getUIScaleFactor() and with getRetinaScaleFactor() and returns the rounded result.
-
-
-
Method Detail
-
getRetinaScaleFactor
public static float getRetinaScaleFactor()
Macintosh retina display support for Java 7 and newer.- Returns:
- 1.0 on standard resolution devices and 2.0 for retina screens
-
getUIScaleFactor
public static float getUIScaleFactor()
For Windows and Linux this method returns the user defined UI scaling factor. This is done by judging from the size of the UIManager's Label.font and comparing it to the unscaled default (13). Typically this factor is larger than 1.0 on HiDPI devices. For this method to work the Look&Feel must consider the OS provided setting and scale its fonts accordingly (Substance LaF does).
On the Macintosh this factor is usually 1.0, because HiDPI device support uses a different mechanism (see getRetinaScaleFactor()).- Returns:
- typically 1.0 or 1.25, 1.5, ...
-
scale
public static int scale(float value)
This is a convenience method that scales the passed int value with getUIScaleFactor() and returns the rounded result.- Parameters:
value
-- Returns:
-
scaleRetinaAndUI
public static int scaleRetinaAndUI(float value)
This is a convenience method that scales the passed int value with getUIScaleFactor() and with getRetinaScaleFactor() and returns the rounded result.- Parameters:
value
-- Returns:
-
getThemeColor
public static java.awt.Color getThemeColor(int no)
-
createIcon
public static javax.swing.Icon createIcon(java.lang.String fileName, int rotation)
-
createDisabledIcon
public static javax.swing.Icon createDisabledIcon(java.lang.String fileName, int rotation)
-
createImage
public static java.awt.image.BufferedImage createImage(java.lang.String fileName)
Creates an image from the fileName. On HiDPI devices this is a high resolution image. If the current look&feel is dark, then colors are adapted for optimal contrast.- Parameters:
fileName
-- Returns:
-
createLaFCompatibleImage
public static java.awt.image.BufferedImage createLaFCompatibleImage(java.lang.String fileName)
Creates an image from the fileName. On HiDPI devices this is a high resolution image. If the current look&feel is dark, then colors are adapted for optimal contrast.- Parameters:
fileName
-- Returns:
-
getIconScaleFactor
public static float getIconScaleFactor()
-
scale
public static java.awt.Image scale(java.awt.image.BufferedImage image)
-
-