001    package echopoint.style;
002    
003    import static echopoint.util.ColorKit.makeColor;
004    import nextapp.echo.app.Color;
005    
006    /**
007     * A utility class used to enforce a application wide standard background
008     * colour for components that need a standard background colour.  Note that
009     * this class uses {@link echopoint.util.ColorKit#makeColor(String)} to
010     * initialise the colour.  Please use a format as documented.
011     *
012     * <p>The default colour to use may be specified as a system property or as
013     * a servlet {@code init-param} if using the {@link echopoint.Servlet} in
014     * your application.  The key to use is {@code
015     * echopoint.style.Background.value}.</p>
016     *
017     * @author Rakesh Vidyadharan 2009-05-14
018     * @version $Id: Background.java 208 2009-05-25 02:40:35Z sptrakesh $
019     */
020    public class Background
021    {
022      /** The property used to configure the default colour. */
023      public static final String BACKGROUND_KEY =
024          Background.class.getName() + ".value";
025    
026      /**
027       * The default background value to use if not configured.
028       *
029       * {@value}
030       */
031      public static final String BACKGROUND = "#32476a";
032    
033      /** The default colour value to use. */
034      private static String color;
035    
036      /** Static initialiser to initialise the default colour. */
037      static
038      {
039        color = System.getProperty( BACKGROUND_KEY, BACKGROUND );
040      }
041    
042      /**
043       * Return the default background colour.
044       *
045       * @return The default background colour to use.
046       */
047      public static Color getInstance()
048      {
049        return makeColor( color );
050      }
051    
052      /**
053       * Set the default colour value to use.  Note that this must be set before
054       * the style sheet is loaded to be fully useful.
055       *
056       * @param value The colour value to use.
057       */
058      public static void setBackground( final String value )
059      {
060        color = value;
061      }
062    }