Skip to content

Commit 1f8af17

Browse files
ptzieglerazoitl
authored andcommitted
Remove explicit reference to ScaledGraphics in Zest label
The method `getAbsoluteScaled()` is defined in the `Graphics` class and returns `1.0` by default. A type-check for `ScaledGraphics` is therefore not needed. Contributes to #901
1 parent ded6745 commit 1f8af17

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/internal/CachedLabel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.eclipse.draw2d.Graphics;
2626
import org.eclipse.draw2d.Label;
2727
import org.eclipse.draw2d.SWTGraphics;
28-
import org.eclipse.draw2d.ScaledGraphics;
2928
import org.eclipse.draw2d.geometry.Point;
3029
import org.eclipse.draw2d.geometry.Rectangle;
3130

@@ -164,7 +163,7 @@ public void setBounds(Rectangle rect) {
164163

165164
@Override
166165
protected void paintFigure(Graphics graphics) {
167-
if (graphics instanceof ScaledGraphics sg && sg.getAbsoluteScale() < 0.30) {
166+
if (graphics.getAbsoluteScale() < 0.30) {
168167
return;
169168
}
170169
if (!cacheLabel) {

org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/internal/GraphLabel.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2005-2010, 2024 CHISEL Group, University of Victoria, Victoria,
2+
* Copyright 2005-2010, 2025 CHISEL Group, University of Victoria, Victoria,
33
* BC, Canada.
44
*
55
* This program and the accompanying materials are made available under the
@@ -24,7 +24,6 @@
2424
import org.eclipse.draw2d.FigureUtilities;
2525
import org.eclipse.draw2d.Graphics;
2626
import org.eclipse.draw2d.MarginBorder;
27-
import org.eclipse.draw2d.ScaledGraphics;
2827
import org.eclipse.draw2d.StackLayout;
2928
import org.eclipse.draw2d.geometry.Dimension;
3029
import org.eclipse.draw2d.geometry.Rectangle;
@@ -161,11 +160,7 @@ public void paint(Graphics graphics) {
161160

162161
int safeBorderWidth = borderWidth > 0 ? borderWidth : 1;
163162
graphics.pushState();
164-
double scale = 1;
165-
166-
if (graphics instanceof ScaledGraphics) {
167-
scale = ((ScaledGraphics) graphics).getAbsoluteScale();
168-
}
163+
double scale = graphics.getAbsoluteScale();
169164
// Top part inside the border (as fillGradient does not allow to fill a
170165
// rectangle with round corners).
171166
Rectangle rect = getBounds().getCopy();

0 commit comments

Comments
 (0)