Source for gnu.javax.swing.plaf.metal.CustomizableTheme

   1: /* CustomizableTheme.java -- A customizable metal theme
   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 gnu.javax.swing.plaf.metal;
  40: 
  41: import java.awt.Color;
  42: 
  43: import javax.swing.plaf.ColorUIResource;
  44: import javax.swing.plaf.metal.DefaultMetalTheme;
  45: 
  46: /**
  47:  * A Metal theme that can be customized by setting the primary and secondary
  48:  * colors.
  49:  *
  50:  * @author Roman Kennke (kennke@aicas.com)
  51:  */
  52: public class CustomizableTheme
  53:     extends DefaultMetalTheme
  54:     implements Cloneable
  55: {
  56: 
  57:   /**
  58:    * The primary1 color.
  59:    */
  60:   private ColorUIResource primary1;
  61: 
  62:   /**
  63:    * The primary2 color.
  64:    */
  65:   private ColorUIResource primary2;
  66: 
  67:   /**
  68:    * The primary3 color.
  69:    */
  70:   private ColorUIResource primary3;
  71: 
  72:   /**
  73:    * The secondary1 color.
  74:    */
  75:   private ColorUIResource secondary1;
  76: 
  77:   /**
  78:    * The secondary2 color.
  79:    */
  80:   private ColorUIResource secondary2;
  81: 
  82:   /**
  83:    * The secondary3 color.
  84:    */
  85:   private ColorUIResource secondary3;
  86: 
  87:   /**
  88:    * Sets the primary1 color of the theme.
  89:    *
  90:    * @param c the primary1 color to set
  91:    */
  92:   public void setPrimary1(Color c)
  93:   {
  94:     primary1 = new ColorUIResource(c);
  95:   }
  96: 
  97:   /**
  98:    * Returns the primary1 color of this theme.
  99:    *
 100:    * @return the primary1 color of this theme
 101:    */
 102:   public ColorUIResource getPrimary1()
 103:   {
 104:     return primary1 == null ? super.getPrimary1() : primary1;
 105:   }
 106: 
 107: 
 108:   /**
 109:    * Sets the primary2 color of the theme.
 110:    *
 111:    * @param c the primary2 color to set
 112:    */
 113:   public void setPrimary2(Color c)
 114:   {
 115:     primary2 = new ColorUIResource(c);
 116:   }
 117: 
 118:   /**
 119:    * Returns the primary2 color of this theme.
 120:    *
 121:    * @return the primary2 color of this theme
 122:    */
 123:   public ColorUIResource getPrimary2()
 124:   {
 125:     return primary2 == null ? super.getPrimary2() : primary2;
 126:   }
 127: 
 128:   /**
 129:    * Sets the primary3 color of the theme.
 130:    *
 131:    * @param c the primary3 color to set
 132:    */
 133:   public void setPrimary3(Color c)
 134:   {
 135:     primary3 = new ColorUIResource(c);
 136:   }
 137: 
 138:   /**
 139:    * Returns the primary3 color of this theme.
 140:    *
 141:    * @return the primary3 color of this theme
 142:    */
 143:   public ColorUIResource getPrimary3()
 144:   {
 145:     return primary3 == null ? super.getPrimary3() : primary3;
 146:   }
 147: 
 148:   /**
 149:    * Sets the secondary1 color of the theme.
 150:    *
 151:    * @param c the secondary1 color to set
 152:    */
 153:   public void setSecondary1(Color c)
 154:   {
 155:     secondary1 = new ColorUIResource(c);
 156:   }
 157: 
 158:   /**
 159:    * Returns the secondary1 color of this theme.
 160:    *
 161:    * @return the secondary1 color of this theme
 162:    */
 163:   public ColorUIResource getSecondary1()
 164:   {
 165:     return secondary1 == null ? super.getSecondary1() : secondary1;
 166:   }
 167: 
 168:   /**
 169:    * Sets the secondary2 color of the theme.
 170:    *
 171:    * @param c the secondary2 color to set
 172:    */
 173:   public void setSecondary2(Color c)
 174:   {
 175:     secondary2 = new ColorUIResource(c);
 176:   }
 177: 
 178:   /**
 179:    * Returns the secondary2 color of this theme.
 180:    *
 181:    * @return the secondary2 color of this theme
 182:    */
 183:   public ColorUIResource getSecondary2()
 184:   {
 185:     return secondary2 == null ? super.getSecondary2() : secondary2;
 186:   }
 187: 
 188:   /**
 189:    * Sets the secondary3 color of the theme.
 190:    *
 191:    * @param c the secondary3 color to set
 192:    */
 193:   public void setSecondary3(Color c)
 194:   {
 195:     secondary3 = new ColorUIResource(c);
 196:   }
 197: 
 198:   /**
 199:    * Returns the secondary3 color of this theme.
 200:    *
 201:    * @return the secondary3 color of this theme
 202:    */
 203:   public ColorUIResource getSecondary3()
 204:   {
 205:     return secondary3 == null ? super.getSecondary3() : secondary3;
 206:   }
 207: 
 208:   /**
 209:    * Returns a clone of this theme.
 210:    *
 211:    * @return a clone of this theme
 212:    */
 213:   public Object clone()
 214:     throws CloneNotSupportedException
 215:   {
 216:     return super.clone();
 217:   }
 218: }