Atomic Developer Documentation  0.3.0-SNAPSHOT
Developer documentation and API
org.eclipse.wb.swt.SWTResourceManager Class Reference

Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. More...

Static Public Member Functions

static Color getColor (int systemColorID)
 Returns the system Color matching the specific ID. More...
 
static Color getColor (int r, int g, int b)
 Returns a Color given its red, green and blue component values. More...
 
static Color getColor (RGB rgb)
 Returns a Color given its RGB value. More...
 
static void disposeColors ()
 Dispose of all the cached Color's.
 
static Image getImage (String path)
 Returns an Image stored in the file at the specified path. More...
 
static Image getImage (Class<?> clazz, String path)
 Returns an Image stored in the file at the specified path relative to the specified class. More...
 
static Image decorateImage (Image baseImage, Image decorator)
 Returns an Image composed of a base image decorated by another image. More...
 
static Image decorateImage (final Image baseImage, final Image decorator, final int corner)
 Returns an Image composed of a base image decorated by another image. More...
 
static void disposeImages ()
 Dispose all of the cached Image's.
 
static Font getFont (String name, int height, int style)
 Returns a Font based on its name, height and style. More...
 
static Font getFont (String name, int size, int style, boolean strikeout, boolean underline)
 Returns a Font based on its name, height and style. More...
 
static Font getBoldFont (Font baseFont)
 Returns a bold version of the given Font. More...
 
static void disposeFonts ()
 Dispose all of the cached Font's.
 
static Cursor getCursor (int id)
 Returns the system cursor matching the specific ID. More...
 
static void disposeCursors ()
 Dispose all of the cached cursors.
 
static void dispose ()
 Dispose of cached objects and their underlying OS resources. More...
 

Static Public Attributes

static final int TOP_LEFT = 1
 Style constant for placing decorator image in top left corner of base image.
 
static final int TOP_RIGHT = 2
 Style constant for placing decorator image in top right corner of base image.
 
static final int BOTTOM_LEFT = 3
 Style constant for placing decorator image in bottom left corner of base image.
 
static final int BOTTOM_RIGHT = 4
 Style constant for placing decorator image in bottom right corner of base image.
 

Static Protected Member Functions

static Image getImage (InputStream stream) throws IOException
 Returns an Image encoded by the specified InputStream. More...
 

Static Protected Attributes

static final int LAST_CORNER_KEY = 5
 Internal value.
 

Detailed Description

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

Definition at line 43 of file SWTResourceManager.java.

Member Function Documentation

static Image org.eclipse.wb.swt.SWTResourceManager.decorateImage ( Image  baseImage,
Image  decorator 
)
static

Returns an Image composed of a base image decorated by another image.

Parameters
baseImagethe base Image that should be decorated
decoratorthe Image to decorate the base image
Returns
Image The resulting decorated image

Definition at line 219 of file SWTResourceManager.java.

static Image org.eclipse.wb.swt.SWTResourceManager.decorateImage ( final Image  baseImage,
final Image  decorator,
final int  corner 
)
static

Returns an Image composed of a base image decorated by another image.

Parameters
baseImagethe base Image that should be decorated
decoratorthe Image to decorate the base image
cornerthe corner to place decorator image
Returns
the resulting decorated Image

Definition at line 233 of file SWTResourceManager.java.

static void org.eclipse.wb.swt.SWTResourceManager.dispose ( )
static

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).

Definition at line 441 of file SWTResourceManager.java.

static Font org.eclipse.wb.swt.SWTResourceManager.getBoldFont ( Font  baseFont)
static

Returns a bold version of the given Font.

Parameters
baseFontthe Font for which a bold version is desired
Returns
the bold version of the given Font

Definition at line 373 of file SWTResourceManager.java.

static Color org.eclipse.wb.swt.SWTResourceManager.getColor ( int  systemColorID)
static

Returns the system Color matching the specific ID.

Parameters
systemColorIDthe ID value for the color
Returns
the system Color matching the specific ID

Definition at line 57 of file SWTResourceManager.java.

static Color org.eclipse.wb.swt.SWTResourceManager.getColor ( int  r,
int  g,
int  b 
)
static

Returns a Color given its red, green and blue component values.

Parameters
rthe red component of the color
gthe green component of the color
bthe blue component of the color
Returns
the Color matching the given red, green and blue component values

Definition at line 72 of file SWTResourceManager.java.

static Color org.eclipse.wb.swt.SWTResourceManager.getColor ( RGB  rgb)
static

Returns a Color given its RGB value.

Parameters
rgbthe RGB value of the color
Returns
the Color matching the RGB value

Definition at line 82 of file SWTResourceManager.java.

static Cursor org.eclipse.wb.swt.SWTResourceManager.getCursor ( int  id)
static

Returns the system cursor matching the specific ID.

Parameters
idint The ID value for the cursor
Returns
Cursor The system cursor matching the specific ID

Definition at line 414 of file SWTResourceManager.java.

static Font org.eclipse.wb.swt.SWTResourceManager.getFont ( String  name,
int  height,
int  style 
)
static

Returns a Font based on its name, height and style.

Parameters
namethe name of the font
heightthe height of the font
stylethe style of the font
Returns
Font The font matching the name, height and style

Definition at line 321 of file SWTResourceManager.java.

static Font org.eclipse.wb.swt.SWTResourceManager.getFont ( String  name,
int  size,
int  style,
boolean  strikeout,
boolean  underline 
)
static

Returns a Font based on its name, height and style.

Windows-specific strikeout and underline flags are also supported.

Parameters
namethe name of the font
sizethe size of the font
stylethe style of the font
strikeoutthe strikeout flag (warning: Windows only)
underlinethe underline flag (warning: Windows only)
Returns
Font The font matching the name, height, style, strikeout and underline

Definition at line 340 of file SWTResourceManager.java.

static Image org.eclipse.wb.swt.SWTResourceManager.getImage ( InputStream  stream) throws IOException
staticprotected

Returns an Image encoded by the specified InputStream.

Parameters
streamthe InputStream encoding the image data
Returns
the Image encoded by the specified input stream

Definition at line 116 of file SWTResourceManager.java.

static Image org.eclipse.wb.swt.SWTResourceManager.getImage ( String  path)
static

Returns an Image stored in the file at the specified path.

Parameters
paththe path to the image file
Returns
the Image stored in the file at the specified path

Definition at line 135 of file SWTResourceManager.java.

static Image org.eclipse.wb.swt.SWTResourceManager.getImage ( Class<?>  clazz,
String  path 
)
static

Returns an Image stored in the file at the specified path relative to the specified class.

Parameters
clazzthe Class relative to which to find the image
paththe path to the image file, if starts with '/'
Returns
the Image stored in the file at the specified path

Definition at line 157 of file SWTResourceManager.java.