return target;
}
+ private static double downscaleSwt0(double x) {
+ return hasSwtScale ? x * fromSwtInternalScalingFactorD : x;
+ }
+
+ private static int downscaleToIntegerSwt0(double x) {
+ return (int)(hasSwtScale ? Math.round((double) x * fromSwtInternalScalingFactorD) : x);
+ }
+
+ private static int downscaleSwt0(int x) {
+ return hasSwtScale ? (int) Math.round((double) x * fromSwtInternalScalingFactorD) : x;
+ }
+
+ private static double upscaleSwt0(double x) {
+ return hasSwtScale ? x * toSwtInternalScalingFactorD : x;
+ }
+
+ private static int upscaleToIntegerSwt0(double x) {
+ return (int)(hasSwtScale ? Math.round((double) x * toSwtInternalScalingFactorD) : x);
+ }
+
+ private static int upscaleSwt0(int x) {
+ return hasSwtScale ? (int) Math.round((double) x * toSwtInternalScalingFactorD) : x;
+ }
+
// SWT API Coordinates <-> pixels
+ // Downscaling
+
public static double downscaleSwt(double x) {
initialize();
- return hasSwtScale ? x * fromSwtInternalScalingFactorD : x;
+ return downscaleSwt0(x);
}
public static int downscaleSwt(int x) {
- if (!hasSwtScale)
- return x;
- return (int) Math.round(downscaleSwt((double) x));
+ initialize();
+ return downscaleSwt0(x);
}
public static Point2D downscaleSwt(double x, double y) {
}
public static Point downscaleSwt(int x, int y) {
- return new Point(downscaleSwt(x), downscaleSwt(y));
+ initialize();
+ return new Point(downscaleSwt0(x), downscaleSwt0(y));
}
public static Point2D downscaleSwt(Point2D p) {
}
public static Point downscaleSwtToInteger(Point2D p) {
- return new Point(
- (int) Math.round(downscaleSwt(p.getX())),
- (int) Math.round(downscaleSwt(p.getY())));
+ initialize();
+ return new Point(downscaleToIntegerSwt0(p.getX()), downscaleToIntegerSwt0(p.getY()));
}
public static Rectangle2D downscaleSwt(Rectangle2D r, Rectangle2D target) {
}
public static Rectangle downscaleSwtToInteger(Rectangle2D r) {
+ initialize();
return new Rectangle(
- (int) Math.round(downscaleSwt(r.getMinX())),
- (int) Math.round(downscaleSwt(r.getMinY())),
- (int) Math.round(downscaleSwt(r.getWidth())),
- (int) Math.round(downscaleSwt(r.getHeight())));
+ downscaleToIntegerSwt0(r.getMinX()),
+ downscaleToIntegerSwt0(r.getMinY()),
+ downscaleToIntegerSwt0(r.getWidth()),
+ downscaleToIntegerSwt0(r.getHeight()));
}
+ // Upscaling
+
public static double upscaleSwt(double x) {
initialize();
- return hasSwtScale ? x * toSwtInternalScalingFactorD : x;
+ return upscaleSwt0(x);
}
public static int upscaleSwt(int x) {
initialize();
- if (!hasSwtScale)
- return x;
- return (int) Math.round((double) x * toSwtInternalScalingFactorD);
+ return upscaleSwt0(x);
}
public static Point2D upscaleSwt(double x, double y) {
+ initialize();
if (!hasSwtScale)
return new Point2D.Double(x, y);
double s = toSwtInternalScalingFactorD;
}
public static Point upscaleSwt(int x, int y) {
- return new Point(upscaleSwt(x), upscaleSwt(y));
+ initialize();
+ return new Point(upscaleSwt0(x), upscaleSwt0(y));
}
public static Point2D upscaleSwt(Point2D p) {
}
public static Point upscaleSwtToInteger(Point2D p) {
- return new Point(
- (int) Math.round(upscaleSwt(p.getX())),
- (int) Math.round(upscaleSwt(p.getY())));
+ initialize();
+ return new Point(upscaleToIntegerSwt0(p.getX()), upscaleToIntegerSwt0(p.getY()));
}
public static Point upscaleSwt(Point p) {
public static Rectangle upscaleSwtToInteger(Rectangle2D r) {
return new Rectangle(
- (int) Math.round(upscaleSwt(r.getMinX())),
- (int) Math.round(upscaleSwt(r.getMinY())),
- (int) Math.round(upscaleSwt(r.getWidth())),
- (int) Math.round(upscaleSwt(r.getHeight())));
+ upscaleToIntegerSwt0(r.getMinX()),
+ upscaleToIntegerSwt0(r.getMinY()),
+ upscaleToIntegerSwt0(r.getWidth()),
+ upscaleToIntegerSwt0(r.getHeight()));
}
}