public class SWTResourceManager extends Object
!!! 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.
Modifier and Type | Field and Description |
---|---|
static int |
BOTTOM_LEFT
Style constant for placing decorator image in bottom left corner of base image.
|
static int |
BOTTOM_RIGHT
Style constant for placing decorator image in bottom right corner of base image.
|
protected static int |
LAST_CORNER_KEY
Internal value.
|
static int |
TOP_LEFT
Style constant for placing decorator image in top left corner of base image.
|
static int |
TOP_RIGHT
Style constant for placing decorator image in top right corner of base image.
|
Constructor and Description |
---|
SWTResourceManager() |
Modifier and Type | Method and Description |
---|---|
static Image |
decorateImage(Image baseImage,
Image decorator)
Returns an
Image composed of a base image decorated by another image. |
static Image |
decorateImage(Image baseImage,
Image decorator,
int corner)
Returns an
Image composed of a base image decorated by another image. |
static void |
dispose()
Dispose of cached objects and their underlying OS resources.
|
static void |
disposeColors()
Dispose of all the cached
Color 's. |
static void |
disposeCursors()
Dispose all of the cached cursors.
|
static void |
disposeFonts()
Dispose all of the cached
Font 's. |
static void |
disposeImages()
Dispose all of the cached
Image 's. |
static Font |
getBoldFont(Font baseFont)
Returns a bold version of the given
Font . |
static Color |
getColor(int systemColorID)
Returns the system
Color matching the specific ID. |
static Color |
getColor(int r,
int g,
int b)
Returns a
Color given its red, green and blue component values. |
static Color |
getColor(RGB rgb)
Returns a
Color given its RGB value. |
static Cursor |
getCursor(int id)
Returns the system cursor matching the specific ID.
|
static Font |
getFont(String name,
int height,
int style)
Returns a
Font based on its name, height and style. |
static Font |
getFont(String name,
int size,
int style,
boolean strikeout,
boolean underline)
Returns a
Font based on its name, height and style. |
static Image |
getImage(Class<?> clazz,
String path)
Returns an
Image stored in the file at the specified path relative to the specified class. |
protected static Image |
getImage(InputStream stream)
Returns an
Image encoded by the specified InputStream . |
static Image |
getImage(String path)
Returns an
Image stored in the file at the specified path. |
public static final int TOP_LEFT
public static final int TOP_RIGHT
public static final int BOTTOM_LEFT
public static final int BOTTOM_RIGHT
protected static final int LAST_CORNER_KEY
public static Color getColor(int systemColorID)
Color
matching the specific ID.systemColorID
- the ID value for the colorColor
matching the specific IDpublic static Color getColor(int r, int g, int b)
Color
given its red, green and blue component values.r
- the red component of the colorg
- the green component of the colorb
- the blue component of the colorColor
matching the given red, green and blue component valuespublic static void disposeColors()
Color
's.protected static Image getImage(InputStream stream) throws IOException
Image
encoded by the specified InputStream
.stream
- the InputStream
encoding the image dataImage
encoded by the specified input streamIOException
public static Image getImage(String path)
Image
stored in the file at the specified path.path
- the path to the image fileImage
stored in the file at the specified pathpublic static Image getImage(Class<?> clazz, String path)
Image
stored in the file at the specified path relative to the specified class.public static Image decorateImage(Image baseImage, Image decorator)
Image
composed of a base image decorated by another image.public static Image decorateImage(Image baseImage, Image decorator, int corner)
Image
composed of a base image decorated by another image.public static void disposeImages()
Image
's.public static Font getFont(String name, int height, int style)
Font
based on its name, height and style.name
- the name of the fontheight
- the height of the fontstyle
- the style of the fontFont
The font matching the name, height and stylepublic static Font getFont(String name, int size, int style, boolean strikeout, boolean underline)
Font
based on its name, height and style. Windows-specific strikeout and underline
flags are also supported.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)Font
The font matching the name, height, style, strikeout and underlinepublic static void disposeFonts()
Font
's.public static Cursor getCursor(int id)
id
- int The ID value for the cursorpublic static void disposeCursors()
public static void dispose()
Copyright © 2013 TextGrid. All Rights Reserved.