Class XYGraphMediaFactory


  • public final class XYGraphMediaFactory
    extends java.lang.Object
    A 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 _colorRegistry
      The color registry.
      private org.eclipse.jface.resource.FontRegistry _fontRegistry
      The font registry.
      private java.util.HashMap<org.eclipse.jface.resource.ImageDescriptor,​org.eclipse.swt.graphics.Image> _imageCache
      Map that holds the provided image descriptors.
      private org.eclipse.jface.resource.ImageRegistry _imageRegistry
      The image registry.
      private static XYGraphMediaFactory _instance
      The shared instance.
      static org.eclipse.swt.graphics.RGB COLOR_BLACK
      the color for black
      static org.eclipse.swt.graphics.RGB COLOR_BLUE
      the color for blue
      static org.eclipse.swt.graphics.RGB COLOR_CYAN
      the color for cyan
      static org.eclipse.swt.graphics.RGB COLOR_DARK_GRAY
      the color for dark gray
      static org.eclipse.swt.graphics.RGB COLOR_GRAY
      the color for gray
      static org.eclipse.swt.graphics.RGB COLOR_GREEN
      the color for green
      static org.eclipse.swt.graphics.RGB COLOR_LIGHT_BLUE
      the color for light blue
      static org.eclipse.swt.graphics.RGB COLOR_ORANGE
      the color for orange
      static org.eclipse.swt.graphics.RGB COLOR_PINK
      the color for pink
      static org.eclipse.swt.graphics.RGB COLOR_PURPLE
      the color for orange
      static org.eclipse.swt.graphics.RGB COLOR_RED
      the color for red
      static org.eclipse.swt.graphics.RGB COLOR_WHITE
      the color for white
      static org.eclipse.swt.graphics.RGB COLOR_YELLOW
      the color for yellow
      static java.lang.String CURSOR_GRABBING_ON_AXIS_PATH  
      static java.lang.String CURSOR_GRABBING_PATH  
      private java.util.HashMap<java.lang.String,​org.eclipse.swt.graphics.Cursor> cursorRegistry  
      static org.eclipse.swt.graphics.FontData FONT_ARIAL
      the font for Arial in height of 9
      static org.eclipse.swt.graphics.FontData FONT_TAHOMA
      the font for Tahoma in height of 9
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XYGraphMediaFactory()
      Private constructor to avoid instantiation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void disposeResources()  
      org.eclipse.swt.graphics.Color getColor​(int r, int g, int b)
      Create the Color for the given color information.
      org.eclipse.swt.graphics.Color getColor​(org.eclipse.swt.graphics.RGB rgb)
      Create the Color for the given RGB.
      org.eclipse.swt.graphics.Cursor getCursor​(java.lang.String cursorImagePath)  
      org.eclipse.swt.graphics.Font getDefaultFont​(int style)
      Return the system's default font.
      org.eclipse.swt.graphics.Font getFont​(java.lang.String name, int height, int style)
      Create the Font for the given information.
      org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.FontData fontData)
      Create the Font for the given FontData and the given style code.
      org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.FontData[] fontData)
      Create the Font for the given FontData.
      org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.FontData[] fontData, int style)
      Create the Font for the given FontData and the given style code.
      org.eclipse.swt.graphics.Image getImage​(java.lang.String relativePath)
      Load the Image from the given path in the given plugin.
      static XYGraphMediaFactory getInstance()
      Return the shared instance of this class.
      org.eclipse.swt.graphics.Image getRegisteredImage​(java.lang.String key)  
      void registerCursor​(java.lang.String key, org.eclipse.swt.graphics.Cursor cursor)
      Register the cursor so it can be disposed when the plugin stopped.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _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
    • Constructor Detail

      • XYGraphMediaFactory

        private XYGraphMediaFactory()
        Private constructor to avoid instantiation.
    • 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 the Color for the given color information.
        Parameters:
        r - red
        g - green
        b - blue
        Returns:
        The Color for the given color information.
      • getColor

        public org.eclipse.swt.graphics.Color getColor​(org.eclipse.swt.graphics.RGB rgb)
        Create the Color for the given RGB.
        Parameters:
        rgb - A RGB object.
        Returns:
        The Color for the given RGB.
      • getFont

        public org.eclipse.swt.graphics.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 org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.FontData[] fontData)
        Create the Font for the given FontData.
        Parameters:
        fontData - The FontData
        Returns:
        The Font for the given FontData
      • getFont

        public org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.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 org.eclipse.swt.graphics.Font getFont​(org.eclipse.swt.graphics.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 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 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:
        relativePath - The image's relative path to the root of the plugin.
        Returns:
        The Image from 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 -