001    package com.sptci.echo2.style;
002    
003    import java.util.logging.Logger;
004    
005    import nextapp.echo2.app.Insets;
006    import nextapp.echo2.app.MutableStyle;
007    
008    import nextapp.echo2.app.layout.CellLayoutData;
009    import nextapp.echo2.app.layout.ColumnLayoutData;
010    import nextapp.echo2.app.layout.GridLayoutData;
011    
012    /**
013     * A sub-class of MutableStyle that will be the root for all style classes
014     *
015     * <p>Copyright 2006 Sans Pareil Technologies, Inc.</p>
016     * @author Rakesh Vidyadharan 2006-11-06
017     * @version $Id: Style.java 3334 2007-06-08 16:25:49Z rakesh $
018     */
019    public abstract class Style extends MutableStyle
020    {
021      /**
022       * The logger to use to log messages.
023       */
024      private static final Logger logger = 
025        Logger.getLogger( Style.class.getName() );
026    
027      /**
028       * Default constructor.  Over-ridden to invoke {@link #init}.
029       */
030      public Style()
031      {
032        super();
033        init();
034      }
035    
036      /**
037       * Mandatory style initialisation method to be implemented by all
038       * sub-classes.
039       */
040      abstract protected void init();
041    
042      /**
043       * Over-ridden to log missing property requests.
044       *
045       * @param name The name of the property to use to retrieve style.
046       * @return Object The appropriate instance of Style.
047       */
048      @Override
049      public Object getProperty( String name )
050      {
051        Object object = super.getProperty( name );
052        if ( object == null )
053        {
054          logger.fine( "No style class defined with name " + name );
055        }
056    
057        return object;
058      }
059    
060      /**
061       * Return a default grid layout data object.
062       *
063       * @return GridLayoutData The layout data object with default 
064       *   configuration.
065       */
066      public static final GridLayoutData getGridLayoutData()
067      {
068        GridLayoutData layoutData = new GridLayoutData();
069        setInsets( layoutData );
070        return layoutData;
071      }
072    
073      /**
074       * Return a default grid layout data object.
075       *
076       * @return ColumnLayoutData The layout data object with default 
077       *   configuration.
078       */
079      public static final ColumnLayoutData getColumnLayoutData()
080      {
081        ColumnLayoutData layoutData = new ColumnLayoutData();
082        setInsets( layoutData );
083        return layoutData;
084      }
085    
086      /**
087       * Set the insets for the layout data to default values.
088       *
089       * @param layoutData The layout data for which insets are to be set.
090       */
091      private static void setInsets( CellLayoutData layoutData )
092      {
093        layoutData.setInsets( new Insets( 
094              Extent.getInstance( 5, Extent.PX ),
095              Extent.getInstance( 5, Extent.PX ),
096              Extent.getInstance( 5, Extent.PX ),
097              Extent.getInstance( 5, Extent.PX ) ) );
098      }
099    }