Class XYGraphMediaFactory
- java.lang.Object
-
- org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory
-
public final class XYGraphMediaFactory extends java.lang.ObjectA factory, which provides convenience methods for the creation of Images and Fonts. All resources created via this factory get automatically disposed, when the application is stopped.- Version:
- $Revision$
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.jface.resource.ColorRegistry_colorRegistryThe color registry.private org.eclipse.jface.resource.FontRegistry_fontRegistryThe font registry.private java.util.HashMap<org.eclipse.jface.resource.ImageDescriptor,org.eclipse.swt.graphics.Image>_imageCacheMap that holds the provided image descriptors.private org.eclipse.jface.resource.ImageRegistry_imageRegistryThe image registry.private static XYGraphMediaFactory_instanceThe shared instance.static org.eclipse.swt.graphics.RGBCOLOR_BLACKthe color for blackstatic org.eclipse.swt.graphics.RGBCOLOR_BLUEthe color for bluestatic org.eclipse.swt.graphics.RGBCOLOR_CYANthe color for cyanstatic org.eclipse.swt.graphics.RGBCOLOR_DARK_GRAYthe color for dark graystatic org.eclipse.swt.graphics.RGBCOLOR_GRAYthe color for graystatic org.eclipse.swt.graphics.RGBCOLOR_GREENthe color for greenstatic org.eclipse.swt.graphics.RGBCOLOR_LIGHT_BLUEthe color for light bluestatic org.eclipse.swt.graphics.RGBCOLOR_ORANGEthe color for orangestatic org.eclipse.swt.graphics.RGBCOLOR_PINKthe color for pinkstatic org.eclipse.swt.graphics.RGBCOLOR_PURPLEthe color for orangestatic org.eclipse.swt.graphics.RGBCOLOR_REDthe color for redstatic org.eclipse.swt.graphics.RGBCOLOR_WHITEthe color for whitestatic org.eclipse.swt.graphics.RGBCOLOR_YELLOWthe color for yellowstatic java.lang.StringCURSOR_GRABBING_ON_AXIS_PATHstatic java.lang.StringCURSOR_GRABBING_PATHprivate java.util.HashMap<java.lang.String,org.eclipse.swt.graphics.Cursor>cursorRegistrystatic org.eclipse.swt.graphics.FontDataFONT_ARIALthe font for Arial in height of 9static org.eclipse.swt.graphics.FontDataFONT_TAHOMAthe font for Tahoma in height of 9
-
Constructor Summary
Constructors Modifier Constructor Description privateXYGraphMediaFactory()Private constructor to avoid instantiation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisposeResources()org.eclipse.swt.graphics.ColorgetColor(int r, int g, int b)Create theColorfor the given color information.org.eclipse.swt.graphics.ColorgetColor(org.eclipse.swt.graphics.RGB rgb)Create theColorfor the givenRGB.org.eclipse.swt.graphics.CursorgetCursor(java.lang.String cursorImagePath)org.eclipse.swt.graphics.FontgetDefaultFont(int style)Return the system's default font.org.eclipse.swt.graphics.FontgetFont(java.lang.String name, int height, int style)Create theFontfor the given information.org.eclipse.swt.graphics.FontgetFont(org.eclipse.swt.graphics.FontData fontData)Create theFontfor the givenFontDataand the given style code.org.eclipse.swt.graphics.FontgetFont(org.eclipse.swt.graphics.FontData[] fontData)Create theFontfor the givenFontData.org.eclipse.swt.graphics.FontgetFont(org.eclipse.swt.graphics.FontData[] fontData, int style)Create theFontfor the givenFontDataand the given style code.org.eclipse.swt.graphics.ImagegetImage(java.lang.String relativePath)Load theImagefrom the given path in the given plugin.static XYGraphMediaFactorygetInstance()Return the shared instance of this class.org.eclipse.swt.graphics.ImagegetRegisteredImage(java.lang.String key)voidregisterCursor(java.lang.String key, org.eclipse.swt.graphics.Cursor cursor)Register the cursor so it can be disposed when the plugin stopped.voidregisterImage(java.lang.String key, org.eclipse.swt.graphics.Image img)Register the image to imageRegistry so it can be disposed when Display disposed.
-
-
-
Field Detail
-
_instance
private static XYGraphMediaFactory _instance
The shared instance.
-
_colorRegistry
private org.eclipse.jface.resource.ColorRegistry _colorRegistry
The color registry.
-
_imageRegistry
private org.eclipse.jface.resource.ImageRegistry _imageRegistry
The image registry.
-
_fontRegistry
private org.eclipse.jface.resource.FontRegistry _fontRegistry
The font registry.
-
cursorRegistry
private java.util.HashMap<java.lang.String,org.eclipse.swt.graphics.Cursor> cursorRegistry
-
_imageCache
private java.util.HashMap<org.eclipse.jface.resource.ImageDescriptor,org.eclipse.swt.graphics.Image> _imageCache
Map that holds the provided image descriptors.
-
CURSOR_GRABBING_PATH
public static final java.lang.String CURSOR_GRABBING_PATH
- See Also:
- Constant Field Values
-
CURSOR_GRABBING_ON_AXIS_PATH
public static final java.lang.String CURSOR_GRABBING_ON_AXIS_PATH
- See Also:
- Constant Field Values
-
COLOR_LIGHT_BLUE
public static final org.eclipse.swt.graphics.RGB COLOR_LIGHT_BLUE
the color for light blue
-
COLOR_BLUE
public static final org.eclipse.swt.graphics.RGB COLOR_BLUE
the color for blue
-
COLOR_WHITE
public static final org.eclipse.swt.graphics.RGB COLOR_WHITE
the color for white
-
COLOR_GRAY
public static final org.eclipse.swt.graphics.RGB COLOR_GRAY
the color for gray
-
COLOR_DARK_GRAY
public static final org.eclipse.swt.graphics.RGB COLOR_DARK_GRAY
the color for dark gray
-
COLOR_BLACK
public static final org.eclipse.swt.graphics.RGB COLOR_BLACK
the color for black
-
COLOR_RED
public static final org.eclipse.swt.graphics.RGB COLOR_RED
the color for red
-
COLOR_GREEN
public static final org.eclipse.swt.graphics.RGB COLOR_GREEN
the color for green
-
COLOR_YELLOW
public static final org.eclipse.swt.graphics.RGB COLOR_YELLOW
the color for yellow
-
COLOR_PINK
public static final org.eclipse.swt.graphics.RGB COLOR_PINK
the color for pink
-
COLOR_CYAN
public static final org.eclipse.swt.graphics.RGB COLOR_CYAN
the color for cyan
-
COLOR_ORANGE
public static final org.eclipse.swt.graphics.RGB COLOR_ORANGE
the color for orange
-
COLOR_PURPLE
public static final org.eclipse.swt.graphics.RGB COLOR_PURPLE
the color for orange
-
FONT_ARIAL
public static final org.eclipse.swt.graphics.FontData FONT_ARIAL
the font for Arial in height of 9
-
FONT_TAHOMA
public static final org.eclipse.swt.graphics.FontData FONT_TAHOMA
the font for Tahoma in height of 9
-
-
Method Detail
-
disposeResources
public void disposeResources()
-
getCursor
public org.eclipse.swt.graphics.Cursor getCursor(java.lang.String cursorImagePath)
-
getInstance
public static XYGraphMediaFactory getInstance()
Return the shared instance of this class.- Returns:
- The shared instance of this class.
-
getColor
public org.eclipse.swt.graphics.Color getColor(int r, int g, int b)Create theColorfor the given color information.- Parameters:
r- redg- greenb- blue- Returns:
- The
Colorfor the given color information.
-
getColor
public org.eclipse.swt.graphics.Color getColor(org.eclipse.swt.graphics.RGB rgb)
Create theColorfor the givenRGB.- Parameters:
rgb- ARGBobject.- Returns:
- The
Colorfor the givenRGB.
-
getFont
public org.eclipse.swt.graphics.Font getFont(java.lang.String name, int height, int style)Create theFontfor the given information.- Parameters:
name- The font name.height- The font height.style- The font style.- Returns:
- The
Fontfor the given information.
-
getFont
public org.eclipse.swt.graphics.Font getFont(org.eclipse.swt.graphics.FontData[] fontData)
Create theFontfor the givenFontData.- Parameters:
fontData- TheFontData- Returns:
- The
Fontfor the givenFontData
-
getFont
public org.eclipse.swt.graphics.Font getFont(org.eclipse.swt.graphics.FontData[] fontData, int style)Create theFontfor the givenFontDataand the given style code.- Parameters:
fontData- TheFontDatastyle- The style code.- Returns:
- The
Fontfor the givenFontDataand the given style code.
-
getFont
public org.eclipse.swt.graphics.Font getFont(org.eclipse.swt.graphics.FontData fontData)
Create theFontfor the givenFontDataand the given style code.- Parameters:
fontData- TheFontData- Returns:
- The
Fontfor the givenFontDataand the given style code.
-
getDefaultFont
public org.eclipse.swt.graphics.Font getDefaultFont(int style)
Return the system's default font.- Parameters:
style- additional styles, e.g. SWT.Bold- Returns:
- The system's default font.
-
registerImage
public void registerImage(java.lang.String key, org.eclipse.swt.graphics.Image img)Register the image to imageRegistry so it can be disposed when Display disposed.- Parameters:
key-img-
-
getRegisteredImage
public org.eclipse.swt.graphics.Image getRegisteredImage(java.lang.String key)
-
getImage
public org.eclipse.swt.graphics.Image getImage(java.lang.String relativePath)
Load theImagefrom the given path in the given plugin. Usually, this is the image found via the the given plug-in relative path. But this implementation also supports a hack for testing: If no plugin is running, because for example this is an SWT-only test, the path is used as is, i.e. relative to the current directory.- Parameters:
relativePath- The image's relative path to the root of the plugin.- Returns:
- The
Imagefrom the given path in the given plugin.
-
registerCursor
public void registerCursor(java.lang.String key, org.eclipse.swt.graphics.Cursor cursor)Register the cursor so it can be disposed when the plugin stopped.- Parameters:
cursor-
-
-