Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2016-01-29 11:44:31 +0000
committerLakshmi Shanmugam2016-01-29 11:47:21 +0000
commitca687380ff330e57e8ac427873f374c56e594a35 (patch)
tree8ffb50d510f75cee9269d4bef198b9af2f1330b4
parentc3634270d03d5be362baf2099472dd9b233037ff (diff)
downloadeclipse.platform.swt-ca687380ff330e57e8ac427873f374c56e594a35.tar.gz
eclipse.platform.swt-ca687380ff330e57e8ac427873f374c56e594a35.tar.xz
eclipse.platform.swt-ca687380ff330e57e8ac427873f374c56e594a35.zip
formatting whitespace
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java241
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java8
2 files changed, 123 insertions, 126 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
index 68f1e85821..7ce60357f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
@@ -26,139 +26,136 @@ public class DPIUtil {
private static boolean autoScale = true;
- /**
- * Compute the zoom value based on the DPI value.
- *
- * @return zoom
- */
- static int mapDPIToZoom (int dpi) {
- int zoom;
- if (dpi >= DPI_ZOOM_200) {
- zoom = 200;
- } else if (dpi >= DPI_ZOOM_150) {
- zoom = 150;
- } else {
- zoom = 100;
- }
- return zoom;
+/**
+ * Compute the zoom value based on the DPI value.
+ *
+ * @return zoom
+ */
+static int mapDPIToZoom (int dpi) {
+ int zoom;
+ if (dpi >= DPI_ZOOM_200) {
+ zoom = 200;
+ } else if (dpi >= DPI_ZOOM_150) {
+ zoom = 150;
+ } else {
+ zoom = 100;
}
+ return zoom;
+}
- /**
- * Gets Image file path at specified zoom level, if image is missing then
- * fall-back to 100% image. If provider or fall-back image is not available,
- * throw error.
- */
- static String validateAndGetImagePathAtZoom (ImageFileNameProvider provider, int zoom, boolean[] found) {
- if (provider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- String filename = provider.getImagePath (zoom);
- found [0] = (filename != null);
- /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
- if (zoom != 100 && !found [0]) filename = provider.getImagePath (100);
- if (filename == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return filename;
- }
+/**
+ * Gets Image file path at specified zoom level, if image is missing then
+ * fall-back to 100% image. If provider or fall-back image is not available,
+ * throw error.
+ */
+static String validateAndGetImagePathAtZoom (ImageFileNameProvider provider, int zoom, boolean[] found) {
+ if (provider == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ String filename = provider.getImagePath (zoom);
+ found [0] = (filename != null);
+ /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
+ if (zoom != 100 && !found [0]) filename = provider.getImagePath (100);
+ if (filename == null) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return filename;
+}
- /**
- * Gets Image data at specified zoom level, if image is missing then
- * fall-back to 100% image. If provider or fall-back image is not available,
- * throw error.
- */
- static ImageData validateAndGetImageDataAtZoom (ImageDataProvider provider, int zoom, boolean[] found) {
- if (provider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- ImageData data = provider.getImageData (zoom);
- found [0] = (data != null);
- /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
- if (zoom != 100 && !found [0]) data = provider.getImageData (100);
- if (data == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return data;
- }
- /**
- * Gets scaling factor for the current Image
- */
- static float getscalingFactor (Image image) {
- float scalingFactor = ((float)image.getDeviceZoom())/((float) 100);
- return scalingFactor;
- }
- /**
- * Auto-scale image with ImageData
- */
- static ImageData autoScaleImageData (ImageData imageData, int targetZoom, int currentZoom) {
- if (imageData == null || targetZoom == currentZoom) return imageData;
- float scaleFactor = ((float) targetZoom)/((float) currentZoom);
- return imageData.scaledTo((int)((float)imageData.width * scaleFactor), (int)((float)imageData.height * scaleFactor));
+/**
+ * Gets Image data at specified zoom level, if image is missing then
+ * fall-back to 100% image. If provider or fall-back image is not available,
+ * throw error.
+ */
+static ImageData validateAndGetImageDataAtZoom (ImageDataProvider provider, int zoom, boolean[] found) {
+ if (provider == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ ImageData data = provider.getImageData (zoom);
+ found [0] = (data != null);
+ /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
+ if (zoom != 100 && !found [0]) data = provider.getImageData (100);
+ if (data == null) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return data;
+}
+/**
+ * Gets scaling factor for the current Image
+ */
+static float getscalingFactor (Image image) {
+ float scalingFactor = ((float)image.getDeviceZoom ())/((float) 100);
+ return scalingFactor;
+}
+/**
+ * Auto-scale image with ImageData
+ */
+static ImageData autoScaleImageData (ImageData imageData, int targetZoom, int currentZoom) {
+ if (imageData == null || targetZoom == currentZoom) return imageData;
+ float scaleFactor = ((float) targetZoom)/((float) currentZoom);
+ return imageData.scaledTo ((int)((float)imageData.width * scaleFactor), (int)((float)imageData.height * scaleFactor));
- }
- /**
- * Auto-scale image with ImageFileName
- */
- static ImageData autoScaleImageFileName (String filename, int targetZoom, int currentZoom) {
- if (filename == null) return null;
- ImageData imageData = new ImageData(filename);
- return autoScaleImageData(imageData, targetZoom, currentZoom);
- }
+}
+/**
+ * Auto-scale image with ImageFileName
+ */
+static ImageData autoScaleImageFileName (String filename, int targetZoom, int currentZoom) {
+ if (filename == null) return null;
+ ImageData imageData = new ImageData (filename);
+ return autoScaleImageData (imageData, targetZoom, currentZoom);
+}
- /**
- * Returns a new rectangle as per the scaleFactor.
- */
- static Rectangle scale(Rectangle rect, int targetZoom, int currentZoom) {
- if (rect == null || targetZoom == currentZoom) return rect;
- float scaleFactor = ((float)targetZoom) / (float)currentZoom;
- Rectangle returnRect = new Rectangle (0,0,0,0);
- returnRect.x = (int) (rect.x * scaleFactor);
- returnRect.y = (int) (rect.y * scaleFactor);
- returnRect.width = (int) (rect.width * scaleFactor);
- returnRect.height = (int) (rect.height * scaleFactor);
- return returnRect;
- }
+/**
+ * Returns a new rectangle as per the scaleFactor.
+ */
+static Rectangle scale (Rectangle rect, int targetZoom, int currentZoom) {
+ if (rect == null || targetZoom == currentZoom) return rect;
+ float scaleFactor = ((float)targetZoom) / (float)currentZoom;
+ Rectangle returnRect = new Rectangle (0,0,0,0);
+ returnRect.x = (int) (rect.x * scaleFactor);
+ returnRect.y = (int) (rect.y * scaleFactor);
+ returnRect.width = (int) (rect.width * scaleFactor);
+ returnRect.height = (int) (rect.height * scaleFactor);
+ return returnRect;
+}
- /**
- * Returns an <code>ImageData</code> for specified zoom.
- */
- static ImageData getImageData (Image image, int zoom) {
- if (image.currentDeviceZoom == zoom) return image._getImageData();
- ImageData imageData = null;
- if (image.imageDataProvider != null) {
- boolean[] found = new boolean[1];
- imageData = DPIUtil.validateAndGetImageDataAtZoom (image.imageDataProvider, zoom, found);
- if (!found[0]) {
- imageData = DPIUtil.autoScaleImageData(imageData, zoom, 100);
- }
- }
- else if (image.imageFileNameProvider != null) {
- boolean[] found = new boolean[1];
- String filename = DPIUtil.validateAndGetImagePathAtZoom (image.imageFileNameProvider, zoom, found);
- if (!found[0]) {
- imageData = DPIUtil.autoScaleImageFileName(filename, zoom, 100);
- }
- else {
- imageData = new ImageData (filename);
- }
+/**
+ * Returns an <code>ImageData</code> for specified zoom.
+ */
+static ImageData getImageData (Image image, int zoom) {
+ if (image.currentDeviceZoom == zoom) return image._getImageData ();
+ ImageData imageData = null;
+ if (image.imageDataProvider != null) {
+ boolean[] found = new boolean[1];
+ imageData = DPIUtil.validateAndGetImageDataAtZoom (image.imageDataProvider, zoom, found);
+ if (!found[0]) {
+ imageData = DPIUtil.autoScaleImageData (imageData, zoom, 100);
}
- else {
- /* Get ImageData at currentZoom and scale it to specified zoom. */
- imageData = image._getImageData();
- imageData = DPIUtil.autoScaleImageData(imageData, zoom, image.currentDeviceZoom);
+ } else if (image.imageFileNameProvider != null) {
+ boolean[] found = new boolean[1];
+ String filename = DPIUtil.validateAndGetImagePathAtZoom (image.imageFileNameProvider, zoom, found);
+ if (!found[0]) {
+ imageData = DPIUtil.autoScaleImageFileName (filename, zoom, 100);
+ } else {
+ imageData = new ImageData (filename);
}
- return imageData;
+ } else {
+ /* Get ImageData at currentZoom and scale it to specified zoom. */
+ imageData = image._getImageData ();
+ imageData = DPIUtil.autoScaleImageData (imageData, zoom, image.currentDeviceZoom);
}
+ return imageData;
+}
- /**
- * Returns Scaling factor from the display
- * @return float scaling factor
- */
- public static float getScalingFactor (Device device) {
- float scalingFactor = 1;
- if (getAutoScale()) {
- scalingFactor = ( device.getDeviceZoom () / 100f );
- }
- return scalingFactor;
+/**
+ * Returns Scaling factor from the display
+ * @return float scaling factor
+ */
+public static float getScalingFactor (Device device) {
+ float scalingFactor = 1;
+ if (getAutoScale ()) {
+ scalingFactor = (device.getScalingFactor ()/100f);
}
+ return scalingFactor;
+}
- public static boolean getAutoScale() {
- return autoScale;
- }
+public static boolean getAutoScale () {
+ return autoScale;
+}
- public static void setAutoScale(boolean autoScale) {
- DPIUtil.autoScale = autoScale;
- }
+public static void setAutoScale(boolean autoScale) {
+ DPIUtil.autoScale = autoScale;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
index 38b6d540ff..4367d0c305 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
@@ -89,7 +89,7 @@ public Device getDevice() {
* @since 3.105
*
*/
-public boolean getEnableAutoScaling () {
+public boolean getEnableAutoScaling() {
return DPIUtil.getAutoScale();
}
/**
@@ -97,7 +97,7 @@ public boolean getEnableAutoScaling () {
* @since 3.105
*
*/
-void setEnableAutoScaling (boolean value) {
+void setEnableAutoScaling(boolean value) {
DPIUtil.setAutoScale(value);
}
void init() {
@@ -119,8 +119,8 @@ public abstract boolean isDisposed();
/**
* @since 3.105
*/
-public int getDeviceZoom () {
- return DPIUtil.mapDPIToZoom ( device._getDPIx ());
+public int getDeviceZoom() {
+ return DPIUtil.mapDPIToZoom(device._getDPIx());
}
} \ No newline at end of file

Back to the top