Class SWTResourceManager
java.lang.Object
com.openinventor.inventor.viewercomponents.swt.tools.SWTResourceManager
Utility class for managing OS resources associated with SWT controls such as
colors, fonts, images, etc.
!!! IMPORTANT !!! Application code must explicitly invoke the
dispose() method to release the operating system resources
managed by cached objects when those objects and OS resources are no longer
needed (e.g. on application shutdown)
This class may be freely distributed as part of any application or plugin.
- Author:
- scheglov_ke, Dan Rubel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intStyle constant for placing decorator image in bottom left corner of base image.static final intStyle constant for placing decorator image in bottom right corner of base image.static final intStyle constant for placing decorator image in top left corner of base image.static final intStyle constant for placing decorator image in top right corner of base image. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.swt.graphics.ImagedecorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator) Returns anImagecomposed of a base image decorated by another image.static org.eclipse.swt.graphics.ImagedecorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator, int corner) Returns anImagecomposed of a base image decorated by another image.static voiddispose()Dispose of cached objects and their underlying OS resources.static voidDispose of all the cachedColor's.static voidDispose all of the cached cursors.static voidDispose all of the cachedFont's.static voidDispose all of the cachedImage's.static org.eclipse.swt.graphics.FontgetBoldFont(org.eclipse.swt.graphics.Font baseFont) Returns a bold version of the givenFont.static org.eclipse.swt.graphics.ColorgetColor(int systemColorID) Returns the systemColormatching the specific ID.static org.eclipse.swt.graphics.ColorgetColor(int r, int g, int b) Returns aColorgiven its red, green and blue component values.static org.eclipse.swt.graphics.ColorgetColor(org.eclipse.swt.graphics.RGB rgb) Returns aColorgiven its RGB value.static org.eclipse.swt.graphics.CursorgetCursor(int id) Returns the system cursor matching the specific ID.static org.eclipse.swt.graphics.FontReturns aFontbased on its name, height and style.static org.eclipse.swt.graphics.FontReturns aFontbased on its name, height and style.static org.eclipse.swt.graphics.ImageReturns anImagestored in the file at the specified path relative to the specified class.static org.eclipse.swt.graphics.ImageReturns anImagestored in the file at the specified path.
-
Field Details
-
TOP_LEFT
public static final int TOP_LEFTStyle constant for placing decorator image in top left corner of base image.- See Also:
-
TOP_RIGHT
public static final int TOP_RIGHTStyle constant for placing decorator image in top right corner of base image.- See Also:
-
BOTTOM_LEFT
public static final int BOTTOM_LEFTStyle constant for placing decorator image in bottom left corner of base image.- See Also:
-
BOTTOM_RIGHT
public static final int BOTTOM_RIGHTStyle constant for placing decorator image in bottom right corner of base image.- See Also:
-
-
Constructor Details
-
SWTResourceManager
public SWTResourceManager()
-
-
Method Details
-
getColor
public static org.eclipse.swt.graphics.Color getColor(int systemColorID) Returns the systemColormatching the specific ID.- Parameters:
systemColorID- the ID value for the color- Returns:
- the system
Colormatching the specific ID
-
getColor
public static org.eclipse.swt.graphics.Color getColor(int r, int g, int b) Returns aColorgiven its red, green and blue component values.- Parameters:
r- the red component of the colorg- the green component of the colorb- the blue component of the color- Returns:
- the
Colormatching the given red, green and blue component values
-
getColor
public static org.eclipse.swt.graphics.Color getColor(org.eclipse.swt.graphics.RGB rgb) Returns aColorgiven its RGB value.- Parameters:
rgb- theRGBvalue of the color- Returns:
- the
Colormatching the RGB value
-
disposeColors
public static void disposeColors()Dispose of all the cachedColor's. -
getImage
Returns anImagestored in the file at the specified path.- Parameters:
path- the path to the image file- Returns:
- the
Imagestored in the file at the specified path
-
getImage
Returns anImagestored in the file at the specified path relative to the specified class.- Parameters:
clazz- theClassrelative to which to find the imagepath- the path to the image file, if starts with'/'- Returns:
- the
Imagestored in the file at the specified path
-
decorateImage
public static org.eclipse.swt.graphics.Image decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator) Returns anImagecomposed of a base image decorated by another image.- Parameters:
baseImage- the baseImagethat should be decorateddecorator- theImageto decorate the base image- Returns:
ImageThe resulting decorated image
-
decorateImage
public static org.eclipse.swt.graphics.Image decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator, int corner) Returns anImagecomposed of a base image decorated by another image.- Parameters:
baseImage- the baseImagethat should be decorateddecorator- theImageto decorate the base imagecorner- the corner to place decorator image- Returns:
- the resulting decorated
Image
-
disposeImages
public static void disposeImages()Dispose all of the cachedImage's. -
getFont
Returns aFontbased on its name, height and style.- Parameters:
name- the name of the fontheight- the height of the fontstyle- the style of the font- Returns:
FontThe font matching the name, height and style
-
getFont
public static org.eclipse.swt.graphics.Font getFont(String name, int size, int style, boolean strikeout, boolean underline) Returns aFontbased on its name, height and style. Windows-specific strikeout and underline flags are also supported.- Parameters:
name- the name of the fontsize- the size of the fontstyle- the style of the fontstrikeout- the strikeout flag (warning: Windows only)underline- the underline flag (warning: Windows only)- Returns:
FontThe font matching the name, height, style, strikeout and underline
-
getBoldFont
public static org.eclipse.swt.graphics.Font getBoldFont(org.eclipse.swt.graphics.Font baseFont) Returns a bold version of the givenFont.- Parameters:
baseFont- theFontfor which a bold version is desired- Returns:
- the bold version of the given
Font
-
disposeFonts
public static void disposeFonts()Dispose all of the cachedFont's. -
getCursor
public static org.eclipse.swt.graphics.Cursor getCursor(int id) Returns the system cursor matching the specific ID.- Parameters:
id- int The ID value for the cursor- Returns:
- Cursor The system cursor matching the specific ID
-
disposeCursors
public static void disposeCursors()Dispose all of the cached cursors. -
dispose
public static void dispose()Dispose of cached objects and their underlying OS resources. This should only be called when the cached objects are no longer needed (e.g. on application shutdown).
-