Skip to content

Commit

Permalink
Refactoring autoScaleUp with zoom to scaleUp
Browse files Browse the repository at this point in the history
This commit contributes to the renaming of methods DPIUtil.autoScaleUp
containing int zoom as an argument to DPIUtil.scaleUp, since the scaling
is not done automatically but based on the zoom level which is provided.

Contributes to #62 and #127
  • Loading branch information
amartya4256 committed Jul 11, 2024
1 parent b2c0366 commit 5c160ad
Show file tree
Hide file tree
Showing 32 changed files with 332 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ public static ImageData autoScaleUp (Device device, final ElementAtZoom<ImageDat
}

public static int[] autoScaleUp(int[] pointArray) {
return autoScaleUp(pointArray, deviceZoom);
return scaleUp(pointArray, deviceZoom);
}

public static int[] autoScaleUp(int[] pointArray, int zoom) {
public static int[] scaleUp(int[] pointArray, int zoom) {
if (zoom == 100 || pointArray == null) return pointArray;
float scaleFactor = getScalingFactor(zoom);
int[] returnArray = new int[pointArray.length];
Expand All @@ -372,24 +372,24 @@ public static int[] autoScaleUp(int[] pointArray, int zoom) {
}

public static int[] autoScaleUp(Drawable drawable, int[] pointArray) {
return autoScaleUp(drawable, pointArray, deviceZoom);
return scaleUp(drawable, pointArray, deviceZoom);
}

public static int[] autoScaleUp(Drawable drawable, int[] pointArray, int zoom) {
public static int[] scaleUp(Drawable drawable, int[] pointArray, int zoom) {
if (drawable != null && !drawable.isAutoScalable()) return pointArray;
return autoScaleUp (pointArray, zoom);
return scaleUp (pointArray, zoom);
}
/**
* Auto-scale up int dimensions.
*/
public static int autoScaleUp(int size) {
return autoScaleUp(size, deviceZoom);
return scaleUp(size, deviceZoom);
}

/**
* Auto-scale up int dimensions to match the given zoom level
*/
public static int autoScaleUp(int size, int zoom) {
public static int scaleUp(int size, int zoom) {
if (zoom == 100 || size == SWT.DEFAULT) return size;
float scaleFactor = getScalingFactor(zoom);
return Math.round (size * scaleFactor);
Expand All @@ -408,41 +408,41 @@ public static int autoScaleUpUsingNativeDPI (int size) {
* Auto-scale up int dimensions if enabled for Drawable class.
*/
public static int autoScaleUp(Drawable drawable, int size) {
return autoScaleUp(drawable, size, deviceZoom);
return scaleUp(drawable, size, deviceZoom);
}

public static int autoScaleUp(Drawable drawable, int size, int zoom) {
public static int scaleUp(Drawable drawable, int size, int zoom) {
if (drawable != null && !drawable.isAutoScalable()) return size;
return autoScaleUp (size, zoom);
return scaleUp (size, zoom);
}

public static float autoScaleUp(float size) {
return autoScaleUp(size, deviceZoom);
return scaleUp(size, deviceZoom);
}

public static float autoScaleUp(float size, int zoom) {
public static float scaleUp(float size, int zoom) {
if (zoom == 100 || size == SWT.DEFAULT) return size;
float scaleFactor = getScalingFactor(zoom);
return (size * scaleFactor);
}

public static float autoScaleUp(Drawable drawable, float size) {
return autoScaleUp(drawable, size, deviceZoom);
return scaleUp(drawable, size, deviceZoom);
}

public static float autoScaleUp(Drawable drawable, float size, int zoom) {
public static float scaleUp(Drawable drawable, float size, int zoom) {
if (drawable != null && !drawable.isAutoScalable()) return size;
return autoScaleUp (size, zoom);
return scaleUp (size, zoom);
}

/**
* Returns a new scaled up Point.
*/
public static Point autoScaleUp(Point point) {
return autoScaleUp(point, deviceZoom);
return scaleUp(point, deviceZoom);
}

public static Point autoScaleUp(Point point, int zoom) {
public static Point scaleUp(Point point, int zoom) {
if (zoom == 100 || point == null) return point;
float scaleFactor = getScalingFactor(zoom);
Point scaledPoint = new Point(0,0);
Expand All @@ -455,26 +455,26 @@ public static Point autoScaleUp(Point point, int zoom) {
* Returns a new scaled up Point if enabled for Drawable class.
*/
public static Point autoScaleUp(Drawable drawable, Point point) {
return autoScaleUp (drawable, point, deviceZoom);
return scaleUp (drawable, point, deviceZoom);
}

public static Point autoScaleUp(Drawable drawable, Point point, int zoom) {
public static Point scaleUp(Drawable drawable, Point point, int zoom) {
if (drawable != null && !drawable.isAutoScalable()) return point;
return autoScaleUp (point, zoom);
return scaleUp (point, zoom);
}

/**
* Returns a new scaled up Rectangle.
*/
public static Rectangle autoScaleUp(Rectangle rect) {
return autoScaleUp(rect, deviceZoom);
return scaleUp(rect, deviceZoom);
}

public static Rectangle autoScaleUp(Rectangle rect, int zoom) {
public static Rectangle scaleUp(Rectangle rect, int zoom) {
if (zoom == 100 || rect == null) return rect;
Rectangle scaledRect = new Rectangle(0,0,0,0);
Point scaledTopLeft = DPIUtil.autoScaleUp (new Point(rect.x, rect.y), zoom);
Point scaledBottomRight = DPIUtil.autoScaleUp (new Point(rect.x + rect.width, rect.y + rect.height), zoom);
Point scaledTopLeft = DPIUtil.scaleUp (new Point(rect.x, rect.y), zoom);
Point scaledBottomRight = DPIUtil.scaleUp (new Point(rect.x + rect.width, rect.y + rect.height), zoom);

scaledRect.x = scaledTopLeft.x;
scaledRect.y = scaledTopLeft.y;
Expand All @@ -487,12 +487,12 @@ public static Rectangle autoScaleUp(Rectangle rect, int zoom) {
* Returns a new scaled up Rectangle if enabled for Drawable class.
*/
public static Rectangle autoScaleUp(Drawable drawable, Rectangle rect) {
return autoScaleUp(drawable, rect, deviceZoom);
return scaleUp(drawable, rect, deviceZoom);
}

public static Rectangle autoScaleUp(Drawable drawable, Rectangle rect, int zoom) {
public static Rectangle scaleUp(Drawable drawable, Rectangle rect, int zoom) {
if (drawable != null && !drawable.isAutoScalable()) return rect;
return autoScaleUp (rect, zoom);
return scaleUp (rect, zoom);
}

/**
Expand Down
Loading

0 comments on commit 5c160ad

Please sign in to comment.