psdi.workflow.util

Class IconHandler

  • java.lang.Object
    • psdi.workflow.util.IconHandler


  • public class IconHandler
    extends java.lang.Object
    This class is used to perform common functions on icons. Icons can be loaded by supplying an identifying string. string is looked up in a properties file and mapped to the defined icon. It is possible to set/get a default icon handler. This allows the icon handler to be installed at startup and then used by any code requiring loading of a standard icon.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected boolean debug
      The debug flag
      protected static IconHandler defaultIconHandler
      The default icon handler - construct one with no resources
      protected java.util.PropertyResourceBundle resources
      The resource bundle for the icon handler
    • Constructor Summary

      Constructors 
      Constructor and Description
      IconHandler()
      Create an icon handler
      IconHandler(java.util.PropertyResourceBundle resources)
      Create an icon handler with a property file which holds the mapping of icon names to resources.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.awt.Cursor buildCursorByName(java.lang.String name, java.awt.Point hotspot)
      Builds a cursor from the named gif image
      static IconHandler getDefaultIconHandler()
      Gets the default icon handler
      javax.swing.Icon getGrayIcon(javax.swing.Icon icon)
      Gets a gray version of an icon.
      protected boolean isDark(int rgb)
      Determines whether an RGB value is dark for graying out an image.
      javax.swing.Icon loadIconById(java.lang.String id)
      This method loads an icon using an identifier.
      javax.swing.Icon loadIconByName(java.lang.String name)
      This method loads an icon from a named resource.
      void setDebug(boolean debug)
      Sets the debug flag
      static void setDefaultIconHandler(IconHandler defaultIconHandler)
      Sets the default icon handler
      void setResources(java.util.PropertyResourceBundle resources)
      Sets the resource bundle
      • Methods inherited from class java.lang.Object

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

      • resources

        protected java.util.PropertyResourceBundle resources
        The resource bundle for the icon handler
      • defaultIconHandler

        protected static IconHandler defaultIconHandler
        The default icon handler - construct one with no resources
      • debug

        protected boolean debug
        The debug flag
    • Constructor Detail

      • IconHandler

        public IconHandler()
        Create an icon handler
      • IconHandler

        public IconHandler(java.util.PropertyResourceBundle resources)
        Create an icon handler with a property file which holds the mapping of icon names to resources.
        Parameters:
        resources - Resource bundle
    • Method Detail

      • loadIconById

        public javax.swing.Icon loadIconById(java.lang.String id)
                                      throws java.io.IOException
        This method loads an icon using an identifier.
        Parameters:
        id - The icon indentifier
        Returns:
        The icon
        Throws:
        java.io.IOException - Thrown by the resource loading code
      • loadIconByName

        public javax.swing.Icon loadIconByName(java.lang.String name)
                                        throws java.io.IOException
        This method loads an icon from a named resource.
        Parameters:
        name - The resource name
        Returns:
        The icon
        Throws:
        java.io.IOException - Thrown by the resource loading code
      • getGrayIcon

        public javax.swing.Icon getGrayIcon(javax.swing.Icon icon)
        Gets a gray version of an icon. This achieved by turning all 'dark' colors into a dark gray , the others into the standard gray background and adding a white pixel below and to the right of a dark pixel if the pixel down and to the right is not also dark. This gives the effect of an incised image.
        Parameters:
        icon - The icon to gray out
        Returns:
        The grayed out icon
      • buildCursorByName

        public java.awt.Cursor buildCursorByName(java.lang.String name,
                                                 java.awt.Point hotspot)
                                          throws java.io.IOException
        Builds a cursor from the named gif image
        Parameters:
        name - The resource name for the image
        hotspot - The cursor hotspot
        Returns:
        the cursor
        Throws:
        java.io.IOException - thrown by the loadImageByName call
      • isDark

        protected boolean isDark(int rgb)
        Determines whether an RGB value is dark for graying out an image. each color must have a value <= 128
        Parameters:
        rgb - The RGB value to test
        Returns:
        True if dark and false otherwise
      • setDefaultIconHandler

        public static void setDefaultIconHandler(IconHandler defaultIconHandler)
        Sets the default icon handler
        Parameters:
        iconHandler - The new default icon handler
      • getDefaultIconHandler

        public static IconHandler getDefaultIconHandler()
        Gets the default icon handler
        Returns:
        The default icon handler
      • setResources

        public void setResources(java.util.PropertyResourceBundle resources)
        Sets the resource bundle
        Parameters:
        resource - The resource bundle
      • setDebug

        public void setDebug(boolean debug)
        Sets the debug flag
        Parameters:
        resource - The resource bundle