Skip to content

Commit 6e452e7

Browse files
Tweak scale factor for drawing the crayons image in color choosers
For #457
1 parent 367f2d9 commit 6e452e7

File tree

1 file changed

+7
-2
lines changed
  • theming/src/main/java/org/pushingpixels/radiance/theming/internal/contrib/randelshofer/quaqua/colorchooser

1 file changed

+7
-2
lines changed

theming/src/main/java/org/pushingpixels/radiance/theming/internal/contrib/randelshofer/quaqua/colorchooser/Crayons.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,20 @@ public Color getColor() {
167167
public void paintComponent(Graphics gr) {
168168
Graphics2D g2d = (Graphics2D) gr.create();
169169
RadianceCommonCortex.installDesktopHints(g2d, getFont());
170-
double scaleFactor = RadianceCommonCortex.getScaleFactor(this);
171-
RadianceCommonCortex.drawImageWithScale(g2d, scaleFactor, crayonsImage, 0, 0);
170+
171+
// The crayons image is created once at Radiance initialization based on the scale
172+
// max scale factor of all connected screens. Use that same scale factor to draw
173+
// that image, no matter what the scale factor of the current monitor is.
174+
double imageScaleFactor = RadianceCommonCortex.getScaleFactor(null);
175+
RadianceCommonCortex.drawImageWithScale(g2d, imageScaleFactor, crayonsImage, 0, 0);
172176

173177
if (selectedCrayon != null) {
174178
Color selectedTextColor = RadianceColorSchemeUtilities.getColorScheme(
175179
this, ComponentState.ENABLED).getForegroundColor();
176180
g2d.setColor(selectedTextColor);
177181
FontMetrics fm = g2d.getFontMetrics();
178182
int nameWidth = fm.stringWidth(selectedCrayon.name);
183+
double scaleFactor = RadianceCommonCortex.getScaleFactor(this);
179184
g2d.drawString(selectedCrayon.name,
180185
((int) (crayonsImage.getWidth() / scaleFactor) - nameWidth) / 2,
181186
fm.getAscent() + 1);

0 commit comments

Comments
 (0)