Class GUIHelper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final org.eclipse.swt.graphics.Colorstatic final intstatic final org.eclipse.swt.graphics.Fontstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.swt.graphics.RGBblend(org.eclipse.swt.graphics.RGB val1, org.eclipse.swt.graphics.RGB val2) Blend the two colour values returning a value that is halfway between them.static intconvertHorizontalDpiToPixel(int dpi) Converts the given DPI scaled value to a pixel value using the factor for the horizontal DPI.static intconvertHorizontalDpiToPixel(int dpi, boolean forDisplayDPI) Converts the given DPI scaled value to a pixel value using the factor for the horizontal DPI.static intconvertHorizontalDpiToPixel(int dpi, IConfigRegistry configRegistry) Default method to convert the given amount of horizontal dots per inch to a pixel value.static intconvertHorizontalPixelToDpi(int pixel) Converts the given amount of pixels to a DPI scaled value using the factor for the horizontal DPI value.static intconvertHorizontalPixelToDpi(int pixel, boolean forDisplayDPI) Converts the given amount of pixels to a DPI scaled value using the factor for the horizontal DPI value.static intconvertHorizontalPixelToDpi(int pixel, IConfigRegistry configRegistry) Default method to convert the given amount of pixels to a horizontal dots per inch value.static intconvertVerticalDpiToPixel(int dpi) Converts the given DPI scaled value to a pixel value using the factor for the vertical DPI.static intconvertVerticalDpiToPixel(int dpi, boolean forDisplayDPI) Converts the given DPI scaled value to a pixel value using the factor for the vertical DPI.static intconvertVerticalDpiToPixel(int dpi, IConfigRegistry configRegistry) Default method to convert the given amount of vertical dots per inch to pixel.static intconvertVerticalPixelToDpi(int pixel) Converts the given amount of pixels to a DPI scaled value using the factor for the vertical DPI.static intconvertVerticalPixelToDpi(int pixel, boolean forDisplayDPI) Converts the given amount of pixels to a DPI scaled value using the factor for the vertical DPI.static intconvertVerticalPixelToDpi(int pixel, IConfigRegistry configRegistry) Default method to convert the given amount of pixels to a vertical dots per inch value.static org.eclipse.swt.graphics.ColorgetColor(int red, int green, int blue) static org.eclipse.swt.graphics.Colorstatic org.eclipse.swt.graphics.ColorgetColor(org.eclipse.swt.graphics.RGB rgb) static org.eclipse.swt.graphics.ImagegetDisplayImage(String imageName) Returns theImagerepresentation of a NatTable internal image resource.static org.eclipse.swt.graphics.ImagegetDisplayImageByURL(String key, URL url) This method returns theImagethat is registered for the given key.static org.eclipse.swt.graphics.ImagegetDisplayImageByURL(URL url) This method extracts the base filename out of the givenURLand uses it as key to search for theImagein theImageRegistry.static floatgetDpiFactor(int dpi) Returns the factor for scaling calculations of pixels regarding the DPI.static intgetDpiX()static intgetDpiX(boolean displayDPI) Returns the horizontal dots per inch configured locally.static intgetDpiY()static intgetDpiY(boolean displayDPI) Returns the vertical dots per inch configured locally.static org.eclipse.swt.graphics.Fontstatic org.eclipse.swt.graphics.FontgetFont(org.eclipse.swt.graphics.FontData... fontDatas) static org.eclipse.swt.graphics.ImageReturns theImagerepresentation of a NatTable internal image resource.static org.eclipse.swt.graphics.ImageReturns theImagerepresentation of a NatTable internal image resource.static org.eclipse.swt.graphics.ImagegetImageByURL(String key, URL url) This method returns theImagethat is registered for the given key.static org.eclipse.swt.graphics.ImagegetImageByURL(String key, URL url, boolean considerScaling, boolean forDisplayDPI) This method returns theImagethat is registered for the given key.static org.eclipse.swt.graphics.ImagegetImageByURL(URL url) This method extracts the base filename out of the givenURLand uses it as key to search for theImagein theImageRegistry.static org.eclipse.jface.resource.ImageDescriptorgetImageDescriptor(String imageName) Returns theImageDescriptorfor a NatTable internal image resource.static URLgetInternalImageUrl(String imageName) Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.static URLgetInternalImageUrl(String imageName, boolean needScaling) Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.static URLgetInternalImageUrl(String imageName, boolean needScaling, boolean forDisplayDPI) Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.static org.eclipse.swt.graphics.FontgetScaledFont(org.eclipse.swt.graphics.Font font, float fontScalingFactor) Return a scaled version of the configured font if font scaling is needed.static Stringstatic StringgetScalingImageSuffix(boolean forDisplayDPI) static Stringstatic booleanstatic booleanneedScaling(boolean forDisplay) static voidsetDpi(int x, int y) Set the dpi values that are used for image scaling.
-
Field Details
-
COLOR_GRAY
public static final org.eclipse.swt.graphics.Color COLOR_GRAY -
COLOR_WHITE
public static final org.eclipse.swt.graphics.Color COLOR_WHITE -
COLOR_DARK_GRAY
public static final org.eclipse.swt.graphics.Color COLOR_DARK_GRAY -
COLOR_BLACK
public static final org.eclipse.swt.graphics.Color COLOR_BLACK -
COLOR_BLUE
public static final org.eclipse.swt.graphics.Color COLOR_BLUE -
COLOR_RED
public static final org.eclipse.swt.graphics.Color COLOR_RED -
COLOR_YELLOW
public static final org.eclipse.swt.graphics.Color COLOR_YELLOW -
COLOR_GREEN
public static final org.eclipse.swt.graphics.Color COLOR_GREEN -
COLOR_LIST_BACKGROUND
public static final org.eclipse.swt.graphics.Color COLOR_LIST_BACKGROUND -
COLOR_LIST_FOREGROUND
public static final org.eclipse.swt.graphics.Color COLOR_LIST_FOREGROUND -
COLOR_LIST_SELECTION
public static final org.eclipse.swt.graphics.Color COLOR_LIST_SELECTION -
COLOR_LIST_SELECTION_TEXT
public static final org.eclipse.swt.graphics.Color COLOR_LIST_SELECTION_TEXT -
COLOR_WIDGET_BACKGROUND
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_BACKGROUND -
COLOR_WIDGET_FOREGROUND
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_FOREGROUND -
COLOR_TITLE_INACTIVE_BACKGROUND
public static final org.eclipse.swt.graphics.Color COLOR_TITLE_INACTIVE_BACKGROUND -
COLOR_WIDGET_BORDER
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_BORDER -
COLOR_WIDGET_DARK_SHADOW
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_DARK_SHADOW -
COLOR_WIDGET_LIGHT_SHADOW
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_LIGHT_SHADOW -
COLOR_WIDGET_NORMAL_SHADOW
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_NORMAL_SHADOW -
COLOR_WIDGET_HIGHLIGHT_SHADOW
public static final org.eclipse.swt.graphics.Color COLOR_WIDGET_HIGHLIGHT_SHADOW -
DEFAULT_FONT
public static final org.eclipse.swt.graphics.Font DEFAULT_FONT -
DEFAULT_RESIZE_HANDLE_SIZE
public static final int DEFAULT_RESIZE_HANDLE_SIZE- See Also:
-
DEFAULT_MIN_DISPLAY_SIZE
public static final int DEFAULT_MIN_DISPLAY_SIZE- See Also:
-
DEFAULT_ANTIALIAS
public static final int DEFAULT_ANTIALIAS- See Also:
-
DEFAULT_TEXT_ANTIALIAS
public static final int DEFAULT_TEXT_ANTIALIAS- See Also:
-
-
Method Details
-
getColor
public static org.eclipse.swt.graphics.Color getColor(org.eclipse.swt.graphics.RGB rgb) -
getColor
public static org.eclipse.swt.graphics.Color getColor(int red, int green, int blue) -
getColor
-
getFont
public static org.eclipse.swt.graphics.Font getFont(org.eclipse.swt.graphics.FontData... fontDatas) -
getFont
-
getScaledFont
public static org.eclipse.swt.graphics.Font getScaledFont(org.eclipse.swt.graphics.Font font, float fontScalingFactor) Return a scaled version of the configured font if font scaling is needed. If no font scaling is needed, the given font is returned.- Parameters:
font- The font to scale.- Returns:
- The font with the updated height if font scaling is needed, otherwise the given font.
- Since:
- 2.0
-
getImageByURL
This method extracts the base filename out of the givenURLand uses it as key to search for theImagein theImageRegistry. If theImageis not yet present it will create theImageinstance and register it automatically. On creating and registering it will respect dpi scaling.- Parameters:
url- TheURLof the image for initial loading.- Returns:
- The
Imagerepresentation of an image external to NatTable. - See Also:
-
getImageByURL
This method returns theImagethat is registered for the given key. If there is noImageregistered for that key already, it will create and register theImagethat can be loaded by the givenURL.This method returns an
Imagethat matches the dpi settings. If the dpi of an axis is bigger than 96 it will search for an image for the bigger dpi. For this the filenames need to carry the dpi information.For example if you request checkbox.png this method will search for a scaled version relative to the requested image. The following will give an example on the scaled files:
- checkbox.png
- checkbox_120_120.png
- checkbox_128_128.png
- checkbox_144_144.png
- checkbox_192_192.png
- checkbox_288_288.png
If the matching scaled version is not found, it will automatically upscale the base image.
Note: If you want to get the image later again you can directly use
JFaceResources.getImage(key).- Parameters:
key- The key under which the resource is registered in the image registry.url- TheURLof the image for initial loading.- Returns:
- The
Imagerepresentation of an image external to NatTable.
-
getDisplayImageByURL
This method extracts the base filename out of the givenURLand uses it as key to search for theImagein theImageRegistry. If theImageis not yet present it will create theImageinstance and register it automatically. On creating and registering it will respect display dpi scaling.- Parameters:
url- TheURLof the image for initial loading.- Returns:
- The
Imagerepresentation of an image external to NatTable. - Since:
- 2.0
- See Also:
-
getDisplayImageByURL
This method returns theImagethat is registered for the given key. If there is noImageregistered for that key already, it will create and register theImagethat can be loaded by the givenURL.This method returns an
Imagethat matches the display dpi settings. If the dpi of an axis is bigger than 96 it will search for an image for the bigger dpi. For this the filenames need to carry the dpi information.For example if you request checkbox.png this method will search for a scaled version relative to the requested image. The following will give an example on the scaled files:
- checkbox.png
- checkbox_120_120.png
- checkbox_128_128.png
- checkbox_144_144.png
- checkbox_192_192.png
- checkbox_288_288.png
If the matching scaled version is not found, it will automatically upscale the base image.
Note: If you want to get the image later again you can directly use
JFaceResources.getImage(key).- Parameters:
key- The key under which the resource is registered in the image registry.url- TheURLof the image for initial loading.- Returns:
- The
Imagerepresentation of an image external to NatTable. - Since:
- 2.0
-
getImageByURL
public static org.eclipse.swt.graphics.Image getImageByURL(String key, URL url, boolean considerScaling, boolean forDisplayDPI) This method returns theImagethat is registered for the given key. If there is noImageregistered for that key already, it will create and register theImagethat can be loaded by the givenURL.This method returns an
Imagethat matches the dpi settings. If the dpi of an axis is bigger than 96 it will search for an image for the bigger dpi. For this the filenames need to carry the dpi information.For example if you request checkbox.png this method will search for a scaled version relative to the requested image. The following will give an example on the scaled files:
- checkbox.png
- checkbox_120_120.png
- checkbox_128_128.png
- checkbox_144_144.png
- checkbox_192_192.png
- checkbox_288_288.png
If the matching scaled version is not found, it will automatically upscale the base image.
Note: If you want to get the image later again you can directly use
JFaceResources.getImage(key).- Parameters:
key- The key under which the resource is registered in the image registry.url- TheURLof the image for initial loading.considerScaling-trueif image scaling according to the scaling settings should be performed,falseif only the existing file should be considered without scaling.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The
Imagerepresentation of an image external to NatTable. - Since:
- 2.0
-
getImage
Returns theImagerepresentation of a NatTable internal image resource. Will handle scaling if needed.For upscaling this method checks whether there is a upscaled version of the image available, otherwise it will upscale the existing image and store that in the registry for further use.
- Parameters:
imageName- The filename of the image (without extension).- Returns:
- The
Imagerepresentation of the internal NatTable image resource ornullif there is no image found for the given name at the internal image resource location.
-
getDisplayImage
Returns theImagerepresentation of a NatTable internal image resource. Will apply scaling for the current display scaling factor if needed.For upscaling this method checks whether there is a upscaled version of the image available, otherwise it will upscale the existing image and store that in the registry for further use.
- Parameters:
imageName- The filename of the image (without extension).- Returns:
- The
Imagerepresentation of the internal NatTable image resource ornullif there is no image found for the given name at the internal image resource location. - Since:
- 2.0
-
getImage
public static org.eclipse.swt.graphics.Image getImage(String imageName, boolean considerScaling, boolean forDisplayDPI) Returns theImagerepresentation of a NatTable internal image resource.For upscaling this method checks whether there is a upscaled version of the image available, otherwise it will upscale the existing image and store that in the registry for further use.
- Parameters:
imageName- The filename of the image (without extension).considerScaling-trueif image scaling according to the scaling settings should be performed,falseif only the existing file should be considered without scaling.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The
Imagerepresentation of the internal NatTable image resource ornullif there is no image found for the given name at the internal image resource location. - Since:
- 2.0
-
getImageDescriptor
Returns theImageDescriptorfor a NatTable internal image resource.- Parameters:
imageName- The filename of the image (without extension).- Returns:
- The
ImageDescriptorof the internal NatTable image resource ornullif there is no image found for the given name at the internal image resource location.
-
getInternalImageUrl
Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.- Parameters:
imageName- The filename of the image (without extension)- Returns:
- The URL of the internal NatTable image or
nullif there is no image found for the given name at the internal image resource location. - Since:
- 1.5
-
getInternalImageUrl
Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.- Parameters:
imageName- The filename of the image (without extension).needScaling-truein case the scaled version is requested,falseif the original version is requested.- Returns:
- The URL of the internal NatTable image or
nullif there is no image found for the given name at the internal image resource location. - Since:
- 1.5
-
getInternalImageUrl
Searches for the image with the given filename in the NatTable internal image resource folder with file extensions .png and .gif.- Parameters:
imageName- The filename of the image (without extension)needScaling-truein case the scaled version is requested,falseif the original version is requested.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The URL of the internal NatTable image or
nullif there is no image found for the given name at the internal image resource location. - Since:
- 2.0
-
getSequenceNumber
-
blend
public static org.eclipse.swt.graphics.RGB blend(org.eclipse.swt.graphics.RGB val1, org.eclipse.swt.graphics.RGB val2) Blend the two colour values returning a value that is halfway between them.- Parameters:
val1- the first valueval2- the second value- Returns:
- the blended colour
-
getDpiFactor
public static float getDpiFactor(int dpi) Returns the factor for scaling calculations of pixels regarding the DPI.- Parameters:
dpi- The DPI for which the factor is requested.- Returns:
- The factor for dpi scaling calculations.
-
setDpi
public static void setDpi(int x, int y) Set the dpi values that are used for image scaling.- Parameters:
x- The horizontal dots per inch.y- The vertical dots per inch.- Since:
- 2.0
-
needScaling
public static boolean needScaling()- Returns:
trueif either the horizontal or the vertical DPI value is bigger than 96.
-
needScaling
public static boolean needScaling(boolean forDisplay) - Parameters:
forDisplay- if the check should be performed against the display scaling or the configured scaling.- Returns:
trueif either the horizontal or the vertical DPI value is bigger than 96.- Since:
- 2.0
-
getDpiX
public static int getDpiX()- Returns:
- The horizontal dots per inch.
-
getDpiX
public static int getDpiX(boolean displayDPI) Returns the horizontal dots per inch configured locally. If no local dpi configuration is set, it falls back to the display dpi.- Parameters:
displayDPI- If the display dpi should be returned always.- Returns:
- The horizontal dots per inch.
- Since:
- 2.0
-
getDpiY
public static int getDpiY()- Returns:
- The vertical dots per inch.
-
getDpiY
public static int getDpiY(boolean displayDPI) Returns the vertical dots per inch configured locally. If no local dpi configuration is set, it falls back to the display dpi.- Parameters:
displayDPI- If the display dpi should be returned always.- Returns:
- The vertical dots per inch.
- Since:
- 2.0
-
getScalingImageSuffix
- Returns:
- The suffix that is used to mark an image as upscaled image.
-
getScalingImageSuffix
- Parameters:
forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The suffix that is used to mark an image as upscaled image.
- Since:
- 2.0
-
convertHorizontalPixelToDpi
public static int convertHorizontalPixelToDpi(int pixel) Converts the given amount of pixels to a DPI scaled value using the factor for the horizontal DPI value.- Parameters:
pixel- the amount of pixels to convert.- Returns:
- The converted pixels.
-
convertHorizontalPixelToDpi
public static int convertHorizontalPixelToDpi(int pixel, boolean forDisplayDPI) Converts the given amount of pixels to a DPI scaled value using the factor for the horizontal DPI value.- Parameters:
pixel- the amount of pixels to convert.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The converted pixels.
- Since:
- 2.0
-
convertHorizontalDpiToPixel
public static int convertHorizontalDpiToPixel(int dpi) Converts the given DPI scaled value to a pixel value using the factor for the horizontal DPI.- Parameters:
dpi- the DPI value to convert.- Returns:
- The pixel value related to the given DPI
-
convertHorizontalDpiToPixel
public static int convertHorizontalDpiToPixel(int dpi, boolean forDisplayDPI) Converts the given DPI scaled value to a pixel value using the factor for the horizontal DPI.- Parameters:
dpi- the DPI value to convert.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The pixel value related to the given DPI
- Since:
- 2.0
-
convertVerticalPixelToDpi
public static int convertVerticalPixelToDpi(int pixel) Converts the given amount of pixels to a DPI scaled value using the factor for the vertical DPI.- Parameters:
pixel- the amount of pixels to convert.- Returns:
- The converted pixels.
-
convertVerticalPixelToDpi
public static int convertVerticalPixelToDpi(int pixel, boolean forDisplayDPI) Converts the given amount of pixels to a DPI scaled value using the factor for the vertical DPI.- Parameters:
pixel- the amount of pixels to convert.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The converted pixels.
- Since:
- 2.0
-
convertVerticalDpiToPixel
public static int convertVerticalDpiToPixel(int dpi) Converts the given DPI scaled value to a pixel value using the factor for the vertical DPI.- Parameters:
dpi- the DPI value to convert.- Returns:
- The pixel value related to the given DPI
-
convertVerticalDpiToPixel
public static int convertVerticalDpiToPixel(int dpi, boolean forDisplayDPI) Converts the given DPI scaled value to a pixel value using the factor for the vertical DPI.- Parameters:
dpi- the DPI value to convert.forDisplayDPI- Whether the display DPI or the configured DPI should be considered.- Returns:
- The pixel value related to the given DPI
- Since:
- 2.0
-
convertHorizontalPixelToDpi
Default method to convert the given amount of pixels to a horizontal dots per inch value. The conversion is performed on theIDpiConverterregistered viaNatTableConfigAttributes.HORIZONTAL_DPI_CONVERTER. If no converter is registered, a fallback toconvertHorizontalPixelToDpi(int)is used.- Parameters:
pixel- The pixel value to convert to dpi.configRegistry- TheIConfigRegistryto get theIDpiConverter.- Returns:
- The dpi converted value.
- Since:
- 2.0
-
convertHorizontalDpiToPixel
Default method to convert the given amount of horizontal dots per inch to a pixel value. The conversion is performed on theIDpiConverterregistered viaNatTableConfigAttributes.HORIZONTAL_DPI_CONVERTER. If no converter is registered, a fallback toconvertHorizontalDpiToPixel(int)is used.- Parameters:
dpi- The dpi value to convert to pixel.configRegistry- TheIConfigRegistryto get theIDpiConverter.- Returns:
- The converted value.
- Since:
- 2.0
-
convertVerticalPixelToDpi
Default method to convert the given amount of pixels to a vertical dots per inch value. The conversion is performed on theIDpiConverterregistered viaNatTableConfigAttributes.VERTICAL_DPI_CONVERTER. If no converter is registered, a fallback toconvertVerticalPixelToDpi(int)is used.- Parameters:
pixel- The pixel value to convert to dpi.configRegistry- TheIConfigRegistryto get theIDpiConverter.- Returns:
- The dpi converted value.
- Since:
- 2.0
-
convertVerticalDpiToPixel
Default method to convert the given amount of vertical dots per inch to pixel. The conversion is performed on theIDpiConverterregistered viaNatTableConfigAttributes.VERTICAL_DPI_CONVERTER. If no converter is registered, a fallback toconvertVerticalDpiToPixel(int)is used.- Parameters:
dpi- The dpi value to convert to pixel.configRegistry- TheIConfigRegistryto get theIDpiConverter.- Returns:
- The converted value.
- Since:
- 2.0
-