Source for javax.swing.plaf.synth.SynthStyle

   1: /* SynthStyle.java -- A set of style properties
   2:    Copyright (C) 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.swing.plaf.synth;
  40: 
  41: import gnu.classpath.NotImplementedException;
  42: 
  43: import java.awt.Color;
  44: import java.awt.Font;
  45: import java.awt.Insets;
  46: 
  47: import javax.swing.Icon;
  48: 
  49: /**
  50:  * A set of style properties that can be installed on a component.
  51:  *
  52:  * @author Roman Kennke (kennke@aicas.com)
  53:  *
  54:  * @since 1.5
  55:  */
  56: public abstract class SynthStyle
  57: {
  58: 
  59:   /**
  60:    * Creates a new <code>SynthStyle</code> object.
  61:    */
  62:   public SynthStyle()
  63:     throws NotImplementedException
  64:   {
  65:     // FIXME: Implement this correctly.
  66:   }
  67: 
  68:   public SynthGraphicsUtils getGraphicsUtils(SynthContext ctx)
  69:     throws NotImplementedException
  70:   {
  71:     // FIXME: Implement this correctly.
  72:     return null;
  73:   }
  74: 
  75:   public Color getColor(SynthContext ctx, ColorType type)
  76:     throws NotImplementedException
  77:   {
  78:     // FIXME: Implement this correctly.
  79:     return null;
  80:   }
  81: 
  82:   protected abstract Color getColorForState(SynthContext ctx, ColorType type);
  83: 
  84:   public Font getFont(SynthContext ctx)
  85:     throws NotImplementedException
  86:   {
  87:     // FIXME: Implement this correctly.
  88:     return null;
  89:   }
  90: 
  91:   protected abstract Font getFontForState(SynthContext ctx);
  92: 
  93:   public Insets getInsets(SynthContext ctx, Insets result)
  94:     throws NotImplementedException
  95:   {
  96:     // FIXME: Implement this correctly.
  97:     return null;
  98:   }
  99: 
 100:   public SynthPainter getPainter(SynthContext ctx)
 101:     throws NotImplementedException
 102:   {
 103:     // FIXME: Implement this correctly.
 104:     return null;
 105:   }
 106: 
 107:   public boolean isOpaque(SynthContext ctx)
 108:     throws NotImplementedException
 109:   {
 110:     // FIXME: Implement this correctly.
 111:     return true;
 112:   }
 113: 
 114:   public Object get(SynthContext ctx, Object key)
 115:     throws NotImplementedException
 116:   {
 117:     // FIXME: Implement this correctly.
 118:     return null;
 119:   }
 120: 
 121:   public void installDefaults(SynthContext ctx)
 122:     throws NotImplementedException
 123:   {
 124:     // FIXME: Implement this correctly.
 125:   }
 126: 
 127:   public void uninstallDefaults(SynthContext ctx)
 128:     throws NotImplementedException
 129:   {
 130:     // FIXME: Implement this correctly.
 131:   }
 132: 
 133:   /**
 134:    * A convenience method to fetch an integer property.
 135:    * If the property's value is a {@link Number}, then the
 136:    * integer value is returned.  Otherwise, the default value
 137:    * is returned.
 138:    * @param ctx the context
 139:    * @param key the key to fetch
 140:    * @param defaultValue the default value
 141:    * @return the integer value of the property, or the default value
 142:    */
 143:   public int getInt(SynthContext ctx, Object key, int defaultValue)
 144:   {
 145:     Object obj = get(ctx, key);
 146:     if (obj instanceof Number)
 147:       return ((Number) obj).intValue();
 148:     return defaultValue;
 149:   }
 150: 
 151:   /**
 152:    * A convenience method to fetch an integer property.
 153:    * If the property's value is a {@link Boolean}, then the
 154:    * value is returned.  Otherwise, the default value
 155:    * is returned.
 156:    * @param ctx the context
 157:    * @param key the key to fetch
 158:    * @param defaultValue the default value
 159:    * @return the boolean value of the property, or the default value
 160:    */
 161:   public boolean getBoolean(SynthContext ctx, Object key,
 162:                             boolean defaultValue)
 163:   {
 164:     Object obj = get(ctx, key);
 165:     if (obj instanceof Boolean)
 166:       return ((Boolean) obj).booleanValue();
 167:     return defaultValue;
 168:   }
 169: 
 170:   /**
 171:    * A convenience method to fetch an Icon-valued property.
 172:    * If the property's value is an {@link Icon}, then the
 173:    * value is returned.  Otherwise, null is returned.
 174:    * @param ctx the context
 175:    * @param key the key to fetch
 176:    * @return the icon, or null
 177:    */
 178:   public Icon getIcon(SynthContext ctx, Object key)
 179:   {
 180:     Object obj = get(ctx, key);
 181:     if (key instanceof Icon)
 182:       return (Icon) obj;
 183:     return null;
 184:   }
 185: 
 186:   /**
 187:    * A convenience method to fetch a String property.
 188:    * If the property's value is a {@link String}, then the
 189:    * value is returned.  Otherwise, the default value
 190:    * is returned.
 191:    * @param ctx the context
 192:    * @param key the key to fetch
 193:    * @param defaultValue the default value
 194:    * @return the String value of the property, or the default value
 195:    */
 196:   public String getString(SynthContext ctx, Object key, String defaultValue)
 197:   {
 198:     Object obj = get(ctx, key);
 199:     if (obj instanceof String)
 200:       return (String) obj;
 201:     return defaultValue;
 202:   }
 203: }