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 recordRepresents an element, such as some image data, at a specific zoom level.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic ImageDataautoScaleImageData(Device device, ImageData imageData, float scaleFactor) static ImageDataautoScaleImageData(Device device, ImageData imageData, int imageDataZoomFactor) Auto-scale ImageData to device zoom that are at given zoom factor.static intstatic intstatic floatgetScalingFactor(int zoom) Returns scaling factor from the given device zoomstatic floatgetScalingFactor(int targetZoom, int currentZoom) static 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 floatpixelToPoint(float size, int zoom) static intpixelToPoint(int size, int zoom) static voidrunWithAutoScaleValue(String autoScaleValue, Runnable runnable) static ImageDatascaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageDatastatic ImageDatascaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) static voidsetDeviceZoom(int nativeDeviceZoom) 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.static voidvalidateLinearScaling(ImageDataProvider provider) 
- 
Constructor Details- 
DPIUtilpublic DPIUtil()
 
- 
- 
Method Details- 
pixelToPointpublic static int pixelToPoint(int size, int zoom) 
- 
pixelToPointpublic static float pixelToPoint(float size, int zoom) 
- 
scaleImageDatapublic static ImageData scaleImageData(Device device, ImageData imageData, int targetZoom, int currentZoom) Auto-scale image with ImageData
- 
scaleImageDatapublic static ImageData scaleImageData(Device device, DPIUtil.ElementAtZoom<ImageData> elementAtZoom, int targetZoom) 
- 
autoScaleImageData
- 
isSmoothScalingEnabledpublic static boolean isSmoothScalingEnabled()
- 
autoScaleImageDatapublic static ImageData autoScaleImageData(Device device, ImageData imageData, int imageDataZoomFactor) Auto-scale ImageData to device zoom that are at given zoom factor.
- 
getScalingFactorpublic static float getScalingFactor(int zoom) Returns scaling factor from the given device zoom- Returns:
- float scaling factor
 
- 
getScalingFactorpublic static float getScalingFactor(int targetZoom, int currentZoom) 
- 
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
 
- 
validateLinearScaling
- 
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) 
- 
getZoomForAutoscalePropertypublic static int getZoomForAutoscaleProperty(int nativeDeviceZoom) 
- 
runWithAutoScaleValue
 
-