Source for javax.swing.plaf.metal.OceanTheme

   1: /* DefaultMetalTheme.java -- A modern theme for the Metal L&F
   2:    Copyright (C) 2005 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: package javax.swing.plaf.metal;
  39: 
  40: import java.awt.Color;
  41: import java.util.Arrays;
  42: 
  43: import javax.swing.UIDefaults;
  44: import javax.swing.plaf.ColorUIResource;
  45: 
  46: /**
  47:  * A modern theme for the Metal Look & Feel.
  48:  * @since 1.5
  49:  *
  50:  * @author Roman Kennke (roman@kennke.org)
  51:  */
  52: public class OceanTheme extends DefaultMetalTheme
  53: {
  54:   /**
  55:    * The OceanTheme value for black.
  56:    */
  57:   static final ColorUIResource BLACK = new ColorUIResource(51, 51, 51);
  58: 
  59:   /**
  60:    * The OceanTheme value for primary1.
  61:    */
  62:   static final ColorUIResource PRIMARY1 = new ColorUIResource(99, 130, 191);
  63: 
  64:   /**
  65:    * The OceanTheme value for primary1.
  66:    */
  67:   static final ColorUIResource PRIMARY2 = new ColorUIResource(163, 184, 204);
  68: 
  69:   /**
  70:    * The OceanTheme value for primary1.
  71:    */
  72:   static final ColorUIResource PRIMARY3 = new ColorUIResource(184, 207, 229);
  73: 
  74:   /**
  75:    * The OceanTheme value for secondary1.
  76:    */
  77:   static final ColorUIResource SECONDARY1 = new ColorUIResource(122, 138, 153);
  78: 
  79:   /**
  80:    * The OceanTheme value for secondary2.
  81:    */
  82:   static final ColorUIResource SECONDARY2 = new ColorUIResource(184, 207, 229);
  83: 
  84:   /**
  85:    * The OceanTheme value for secondary3.
  86:    */
  87:   static final ColorUIResource SECONDARY3 = new ColorUIResource(238, 238, 238);
  88: 
  89:   /**
  90:    * The OceanTheme value for inactive control text.
  91:    */
  92:   static final ColorUIResource INACTIVE_CONTROL_TEXT =
  93:     new ColorUIResource(153, 153, 153);
  94: 
  95:   /**
  96:    * Returns the name of this theme, "Ocean"
  97:    */
  98:   public String getName()
  99:   {
 100:     return "Ocean";
 101:   }
 102: 
 103:   /**
 104:    * Returns the color for control text, which is the
 105:    * value of the theme's black value.
 106:    */
 107:   public ColorUIResource getControlTextColor()
 108:   {
 109:     return getBlack();
 110:   }
 111: 
 112:   /**
 113:    * Returns the desktop color, which is the theme's white color.
 114:    */
 115:   public ColorUIResource getDesktopColor()
 116:   {
 117:     return getWhite();
 118:   }
 119: 
 120:   /**
 121:    * Returns the color for inactive control text, which is the
 122:    * RGB value (153, 153, 153).
 123:    */
 124:   public ColorUIResource getInactiveControlTextColor()
 125:   {
 126:     return INACTIVE_CONTROL_TEXT;
 127:   }
 128: 
 129:   /**
 130:    * Returns the OceanTheme's color for disabled menu foreground,
 131:    * 
 132:    */
 133:   public ColorUIResource getMenuDisabledForeground()
 134:   {
 135:     return INACTIVE_CONTROL_TEXT;
 136:   }
 137: 
 138:   
 139:   /**
 140:    * Returns the OceanTheme's color for black, the RGB value
 141:    * (51, 51, 51).
 142:    *
 143:    * @return Returns the OceanTheme's value for black 
 144:    */
 145:   protected ColorUIResource getBlack()
 146:   {
 147:     return BLACK;
 148:   }
 149: 
 150:   /**
 151:    * Return the OceanTheme's value for primary 1, the RGB value
 152:    * (99, 130, 191).
 153:    */
 154:   protected ColorUIResource getPrimary1()
 155:   {
 156:     return PRIMARY1;
 157:   }
 158:   
 159:   /**
 160:    * Return the OceanTheme's value for primary 2, the RGB value
 161:    * (163, 184, 204).
 162:    */
 163:   protected ColorUIResource getPrimary2()
 164:   {
 165:     return PRIMARY2;
 166:   }
 167:   
 168:   /**
 169:    * Return the OceanTheme's value for primary 1, the RGB value
 170:    * (184, 207, 229).
 171:    */
 172:   protected ColorUIResource getPrimary3()
 173:   {
 174:     return PRIMARY3;
 175:   }
 176: 
 177:   /**
 178:    * Return the OceanTheme's value for secondary 1, the RGB value
 179:    * (122, 138, 153).
 180:    */
 181:   protected ColorUIResource getSecondary1()
 182:   {
 183:     return SECONDARY1;
 184:   }
 185: 
 186:   /**
 187:    * Return the OceanTheme's value for secondary 2, the RGB value
 188:    * (184, 207, 229).
 189:    */
 190:   protected ColorUIResource getSecondary2()
 191:   {
 192:     return SECONDARY2;
 193:   }
 194:   /**
 195:    * Return the OceanTheme's value for secondary 3, the RGB value
 196:    * (238, 238, 238).
 197:    */
 198:   protected ColorUIResource getSecondary3()
 199:   {
 200:     return SECONDARY3;
 201:   }
 202: 
 203:   /**
 204:    * Adds customized entries to the UIDefaults table.
 205:    *
 206:    * @param defaults the UI defaults table
 207:    */
 208:   public void addCustomEntriesToTable(UIDefaults defaults)
 209:   {
 210:     defaults.put("Button.gradient", Arrays.asList(new Object[]
 211:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 212:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 213:     defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
 214:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 215:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 216:     defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
 217:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 218:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 219:     defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
 220:       {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
 221:       new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
 222:     defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
 223:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 224:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 225:     defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
 226:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 227:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 228:     defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
 229:       {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
 230:        new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
 231:     defaults.put("Slider.gradient", Arrays.asList(new Object[]
 232:       {new Double(0.3), new Double(0.2), new ColorUIResource(200, 221, 242),
 233:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 234:     defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
 235:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 236:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 237:     defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
 238:       {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
 239:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 240: 
 241:     
 242:     defaults.put("Button.rollover", Boolean.TRUE);
 243: 
 244:     defaults.put("TabbedPane.selected", new ColorUIResource(200, 221, 242));
 245:     defaults.put("TabbedPane.unselectedBackground", SECONDARY3);
 246:   }
 247: }