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.awt.Insets;
  42: import java.util.Arrays;
  43: 
  44: import javax.swing.UIDefaults;
  45: import javax.swing.plaf.ColorUIResource;
  46: import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
  47: 
  48: /**
  49:  * A modern theme for the Metal Look & Feel.
  50:  * @since 1.5
  51:  *
  52:  * @author Roman Kennke (roman@kennke.org)
  53:  */
  54: public class OceanTheme extends DefaultMetalTheme
  55: {
  56:   /**
  57:    * The OceanTheme value for black.
  58:    */
  59:   static final ColorUIResource BLACK = new ColorUIResource(51, 51, 51);
  60: 
  61:   /**
  62:    * The OceanTheme value for primary1.
  63:    */
  64:   static final ColorUIResource PRIMARY1 = new ColorUIResource(99, 130, 191);
  65: 
  66:   /**
  67:    * The OceanTheme value for primary1.
  68:    */
  69:   static final ColorUIResource PRIMARY2 = new ColorUIResource(163, 184, 204);
  70: 
  71:   /**
  72:    * The OceanTheme value for primary1.
  73:    */
  74:   static final ColorUIResource PRIMARY3 = new ColorUIResource(184, 207, 229);
  75: 
  76:   /**
  77:    * The OceanTheme value for secondary1.
  78:    */
  79:   static final ColorUIResource SECONDARY1 = new ColorUIResource(122, 138, 153);
  80: 
  81:   /**
  82:    * The OceanTheme value for secondary2.
  83:    */
  84:   static final ColorUIResource SECONDARY2 = new ColorUIResource(184, 207, 229);
  85: 
  86:   /**
  87:    * The OceanTheme value for secondary3.
  88:    */
  89:   static final ColorUIResource SECONDARY3 = new ColorUIResource(238, 238, 238);
  90: 
  91:   /**
  92:    * The OceanTheme value for inactive control text.
  93:    */
  94:   static final ColorUIResource INACTIVE_CONTROL_TEXT =
  95:     new ColorUIResource(153, 153, 153);
  96: 
  97:   /**
  98:    * Returns the name of this theme, "Ocean"
  99:    */
 100:   public String getName()
 101:   {
 102:     return "Ocean";
 103:   }
 104: 
 105:   /**
 106:    * Returns the color for control text, which is the
 107:    * value of the theme's black value.
 108:    */
 109:   public ColorUIResource getControlTextColor()
 110:   {
 111:     return getBlack();
 112:   }
 113: 
 114:   /**
 115:    * Returns the desktop color, which is the theme's white color.
 116:    */
 117:   public ColorUIResource getDesktopColor()
 118:   {
 119:     return getWhite();
 120:   }
 121: 
 122:   /**
 123:    * Returns the color for inactive control text, which is the
 124:    * RGB value (153, 153, 153).
 125:    */
 126:   public ColorUIResource getInactiveControlTextColor()
 127:   {
 128:     return INACTIVE_CONTROL_TEXT;
 129:   }
 130: 
 131:   /**
 132:    * Returns the OceanTheme's color for disabled menu foreground,
 133:    *
 134:    */
 135:   public ColorUIResource getMenuDisabledForeground()
 136:   {
 137:     return INACTIVE_CONTROL_TEXT;
 138:   }
 139: 
 140: 
 141:   /**
 142:    * Returns the OceanTheme's color for black, the RGB value
 143:    * (51, 51, 51).
 144:    *
 145:    * @return Returns the OceanTheme's value for black
 146:    */
 147:   protected ColorUIResource getBlack()
 148:   {
 149:     return BLACK;
 150:   }
 151: 
 152:   /**
 153:    * Return the OceanTheme's value for primary 1, the RGB value
 154:    * (99, 130, 191).
 155:    */
 156:   protected ColorUIResource getPrimary1()
 157:   {
 158:     return PRIMARY1;
 159:   }
 160: 
 161:   /**
 162:    * Return the OceanTheme's value for primary 2, the RGB value
 163:    * (163, 184, 204).
 164:    */
 165:   protected ColorUIResource getPrimary2()
 166:   {
 167:     return PRIMARY2;
 168:   }
 169: 
 170:   /**
 171:    * Return the OceanTheme's value for primary 1, the RGB value
 172:    * (184, 207, 229).
 173:    */
 174:   protected ColorUIResource getPrimary3()
 175:   {
 176:     return PRIMARY3;
 177:   }
 178: 
 179:   /**
 180:    * Return the OceanTheme's value for secondary 1, the RGB value
 181:    * (122, 138, 153).
 182:    */
 183:   protected ColorUIResource getSecondary1()
 184:   {
 185:     return SECONDARY1;
 186:   }
 187: 
 188:   /**
 189:    * Return the OceanTheme's value for secondary 2, the RGB value
 190:    * (184, 207, 229).
 191:    */
 192:   protected ColorUIResource getSecondary2()
 193:   {
 194:     return SECONDARY2;
 195:   }
 196:   /**
 197:    * Return the OceanTheme's value for secondary 3, the RGB value
 198:    * (238, 238, 238).
 199:    */
 200:   protected ColorUIResource getSecondary3()
 201:   {
 202:     return SECONDARY3;
 203:   }
 204: 
 205:   /**
 206:    * Adds customized entries to the UIDefaults table.
 207:    *
 208:    * @param defaults the UI defaults table
 209:    */
 210:   public void addCustomEntriesToTable(UIDefaults defaults)
 211:   {
 212:     // Gradients.
 213:     defaults.put("Button.gradient", Arrays.asList(new Object[]
 214:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 215:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 216:     defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
 217:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 218:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 219:     defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
 220:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 221:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 222:     defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
 223:       {new Float(1.0), new Float(0.0), new ColorUIResource(Color.WHITE),
 224:       new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
 225:     defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
 226:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 227:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 228:     defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
 229:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 230:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 231:     defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
 232:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 233:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 234:     defaults.put("Slider.gradient", Arrays.asList(new Object[]
 235:       {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
 236:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 237:     defaults.put("Slider.focusGradient", Arrays.asList(new Object[]
 238:       {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
 239:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 240:     defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
 241:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 242:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 243:     defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
 244:       {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
 245:        new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
 246: 
 247:     // Colors.
 248:     ColorUIResource c1 = new ColorUIResource(200, 221, 242);
 249:     ColorUIResource c2 = new ColorUIResource(153, 153, 153);
 250:     ColorUIResource c3 = new ColorUIResource(204, 204, 204);
 251:     ColorUIResource c4 = new ColorUIResource(210, 226, 239);
 252:     ColorUIResource c5 = new ColorUIResource(218, 218, 218);
 253:     defaults.put("Button.disabledToolBarBorderBackground", c3);
 254:     defaults.put("Button.toolBarBorderBackground", c2);
 255:     defaults.put("Label.disabledForeground", c2);
 256:     defaults.put("MenuBar.borderColor", c3);
 257:     defaults.put("Slider.altTrackColor", c4);
 258:     defaults.put("SplitPane.dividerFocusColor", c1);
 259:     defaults.put("TabbedPane.contentAreaColor", c1);
 260:     defaults.put("TabbedPane.borderHightlightColor", PRIMARY1);
 261:     defaults.put("TabbedPane.selected", c1);
 262:     defaults.put("TabbedPane.tabAreaBackground", c5);
 263:     defaults.put("TabbedPane.unselectedBackground", SECONDARY3);
 264:     defaults.put("Table.gridColor", SECONDARY1);
 265:     defaults.put("ToolBar.borderColor", c3);
 266:     defaults.put("Tree.selectionBorderColor", PRIMARY1);
 267: 
 268:     // Borders.
 269:     defaults.put("List.focusCellHighlightBorder",
 270:                  new LineBorderUIResource(getPrimary1()));
 271:     defaults.put("Table.focusCellHighlightBorder",
 272:                  new LineBorderUIResource(getPrimary1()));
 273: 
 274:     // Insets.
 275:     defaults.put("TabbedPane.contentBorderInsets", new Insets(4, 2, 3, 3));
 276:     defaults.put("TabbedPane.tabAreaInsets", new Insets(2, 2, 0, 6));
 277: 
 278:     // Flags.
 279:     defaults.put("SplitPane.oneTouchButtonsOpaque", Boolean.FALSE);
 280:     defaults.put("Menu.opaque", Boolean.FALSE);
 281:     defaults.put("ToolBar.isRollover", Boolean.TRUE);
 282:     defaults.put("RadioButton.rollover", Boolean.TRUE);
 283:     defaults.put("CheckBox.rollover", Boolean.TRUE);
 284:     defaults.put("Button.rollover", Boolean.TRUE);
 285: 
 286:     // Icons.
 287:     // FIXME: Add OceanTheme icons.
 288: //    defaults.put("Tree.leafIcon", XXX);
 289: //    defaults.put("Tree.expandedIcon", XXX);
 290: //    defaults.put("Tree.openIcon", XXX);
 291: //    defaults.put("Tree.closedIcon", XXX);
 292: //    defaults.put("Tree.collapsedIcon", XXX);
 293: //    defaults.put("FileChooser.newFolderIcon", XXX);
 294: //    defaults.put("FileChooser.homeFolderIcon", XXX);
 295: //    defaults.put("FileChooser.upFolderIcon", XXX);
 296: //    defaults.put("FileView.hardDriveIcon", XXX);
 297: //    defaults.put("FileView.floppyDriveIcon", XXX);
 298: //    defaults.put("FileView.fileIcon", XXX);
 299: //    defaults.put("FileView.computerIcon", XXX);
 300: //    defaults.put("FileView.directoryIcon", XXX);
 301: //    defaults.put("OptionPane.questionIcon", XXX);
 302: //    defaults.put("OptionPane.errorIcon", XXX);
 303: //    defaults.put("OptionPane.warningIcon", XXX);
 304: //    defaults.put("OptionPane.informationIcon", XXX);
 305: //    defaults.put("InternalFrame.icon", XXX);
 306: //    defaults.put("InternalFrame.closeIcon", XXX);
 307: //    defaults.put("InternalFrame.iconifyIcon", XXX);
 308: //    defaults.put("InternalFrame.minimizeIcon", XXX);
 309: //    defaults.put("InternalFrame.maximizeIcon", XXX);
 310: //    defaults.put("InternalFrame.paletteCloseIcon", XXX);
 311: 
 312:     // UI classes.
 313:     defaults.put("MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI");
 314: 
 315:     // Others.
 316:     defaults.put("Button.rolloverIconType", "ocean");
 317:   }
 318: }