001 package echopoint.style;
002
003 import static echopoint.InfoWindow.*;
004 import static echopoint.util.ColorKit.makeColor;
005 import static nextapp.echo.app.Alignment.ALIGN_LEFT;
006 import nextapp.echo.app.Extent;
007 import nextapp.echo.app.Insets;
008
009 /**
010 * A default style class for {@link echopoint.InfoWindow} components.
011 * Over-ride the {@link #init} method or the individual style configuration
012 * methods as appropriate.
013 *
014 * @author Rakesh Vidyadharan 2009-05-14
015 * @version $Id: InfoWindowStyle.java 248 2009-10-19 14:20:53Z sptrakesh $
016 */
017 public class InfoWindowStyle extends AbstractStyle
018 {
019 private static final long serialVersionUID = 1L;
020
021 /**
022 * The default background to use for info window components.
023 *
024 * {@value}
025 */
026 public static final String BACKGROUND = "#f9f9f9";
027
028 /**
029 * The default foreground colour to use for the component.
030 *
031 * {@value}
032 */
033 public static final String FOREGROUND = "#a10202";
034
035 /**
036 * The default text background to use for info window components.
037 *
038 * {@value}
039 */
040 public static final String TEXT_BACKGROUND = "#cfdfff";
041
042 /**
043 * The text foreground colour to use for the component.
044 *
045 * {@value}
046 */
047 public static final String TEXT_FOREGROUND = "#2f2f4f";
048
049 /**
050 * The text foreground colour to use for the title bar.
051 *
052 * {@value}
053 */
054 public static final String TITLE_FOREGROUND = "#ffffff";
055
056 /**
057 * Sub-classes may over-ride this method, or the individual styling methods
058 * depending upon which approach is more convenient.
059 *
060 * @see #setProperties()
061 * @see #setTextProperties()
062 * @see #setOtherTextProperties()
063 * @see #setTitleProperties()
064 */
065 protected void init()
066 {
067 super.init();
068
069 setProperties();
070 setTextProperties();
071 setOtherTextProperties();
072 setTitleProperties();
073 }
074
075 /** Set general style properties for the content in info window itself. */
076 protected void setProperties()
077 {
078 set( PROPERTY_BACKGROUND, makeColor( BACKGROUND ) );
079 set( PROPERTY_FOREGROUND, makeColor( FOREGROUND ) );
080 set( PROPERTY_INSETS, new Insets( new Extent( 10 ) ) );
081 set( PROPERTY_WIDTH, new Insets( new Extent( 250 ) ) );
082 }
083
084 /** Set the style properties for the text that drives the info window. */
085 protected void setTextProperties()
086 {
087 set( PROPERTY_TEXT_BACKGROUND, makeColor( TEXT_BACKGROUND ) );
088 set( PROPERTY_TEXT_FONT, DefaultFont.fontWithStyle( "BOLD" ) );
089 set( PROPERTY_TEXT_FOREGROUND, makeColor( TEXT_FOREGROUND ) );
090 set( PROPERTY_TEXT_INSETS,
091 new Insets( new Extent( 3 ), new Extent( 8 ) ) );
092 }
093
094 /** Set the style properties for the text that is displayed in the component. */
095 protected void setOtherTextProperties()
096 {
097 set( PROPERTY_OTHER_TEXT_FOREGROUND, makeColor( "#000000" ) );
098 set( PROPERTY_OTHER_TEXT_INSETS,
099 new Insets( new Extent( 2 ), new Extent( 5 ) ) );
100 }
101
102 /** Set the style properties for title of the info window. */
103 protected void setTitleProperties()
104 {
105 set( PROPERTY_TITLE_ALIGNMENT, ALIGN_LEFT );
106 set( PROPERTY_TITLE_BACKGROUND, Background.getInstance() );
107 set( PROPERTY_TITLE_FONT, DefaultFont.getInstance( "BOLD", "12px" ) );
108 set( PROPERTY_TITLE_FOREGROUND, makeColor( TITLE_FOREGROUND ) );
109 }
110 }