Class ChartScale
- Since:
- 2026-01-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAuto-detects the scale factor from the givenGraphicsConfiguration.static floatfont(float size) Scales font sizes.static floatReturns the currently active global scale factor.static doublescale(double value) static floatscale(float value) static voidsetScaleFactor(float factor) Sets the global scale factor used by the chart framework.static floatuiFontSize(Font baseFont, float sizeInDp) Scales a target font size in a UI-toolkit-aware way.
-
Method Details
-
setScaleFactor
public static void setScaleFactor(float factor) Sets the global scale factor used by the chart framework.Framework note: This is a process-wide setting. Prefer setting it once during application startup (or call
autoDetect(GraphicsConfiguration)once from the primary window). This method always overrides any previously auto-detected value. -
autoDetect
Auto-detects the scale factor from the givenGraphicsConfiguration.Framework policy: This method initializes the scale factor only once. The first call with a non-null
GraphicsConfigurationwins. Subsequent calls are ignored to avoid global scale thrash when windows move across monitors. -
getScaleFactor
public static float getScaleFactor()Returns the currently active global scale factor. -
scale
public static float scale(float value) -
scale
public static double scale(double value) -
font
public static float font(float size) Scales font sizes. Fonts often require slightly different scaling than geometric shapes. -
uiFontSize
Scales a target font size in a UI-toolkit-aware way.Why: In modern Swing applications (e.g. FlatLaf),
UIManagerfonts are already HiDPI-aware and may already include the platform scale factor. If we then applyfont(float)again, text becomes double-scaled.Policy: If the provided
baseFontlooks like a UI-managed font (i.e. its size already tracks the UI scale), we treatsizeInDpas the final point size. Otherwise we apply the framework scale factor.- Parameters:
baseFont- the font used as baseline; may benullsizeInDp- desired size in design units (dp)- Returns:
- a size value suitable for
Font.deriveFont(float)
-