org.csstudio.ui.util
Class CustomMediaFactory

java.lang.Object
  extended by org.csstudio.ui.util.CustomMediaFactory

public final class CustomMediaFactory
extends java.lang.Object

A factory, which provides convinience methods for the creation of Images and Fonts. All resources created via this factory get automatically disposed, when the application is stopped.

Version:
$Revision$
Author:
Sven Wende

Field Summary
static RGB COLOR_BLACK
          the color for black
static RGB COLOR_BLUE
          the color for blue
static RGB COLOR_CYAN
          the color for cyan
static RGB COLOR_DARK_GRAY
          the color for dark gray
static RGB COLOR_GRAY
          the color for gray
static RGB COLOR_GREEN
          the color for green
static RGB COLOR_LIGHT_BLUE
          the color for light blue
static RGB COLOR_ORANGE
          the color for orange
static RGB COLOR_PINK
          the color for pink
static RGB COLOR_PURPLE
          the color for orange
static RGB COLOR_RED
          the color for red
static RGB COLOR_WHITE
          the color for white
static RGB COLOR_YELLOW
          the color for yellow
static FontData FONT_ARIAL
          the font for Arial in height of 9
static FontData FONT_TAHOMA
          the font for Tahoma in height of 9
 
Method Summary
 Color getColor(int r, int g, int b)
          Create the Color for the given color information.
 Color getColor(RGB rgb)
          Create the Color for the given RGB.
 Font getDefaultFont(int style)
          Return the system's default font.
 Font getFont(FontData fontData)
          Create the Font for the given FontData and the given style code.
 Font getFont(FontData[] fontData)
          Create the Font for the given FontData.
 Font getFont(FontData[] fontData, int style)
          Create the Font for the given FontData and the given style code.
 Font getFont(java.lang.String name, int height, int style)
          Create the Font for the given information.
 ImageDescriptor getImageDescriptorFromPlugin(java.lang.String pluginId, java.lang.String relativePath)
          Load the ImageDescriptor from the given path in the given plugin.
 Image getImageFromPlugin(Plugin plugin, java.lang.String pluginId, java.lang.String relativePath)
          Load the Image from the given path in the given plugin.
 Image getImageFromPlugin(java.lang.String pluginId, java.lang.String relativePath)
          Load the Image from the given path in the given plugin.
static CustomMediaFactory getInstance()
          Return the shared instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR_LIGHT_BLUE

public static final RGB COLOR_LIGHT_BLUE
the color for light blue


COLOR_BLUE

public static final RGB COLOR_BLUE
the color for blue


COLOR_WHITE

public static final RGB COLOR_WHITE
the color for white


COLOR_GRAY

public static final RGB COLOR_GRAY
the color for gray


COLOR_DARK_GRAY

public static final RGB COLOR_DARK_GRAY
the color for dark gray


COLOR_BLACK

public static final RGB COLOR_BLACK
the color for black


COLOR_RED

public static final RGB COLOR_RED
the color for red


COLOR_GREEN

public static final RGB COLOR_GREEN
the color for green


COLOR_YELLOW

public static final RGB COLOR_YELLOW
the color for yellow


COLOR_PINK

public static final RGB COLOR_PINK
the color for pink


COLOR_CYAN

public static final RGB COLOR_CYAN
the color for cyan


COLOR_ORANGE

public static final RGB COLOR_ORANGE
the color for orange


COLOR_PURPLE

public static final RGB COLOR_PURPLE
the color for orange


FONT_ARIAL

public static final FontData FONT_ARIAL
the font for Arial in height of 9


FONT_TAHOMA

public static final FontData FONT_TAHOMA
the font for Tahoma in height of 9

Method Detail

getInstance

public static CustomMediaFactory getInstance()
Return the shared instance of this class.

Returns:
The shared instance of this class.

getColor

public Color getColor(int r,
                      int g,
                      int b)
Create the Color for the given color information.

Parameters:
r - red
g - green
b - blue
Returns:
The Color for the given color information.

getColor

public Color getColor(RGB rgb)
Create the Color for the given RGB.

Parameters:
rgb - A RGB object.
Returns:
The Color for the given RGB.

getFont

public Font getFont(java.lang.String name,
                    int height,
                    int style)
Create the Font for the given information.

Parameters:
name - The font name.
height - The font height.
style - The font style.
Returns:
The Font for the given information.

getFont

public Font getFont(FontData[] fontData)
Create the Font for the given FontData.

Parameters:
fontData - The FontData
Returns:
The Font for the given FontData

getFont

public Font getFont(FontData[] fontData,
                    int style)
Create the Font for the given FontData and the given style code.

Parameters:
fontData - The FontData
style - The style code.
Returns:
The Font for the given FontData and the given style code.

getFont

public Font getFont(FontData fontData)
Create the Font for the given FontData and the given style code.

Parameters:
fontData - The FontData
Returns:
The Font for the given FontData and the given style code.

getDefaultFont

public Font getDefaultFont(int style)
Return the system's default font.

Parameters:
style - additional styles, e.g. SWT.Bold
Returns:
The system's default font.

getImageFromPlugin

public Image getImageFromPlugin(java.lang.String pluginId,
                                java.lang.String relativePath)
Load the Image from the given path in the given plugin.

Parameters:
pluginId - The id of the plugin that contains the requested image.
relativePath - The resource path of the requested image.
Returns:
The Image from the given path in the given plugin.

getImageFromPlugin

public Image getImageFromPlugin(Plugin plugin,
                                java.lang.String pluginId,
                                java.lang.String relativePath)
Load the Image from 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:
plugin - The plugin that contains the requested image.
pluginId - The id of the plugin.
relativePath - The image's relative path to the root of the plugin.
Returns:
The Image from the given path in the given plugin.

getImageDescriptorFromPlugin

public ImageDescriptor getImageDescriptorFromPlugin(java.lang.String pluginId,
                                                    java.lang.String relativePath)
Load the ImageDescriptor from the given path in the given plugin.

Parameters:
pluginId - The id of the plugin that contains the requested image.
relativePath - The resource path of the requested image.
Returns:
The ImageDescriptor from the given path in the given plugin.