001 /* DefaultMetalTheme.java -- A modern theme for the Metal L&F 002 Copyright (C) 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 package javax.swing.plaf.metal; 039 040 import java.awt.Color; 041 import java.awt.Insets; 042 import java.util.Arrays; 043 044 import javax.swing.UIDefaults; 045 import javax.swing.plaf.ColorUIResource; 046 import javax.swing.plaf.BorderUIResource.LineBorderUIResource; 047 048 /** 049 * A modern theme for the Metal Look & Feel. 050 * @since 1.5 051 * 052 * @author Roman Kennke (roman@kennke.org) 053 */ 054 public class OceanTheme extends DefaultMetalTheme 055 { 056 /** 057 * The OceanTheme value for black. 058 */ 059 static final ColorUIResource BLACK = new ColorUIResource(51, 51, 51); 060 061 /** 062 * The OceanTheme value for primary1. 063 */ 064 static final ColorUIResource PRIMARY1 = new ColorUIResource(99, 130, 191); 065 066 /** 067 * The OceanTheme value for primary1. 068 */ 069 static final ColorUIResource PRIMARY2 = new ColorUIResource(163, 184, 204); 070 071 /** 072 * The OceanTheme value for primary1. 073 */ 074 static final ColorUIResource PRIMARY3 = new ColorUIResource(184, 207, 229); 075 076 /** 077 * The OceanTheme value for secondary1. 078 */ 079 static final ColorUIResource SECONDARY1 = new ColorUIResource(122, 138, 153); 080 081 /** 082 * The OceanTheme value for secondary2. 083 */ 084 static final ColorUIResource SECONDARY2 = new ColorUIResource(184, 207, 229); 085 086 /** 087 * The OceanTheme value for secondary3. 088 */ 089 static final ColorUIResource SECONDARY3 = new ColorUIResource(238, 238, 238); 090 091 /** 092 * The OceanTheme value for inactive control text. 093 */ 094 static final ColorUIResource INACTIVE_CONTROL_TEXT = 095 new ColorUIResource(153, 153, 153); 096 097 /** 098 * Returns the name of this theme, "Ocean" 099 */ 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 }