summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
blob: 6a6a3f5aae72e1c6718d849686e648b21ab62ca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* DefaultMetalTheme.java -- A modern theme for the Metal L&F
   Copyright (C) 2005 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package javax.swing.plaf.metal;

import java.awt.Color;
import java.awt.Insets;
import java.util.Arrays;

import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.BorderUIResource.LineBorderUIResource;

/**
 * A modern theme for the Metal Look & Feel.
 * @since 1.5
 *
 * @author Roman Kennke (roman@kennke.org)
 */
public class OceanTheme extends DefaultMetalTheme
{
  /**
   * The OceanTheme value for black.
   */
  static final ColorUIResource BLACK = new ColorUIResource(51, 51, 51);

  /**
   * The OceanTheme value for primary1.
   */
  static final ColorUIResource PRIMARY1 = new ColorUIResource(99, 130, 191);

  /**
   * The OceanTheme value for primary1.
   */
  static final ColorUIResource PRIMARY2 = new ColorUIResource(163, 184, 204);

  /**
   * The OceanTheme value for primary1.
   */
  static final ColorUIResource PRIMARY3 = new ColorUIResource(184, 207, 229);

  /**
   * The OceanTheme value for secondary1.
   */
  static final ColorUIResource SECONDARY1 = new ColorUIResource(122, 138, 153);

  /**
   * The OceanTheme value for secondary2.
   */
  static final ColorUIResource SECONDARY2 = new ColorUIResource(184, 207, 229);

  /**
   * The OceanTheme value for secondary3.
   */
  static final ColorUIResource SECONDARY3 = new ColorUIResource(238, 238, 238);

  /**
   * The OceanTheme value for inactive control text.
   */
  static final ColorUIResource INACTIVE_CONTROL_TEXT =
    new ColorUIResource(153, 153, 153);

  /**
   * Returns the name of this theme, "Ocean"
   */
  public String getName()
  {
    return "Ocean";
  }

  /**
   * Returns the color for control text, which is the
   * value of the theme's black value.
   */
  public ColorUIResource getControlTextColor()
  {
    return getBlack();
  }

  /**
   * Returns the desktop color, which is the theme's white color.
   */
  public ColorUIResource getDesktopColor()
  {
    return getWhite();
  }

  /**
   * Returns the color for inactive control text, which is the
   * RGB value (153, 153, 153).
   */
  public ColorUIResource getInactiveControlTextColor()
  {
    return INACTIVE_CONTROL_TEXT;
  }

  /**
   * Returns the OceanTheme's color for disabled menu foreground,
   *
   */
  public ColorUIResource getMenuDisabledForeground()
  {
    return INACTIVE_CONTROL_TEXT;
  }


  /**
   * Returns the OceanTheme's color for black, the RGB value
   * (51, 51, 51).
   *
   * @return Returns the OceanTheme's value for black
   */
  protected ColorUIResource getBlack()
  {
    return BLACK;
  }

  /**
   * Return the OceanTheme's value for primary 1, the RGB value
   * (99, 130, 191).
   */
  protected ColorUIResource getPrimary1()
  {
    return PRIMARY1;
  }

  /**
   * Return the OceanTheme's value for primary 2, the RGB value
   * (163, 184, 204).
   */
  protected ColorUIResource getPrimary2()
  {
    return PRIMARY2;
  }

  /**
   * Return the OceanTheme's value for primary 1, the RGB value
   * (184, 207, 229).
   */
  protected ColorUIResource getPrimary3()
  {
    return PRIMARY3;
  }

  /**
   * Return the OceanTheme's value for secondary 1, the RGB value
   * (122, 138, 153).
   */
  protected ColorUIResource getSecondary1()
  {
    return SECONDARY1;
  }

  /**
   * Return the OceanTheme's value for secondary 2, the RGB value
   * (184, 207, 229).
   */
  protected ColorUIResource getSecondary2()
  {
    return SECONDARY2;
  }
  /**
   * Return the OceanTheme's value for secondary 3, the RGB value
   * (238, 238, 238).
   */
  protected ColorUIResource getSecondary3()
  {
    return SECONDARY3;
  }

