-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
This was brought up here and here. When a plain SWTGraphic is used, scaling is done internally using an SWT Transform. This class seems to behave differently on different platforms.
For example the following snippet:
package test;
import org.eclipse.draw2d.SWTGraphics;
import org.eclipse.draw2d.ScaledGraphics;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Pattern;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Test {
public static void main(String[] args) {
// System.setProperty("swt.autoScale.updateOnRuntime", "true");
Shell shell = new Shell();
shell.setSize(400, 400);
Display d = shell.getDisplay();
Color white = new Color(255, 255, 255);
Color gray = new Color(128, 128, 128);
shell.addPaintListener(event -> {
GC gc = event.gc;
for (int y = 0 ; y < shell.getSize().y; y += 50) {
gc.setBackground(y % 20 == 0 ? white : gray);
gc.fillRectangle(0, y, shell.getSize().x, 50);
}
SWTGraphics g1 = new SWTGraphics(gc);
g1.translate(50, 100);
g1.scale(2.5f);
g1.setBackgroundColor(white);
g1.drawText("Hello World", 0, 0);
g1.dispose();
gc.setTransform(null);
ScaledGraphics g2 = new ScaledGraphics(new SWTGraphics(gc));
g2.translate(50, 100);
g2.scale(2.5f);
g2.setBackgroundColor(white);
g2.drawText("Hello World", 0, 0);
g2.dispose();
});
shell.open();
while(!shell.isDisposed()) {
while(!d.readAndDispatch()) {
d.sleep();
}
}
}
}
Reactions are currently unavailable