Package org.eclipse.swt.internal
Class DPIUtil
java.lang.Object
org.eclipse.swt.internal.DPIUtil
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 ClassesModifier and TypeClassDescriptionstatic final classAutoScale ImageDataProvider.static final recordRepresents an element, such as some image data, at a specific zoom level. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatautoScaleDown(float size) Auto-scale down float dimensions.static float[]autoScaleDown(float[] size) Auto-scale down float array dimensions.static intautoScaleDown(int size) Auto-scale down int dimensions.static int[]autoScaleDown(int[] pointArray) static ImageDataautoScaleDown(Device device, ImageData imageData) Auto-scale down ImageDatastatic floatautoScaleDown(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 intautoScaleDown(Drawable drawable, int size) Auto-scale down int dimensions if enabled for Drawable class.static int[]autoScaleDown(Drawable drawable, int[] pointArray) static PointautoScaleDown(Drawable drawable, Point point) Returns a new scaled down Point if enabled for Drawable class.static RectangleautoScaleDown(Drawable drawable, Rectangle rect) Returns a new scaled down Rectangle if enabled for Drawable class.static PointautoScaleDown(Point point) Returns a new scaled down Point.static RectangleautoScaleDown(Rectangle rect) Returns a new scaled down Rectangle.static ImageDataautoScaleImageData(Device device, ImageData imageData, int imageDataZoomFactor) Auto-scale ImageData to device zoom that are at given zoom factor.static floatautoScaleUp(float size) static intautoScaleUp(int size) Auto-scale up int dimensions.static int[]autoScaleUp(int[] pointArray) static ImageDataautoScaleUp(Device device, ImageData imageData) Auto-scale up ImageData to device zoom that is at 100%.static floatautoScaleUp(Drawable drawable, float size) static intautoScaleUp(Drawable drawable, int size) Auto-scale up int dimensions if enabled for Drawable class.static int[]autoScaleUp(Drawable drawable, int[] pointArray) static PointautoScaleUp(Drawable drawable, Point point) Returns a new scaled up Point if enabled for Drawable class.static RectangleautoScaleUp(Drawable drawable, Rectangle rect) Returns a new scaled up Rectangle if enabled for Drawable class.static PointautoScaleUp(Point point) Returns a new scaled up Point.static RectangleautoScaleUp(Rectangle rect) Returns a new scaled up Rectangle.static intstatic intstatic intgetZoomForAutoscaleProperty(int nativeDeviceZoom) static booleanstatic booleanstatic intmapDPIToZoom(int dpi) Compute the zoom value based on the DPI value.static intmapZoomToDPI(int zoom) Compute the DPI value value based on the zoom.static voidrunWithAutoScaleValue(String autoScaleValue, Runnable runnable) static RectanglescaleBounds(Rectangle rect, int targetZoom, int currentZoom) Returns a new rectangle as per the scaleFactor.static float[]scaleDown(float[] size, int zoom) static floatscaleDown(float size, int zoom) static intscaleDown(int size, int zoom) static float[]static floatstatic intstatic Pointstatic Rectanglestatic Pointstatic Rectanglestatic ImageDatascaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageDatastatic ImageDatascaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) static floatscaleUp(float size, int zoom) static int[]scaleUp(int[] pointArray, int zoom) static intscaleUp(int size, int zoom) Auto-scale up int dimensions to match the given zoom levelstatic floatstatic int[]static intstatic Pointstatic Rectanglestatic Pointstatic Rectanglestatic voidstatic voidsetDeviceZoom(int nativeDeviceZoom) static voidsetMonitorSpecificScaling(boolean activate) static DPIUtil.ElementAtZoom<ImageData> validateAndGetImageDataAtZoom(ImageDataProvider provider, int zoom) Gets ImageData that are appropriate for the specified zoom level together with the zoom level at which the image data are.static DPIUtil.ElementAtZoom<String> validateAndGetImagePathAtZoom(ImageFileNameProvider provider, int zoom) Gets the image file path that are appropriate for the specified zoom level together with the zoom level at which the image data are.
-
Constructor Details
-
DPIUtil
public DPIUtil()
-
-
Method Details
-
autoScaleDown
Auto-scale down ImageData -
autoScaleDown
public static int[] autoScaleDown(int[] pointArray) -
autoScaleDown
-
autoScaleDown
public static float[] autoScaleDown(float[] size) Auto-scale down float array dimensions. -
scaleDown
public static float[] scaleDown(float[] size, int zoom) -
autoScaleDown
Auto-scale down float array dimensions if enabled for Drawable class. -
scaleDown
-
autoScaleDown
public static int autoScaleDown(int size) Auto-scale down int dimensions. -
scaleDown
public static int scaleDown(int size, int zoom) -
autoScaleDown
Auto-scale down int dimensions if enabled for Drawable class. -
scaleDown
-
autoScaleDown
public static float autoScaleDown(float size) Auto-scale down float dimensions. -
scaleDown
public static float scaleDown(float size, int zoom) -
autoScaleDown
Auto-scale down float dimensions if enabled for Drawable class. -
scaleDown
-
autoScaleDown
Returns a new scaled down Point. -
scaleDown
-
autoScaleDown
Returns a new scaled down Point if enabled for Drawable class. -
scaleDown
-
autoScaleDown
Returns a new scaled down Rectangle. -
scaleDown
-
autoScaleDown
Returns a new scaled down Rectangle if enabled for Drawable class. -
scaleDown
-
scaleImageData
public static ImageData scaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageData -
scaleImageData
public static ImageData scaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) -
isSmoothScalingEnabled
public static boolean isSmoothScalingEnabled() -
scaleBounds
Returns a new rectangle as per the scaleFactor. -
autoScaleImageData
public static ImageData autoScaleImageData(Device device, ImageData imageData, int imageDataZoomFactor) Auto-scale ImageData to device zoom that are at given zoom factor. -
autoScaleUp
Auto-scale up ImageData to device zoom that is at 100%. -
autoScaleUp
public static int[] autoScaleUp(int[] pointArray) -
scaleUp
public static int[] scaleUp(int[] pointArray, int zoom) -
autoScaleUp
-
scaleUp
-
autoScaleUp
public static int autoScaleUp(int size) Auto-scale up int dimensions. -
scaleUp
public static int scaleUp(int size, int zoom) Auto-scale up int dimensions to match the given zoom level -
autoScaleUp
Auto-scale up int dimensions if enabled for Drawable class. -
scaleUp
-
autoScaleUp
public static float autoScaleUp(float size) -
scaleUp
public static float scaleUp(float size, int zoom) -
autoScaleUp
-
scaleUp
-
autoScaleUp
Returns a new scaled up Point. -
scaleUp
-
autoScaleUp
Returns a new scaled up Point if enabled for Drawable class. -
scaleUp
-
autoScaleUp
Returns a new scaled up Rectangle. -
scaleUp
-
autoScaleUp
Returns a new scaled up Rectangle if enabled for Drawable class. -
scaleUp
-
mapDPIToZoom
public static int mapDPIToZoom(int dpi) Compute the zoom value based on the DPI value.- Returns:
- zoom
-
mapZoomToDPI
public static int mapZoomToDPI(int zoom) Compute the DPI value value based on the zoom.- Returns:
- DPI
-
validateAndGetImageDataAtZoom
public static DPIUtil.ElementAtZoom<ImageData> validateAndGetImageDataAtZoom(ImageDataProvider provider, int zoom) Gets ImageData that are appropriate for the specified zoom level together with the zoom level at which the image data are. If there is an image at the specified zoom level, it is returned. Otherwise the next larger image at 150% and 200% is returned, if existing. If none of these is found, the 100% image is returned as a fallback. If provider or fallback image is not available, an error is thrown. -
validateAndGetImagePathAtZoom
public static DPIUtil.ElementAtZoom<String> validateAndGetImagePathAtZoom(ImageFileNameProvider provider, int zoom) Gets the image file path that are appropriate for the specified zoom level together with the zoom level at which the image data are. If there is an image at the specified zoom level, it is returned. Otherwise the next larger image at 150% and 200% is returned, if existing. If none of these is found, the 100% image is returned as a fallback. If provider or fallback image is not available, an error is thrown. -
getNativeDeviceZoom
public static int getNativeDeviceZoom() -
getDeviceZoom
public static int getDeviceZoom() -
setDeviceZoom
public static void setDeviceZoom(int nativeDeviceZoom) -
getZoomForAutoscaleProperty
public static int getZoomForAutoscaleProperty(int nativeDeviceZoom) -
runWithAutoScaleValue
-
setMonitorSpecificScaling
public static void setMonitorSpecificScaling(boolean activate) -
isMonitorSpecificScalingActive
public static boolean isMonitorSpecificScalingActive() -
setAutoScaleForMonitorSpecificScaling
public static void setAutoScaleForMonitorSpecificScaling()
-