  /**
   * Adds customized entries to the UIDefaults table.
   *
   * @param defaults the UI defaults table
   */
  public void addCustomEntriesToTable(UIDefaults defaults)
  {
    // Gradients.
    defaults.put("Button.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
      {new Float(1.0), new Float(0.0), new ColorUIResource(Color.WHITE),
      new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
    defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("Slider.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("Slider.focusGradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
    defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
      {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));

    // Colors.
    ColorUIResource c1 = new ColorUIResource(200, 221, 242);
    ColorUIResource c2 = new ColorUIResource(153, 153, 153);
    ColorUIResource c3 = new ColorUIResource(204, 204, 204);
    ColorUIResource c4 = new ColorUIResource(210, 226, 239);
    ColorUIResource c5 = new ColorUIResource(218, 218, 218);
    defaults.put("Button.disabledToolBarBorderBackground", c3);
    defaults.put("Button.toolBarBorderBackground", c2);
    defaults.put("Label.disabledForeground", c2);
    defaults.put("MenuBar.borderColor", c3);
    defaults.put("Slider.altTrackColor", c4);
    defaults.put("SplitPane.dividerFocusColor", c1);
    defaults.put("TabbedPane.contentAreaColor", c1);
    defaults.put("TabbedPane.borderHightlightColor", PRIMARY1);
    defaults.put("TabbedPane.selected", c1);
    defaults.put("TabbedPane.tabAreaBackground", c5);
    defaults.put("TabbedPane.unselectedBackground", SECONDARY3);
    defaults.put("Table.gridColor", SECONDARY1);
    defaults.put("ToolBar.borderColor", c3);
    defaults.put("Tree.selectionBorderColor", PRIMARY1);

    // Borders.
    defaults.put("List.focusCellHighlightBorder",
                 new LineBorderUIResource(getPrimary1()));
    defaults.put("Table.focusCellHighlightBorder",
                 new LineBorderUIResource(getPrimary1()));

    // Insets.
    defaults.put("TabbedPane.contentBorderInsets", new Insets(4, 2, 3, 3));
    defaults.put("TabbedPane.tabAreaInsets", new Insets(2, 2, 0, 6));

    // Flags.
    defaults.put("SplitPane.oneTouchButtonsOpaque", Boolean.FALSE);
    defaults.put("Menu.opaque", Boolean.FALSE);
    defaults.put("ToolBar.isRollover", Boolean.TRUE);
    defaults.put("RadioButton.rollover", Boolean.TRUE);
    defaults.put("CheckBox.rollover", Boolean.TRUE);
    defaults.put("Button.rollover", Boolean.TRUE);

    // Icons.
    // FIXME: Add OceanTheme icons.
//    defaults.put("Tree.leafIcon", XXX);
//    defaults.put("Tree.expandedIcon", XXX);
//    defaults.put("Tree.openIcon", XXX);
//    defaults.put("Tree.closedIcon", XXX);
//    defaults.put("Tree.collapsedIcon", XXX);
//    defaults.put("FileChooser.newFolderIcon", XXX);
//    defaults.put("FileChooser.homeFolderIcon", XXX);
//    defaults.put("FileChooser.upFolderIcon", XXX);
//    defaults.put("FileView.hardDriveIcon", XXX);
//    defaults.put("FileView.floppyDriveIcon", XXX);
//    defaults.put("FileView.fileIcon", XXX);
//    defaults.put("FileView.computerIcon", XXX);
//    defaults.put("FileView.directoryIcon", XXX);
//    defaults.put("OptionPane.questionIcon", XXX);
//    defaults.put("OptionPane.errorIcon", XXX);
//    defaults.put("OptionPane.warningIcon", XXX);
//    defaults.put("OptionPane.informationIcon", XXX);
//    defaults.put("InternalFrame.icon", XXX);
//    defaults.put("InternalFrame.closeIcon", XXX);
//    defaults.put("InternalFrame.iconifyIcon", XXX);
//    defaults.put("InternalFrame.minimizeIcon", XXX);
//    defaults.put("InternalFrame.maximizeIcon", XXX);
//    defaults.put("InternalFrame.paletteCloseIcon", XXX);

    // UI classes.
    defaults.put("MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI");

    // Others.
    defaults.put("Button.rolloverIconType", "ocean");
  }
}