Package org.eclipse.swt.internal
Class DPIUtil
- java.lang.Object
-
- org.eclipse.swt.internal.DPIUtil
-
public class DPIUtil extends java.lang.Object
This class hold common constants and utility functions w.r.t. to SWT high DPI functionality.The
autoScaleUp(..)
methods convert from API coordinates (in SWT points) to internal high DPI coordinates (in pixels) that interface with native widgets.The
autoScaleDown(..)
convert from high DPI pixels to API coordinates (in SWT points).- Since:
- 3.105
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DPIUtil.AutoScaleImageDataProvider
AutoScale ImageDataProvider.
-
Constructor Summary
Constructors Constructor Description DPIUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Rectangle
autoScaleBounds(Rectangle rect, int targetZoom, int currentZoom)
Returns a new rectangle as per the scaleFactor.static float
autoScaleDown(float size)
Auto-scale down float dimensions.static float[]
autoScaleDown(float[] size)
Auto-scale down float array dimensions.static int
autoScaleDown(int size)
Auto-scale down int dimensions.static int[]
autoScaleDown(int[] pointArray)
static ImageData
autoScaleDown(Device device, ImageData imageData)
Auto-scale down ImageDatastatic float
autoScaleDown(Drawable drawable, float size)
Auto-scale down float dimensions if enabled for Drawable class.static float[]
autoScaleDown(Drawable drawable, float[] size)
Auto-scale down float array dimensions if enabled for Drawable class.static int
autoScaleDown(Drawable drawable, int size)
Auto-scale down int dimensions if enabled for Drawable class.static int[]
autoScaleDown(Drawable drawable, int[] pointArray)
static Point
autoScaleDown(Drawable drawable, Point point)
Returns a new scaled down Point if enabled for Drawable class.static Rectangle
autoScaleDown(Drawable drawable, Rectangle rect)
Returns a new scaled down Rectangle if enabled for Drawable class.static Point
autoScaleDown(Point point)
Returns a new scaled down Point.static Rectangle
autoScaleDown(Rectangle rect)
Returns a new scaled down Rectangle.static ImageData
autoScaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom)
Auto-scale image with ImageDatastatic float
autoScaleUp(float size)
static int
autoScaleUp(int size)
Auto-scale up int dimensions.static int[]
autoScaleUp(int[] pointArray)
static ImageData
autoScaleUp(Device device, ImageData imageData)
Auto-scale up ImageDatastatic float
autoScaleUp(Drawable drawable, float size)
static int
autoScaleUp(Drawable drawable, int size)
Auto-scale up int dimensions if enabled for Drawable class.static int[]
autoScaleUp(Drawable drawable, int[] pointArray)
static Point
autoScaleUp(Drawable drawable, Point point)
Returns a new scaled up Point if enabled for Drawable class.static Rectangle
autoScaleUp(Drawable drawable, Rectangle rect)
Returns a new scaled up Rectangle if enabled for Drawable class.static Point
autoScaleUp(Point point)
Returns a new scaled up Point.static Rectangle
autoScaleUp(Rectangle rect)
Returns a new scaled up Rectangle.static int
autoScaleUpUsingNativeDPI(int size)
Auto-scale up int dimensions using Native DPIstatic int
getDeviceZoom()
static int
getZoomForAutoscaleProperty(int nativeDeviceZoom)
static int
mapDPIToZoom(int dpi)
Compute the zoom value based on the DPI value.static void
setDeviceZoom(int nativeDeviceZoom)
static void
setUseCairoAutoScale(boolean cairoAutoScale)
static boolean
useCairoAutoScale()
static ImageData
validateAndGetImageDataAtZoom(ImageDataProvider provider, int zoom, boolean[] found)
Gets Image data at specified zoom level, if image is missing then fall-back to 100% image.static java.lang.String
validateAndGetImagePathAtZoom(ImageFileNameProvider provider, int zoom, boolean[] found)
Gets Image file path at specified zoom level, if image is missing then fall-back to 100% image.
-
-
-
Method Detail
-
autoScaleDown
public static ImageData autoScaleDown(Device device, ImageData imageData)
Auto-scale down ImageData
-
autoScaleDown
public static int[] autoScaleDown(int[] pointArray)
-
autoScaleDown
public static int[] autoScaleDown(Drawable drawable, int[] pointArray)
-
autoScaleDown
public static float[] autoScaleDown(float[] size)
Auto-scale down float array dimensions.
-
autoScaleDown
public static float[] autoScaleDown(Drawable drawable, float[] size)
Auto-scale down float array dimensions if enabled for Drawable class.
-
autoScaleDown
public static int autoScaleDown(int size)
Auto-scale down int dimensions.
-
autoScaleDown
public static int autoScaleDown(Drawable drawable, int size)
Auto-scale down int dimensions if enabled for Drawable class.
-
autoScaleDown
public static float autoScaleDown(float size)
Auto-scale down float dimensions.
-
autoScaleDown
public static float autoScaleDown(Drawable drawable, float size)
Auto-scale down float dimensions if enabled for Drawable class.
-
autoScaleDown
public static Point autoScaleDown(Drawable drawable, Point point)
Returns a new scaled down Point if enabled for Drawable class.
-
autoScaleDown
public static Rectangle autoScaleDown(Rectangle rect)
Returns a new scaled down Rectangle.
-
autoScaleDown
public static Rectangle autoScaleDown(Drawable drawable, Rectangle rect)
Returns a new scaled down Rectangle if enabled for Drawable class.
-
autoScaleImageData
public static ImageData autoScaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom)
Auto-scale image with ImageData
-
autoScaleBounds
public static Rectangle autoScaleBounds(Rectangle rect, int targetZoom, int currentZoom)
Returns a new rectangle as per the scaleFactor.
-
autoScaleUp
public static ImageData autoScaleUp(Device device, ImageData imageData)
Auto-scale up ImageData
-
autoScaleUp
public static int[] autoScaleUp(int[] pointArray)
-
autoScaleUp
public static int[] autoScaleUp(Drawable drawable, int[] pointArray)
-
autoScaleUp
public static int autoScaleUp(int size)
Auto-scale up int dimensions.
-
autoScaleUpUsingNativeDPI
public static int autoScaleUpUsingNativeDPI(int size)
Auto-scale up int dimensions using Native DPI
-
autoScaleUp
public static int autoScaleUp(Drawable drawable, int size)
Auto-scale up int dimensions if enabled for Drawable class.
-
autoScaleUp
public static float autoScaleUp(float size)
-
autoScaleUp
public static float autoScaleUp(Drawable drawable, float size)
-
autoScaleUp
public static Point autoScaleUp(Drawable drawable, Point point)
Returns a new scaled up Point if enabled for Drawable class.
-
autoScaleUp
public static Rectangle autoScaleUp(Drawable drawable, Rectangle rect)
Returns a new scaled up Rectangle if enabled for Drawable class.
-
mapDPIToZoom
public static int mapDPIToZoom(int dpi)
Compute the zoom value based on the DPI value.- Returns:
- zoom
-
validateAndGetImageDataAtZoom
public static ImageData validateAndGetImageDataAtZoom(ImageDataProvider provider, int zoom, boolean[] found)
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.
-
validateAndGetImagePathAtZoom
public static java.lang.String validateAndGetImagePathAtZoom(ImageFileNameProvider provider, int zoom, boolean[] found)
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.
-
getDeviceZoom
public static int getDeviceZoom()
-
setDeviceZoom
public static void setDeviceZoom(int nativeDeviceZoom)
-
setUseCairoAutoScale
public static void setUseCairoAutoScale(boolean cairoAutoScale)
-
useCairoAutoScale
public static boolean useCairoAutoScale()
-
getZoomForAutoscaleProperty
public static int getZoomForAutoscaleProperty(int nativeDeviceZoom)
-
-