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 SummaryNested ClassesModifier and TypeClassDescriptionstatic final classAutoScale ImageDataProvider.static final recordRepresents an element, such as some image data, at a specific zoom level.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic RectangleautoScaleBounds(Rectangle rect, int targetZoom, int currentZoom) Returns a new rectangle as per the scaleFactor.static 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 ImageDataautoScaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageDatastatic ImageDataautoScaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) static floatautoScaleUp(float size) static floatautoScaleUp(float size, int zoom) static intautoScaleUp(int size) Auto-scale up int dimensions.static int[]autoScaleUp(int[] pointArray) static int[]autoScaleUp(int[] pointArray, int zoom) static intautoScaleUp(int size, int zoom) Auto-scale up int dimensions to match the given zoom levelstatic ImageDataautoScaleUp(Device device, ImageData imageData) Auto-scale up ImageData to device zoom that is at 100%.static ImageDataautoScaleUp(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom) static floatautoScaleUp(Drawable drawable, float size) static floatautoScaleUp(Drawable drawable, float size, int zoom) static intautoScaleUp(Drawable drawable, int size) Auto-scale up int dimensions if enabled for Drawable class.static int[]autoScaleUp(Drawable drawable, int[] pointArray) static int[]autoScaleUp(Drawable drawable, int[] pointArray, int zoom) static intautoScaleUp(Drawable drawable, int size, int zoom) static PointautoScaleUp(Drawable drawable, Point point) Returns a new scaled up Point if enabled for Drawable class.static PointautoScaleUp(Drawable drawable, Point point, int zoom) static RectangleautoScaleUp(Drawable drawable, Rectangle rect) Returns a new scaled up Rectangle if enabled for Drawable class.static RectangleautoScaleUp(Drawable drawable, Rectangle rect, int zoom) static PointautoScaleUp(Point point) Returns a new scaled up Point.static PointautoScaleUp(Point point, int zoom) static RectangleautoScaleUp(Rectangle rect) Returns a new scaled up Rectangle.static RectangleautoScaleUp(Rectangle rect, int zoom) static intautoScaleUpUsingNativeDPI(int size) Auto-scale up int dimensions using Native DPIstatic intstatic intstatic intgetZoomForAutoscaleProperty(int nativeDeviceZoom) static 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 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 voidsetDeviceZoom(int nativeDeviceZoom) static voidsetUseCairoAutoScale(boolean cairoAutoScale) static booleanstatic 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- 
DPIUtilpublic DPIUtil()
 
- 
- 
Method Details- 
autoScaleDownAuto-scale down ImageData
- 
autoScaleDownpublic static int[] autoScaleDown(int[] pointArray) 
- 
autoScaleDown
- 
autoScaleDownpublic static float[] autoScaleDown(float[] size) Auto-scale down float array dimensions.
- 
scaleDownpublic static float[] scaleDown(float[] size, int zoom) 
- 
autoScaleDownAuto-scale down float array dimensions if enabled for Drawable class.
- 
scaleDown
- 
autoScaleDownpublic static int autoScaleDown(int size) Auto-scale down int dimensions.
- 
scaleDownpublic static int scaleDown(int size, int zoom) 
- 
autoScaleDownAuto-scale down int dimensions if enabled for Drawable class.
- 
scaleDown
- 
autoScaleDownpublic static float autoScaleDown(float size) Auto-scale down float dimensions.
- 
scaleDownpublic static float scaleDown(float size, int zoom) 
- 
autoScaleDownAuto-scale down float dimensions if enabled for Drawable class.
- 
scaleDown
- 
autoScaleDownReturns a new scaled down Point.
- 
scaleDown
- 
autoScaleDownReturns a new scaled down Point if enabled for Drawable class.
- 
scaleDown
- 
autoScaleDownReturns a new scaled down Rectangle.
- 
scaleDown
- 
autoScaleDownReturns a new scaled down Rectangle if enabled for Drawable class.
- 
scaleDown
- 
autoScaleImageDatapublic static ImageData autoScaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageData
- 
autoScaleImageDatapublic static ImageData autoScaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) 
- 
autoScaleBoundsReturns a new rectangle as per the scaleFactor.
- 
autoScaleImageDatapublic static ImageData autoScaleImageData(Device device, ImageData imageData, int imageDataZoomFactor) Auto-scale ImageData to device zoom that are at given zoom factor.
- 
autoScaleUpAuto-scale up ImageData to device zoom that is at 100%.
- 
autoScaleUp
- 
autoScaleUppublic static int[] autoScaleUp(int[] pointArray) 
- 
autoScaleUppublic static int[] autoScaleUp(int[] pointArray, int zoom) 
- 
autoScaleUp
- 
autoScaleUp
- 
autoScaleUppublic static int autoScaleUp(int size) Auto-scale up int dimensions.
- 
autoScaleUppublic static int autoScaleUp(int size, int zoom) Auto-scale up int dimensions to match the given zoom level
- 
autoScaleUpUsingNativeDPIpublic static int autoScaleUpUsingNativeDPI(int size) Auto-scale up int dimensions using Native DPI
- 
autoScaleUpAuto-scale up int dimensions if enabled for Drawable class.
- 
autoScaleUp
- 
autoScaleUppublic static float autoScaleUp(float size) 
- 
autoScaleUppublic static float autoScaleUp(float size, int zoom) 
- 
autoScaleUp
- 
autoScaleUp
- 
autoScaleUpReturns a new scaled up Point.
- 
autoScaleUp
- 
autoScaleUpReturns a new scaled up Point if enabled for Drawable class.
- 
autoScaleUp
- 
autoScaleUpReturns a new scaled up Rectangle.
- 
autoScaleUp
- 
autoScaleUpReturns a new scaled up Rectangle if enabled for Drawable class.
- 
autoScaleUp
- 
mapDPIToZoompublic static int mapDPIToZoom(int dpi) Compute the zoom value based on the DPI value.- Returns:
- zoom
 
- 
mapZoomToDPIpublic static int mapZoomToDPI(int zoom) Compute the DPI value value based on the zoom.- Returns:
- DPI
 
- 
validateAndGetImageDataAtZoompublic 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.
- 
validateAndGetImagePathAtZoompublic 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.
- 
getNativeDeviceZoompublic static int getNativeDeviceZoom()
- 
getDeviceZoompublic static int getDeviceZoom()
- 
setDeviceZoompublic static void setDeviceZoom(int nativeDeviceZoom) 
- 
setUseCairoAutoScalepublic static void setUseCairoAutoScale(boolean cairoAutoScale) 
- 
useCairoAutoScalepublic static boolean useCairoAutoScale()
- 
getZoomForAutoscalePropertypublic static int getZoomForAutoscaleProperty(int nativeDeviceZoom) 
- 
isAutoScaleOnRuntimeActivepublic static boolean isAutoScaleOnRuntimeActive()
 
-