1 /*
2 * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
33 import sun.swing.SwingUtilities2;
34 import sun.swing.PrintColorUIResource;
35
36 /**
37 * The default theme for the {@code MetalLookAndFeel}.
38 * <p>
39 * The designers
40 * of the Metal Look and Feel strive to keep the default look up to
41 * date, possibly through the use of new themes in the future.
42 * Therefore, developers should only use this class directly when they
43 * wish to customize the "Ocean" look, or force it to be the current
44 * theme, regardless of future updates.
45
46 * <p>
47 * All colors returned by {@code OceanTheme} are completely
48 * opaque.
49 *
50 * @since 1.5
51 * @see MetalLookAndFeel#setCurrentTheme
52 */
53 public class OceanTheme extends DefaultMetalTheme {
54 private static final ColorUIResource PRIMARY1 =
55 new ColorUIResource(0x6382BF);
56 private static final ColorUIResource PRIMARY2 =
57 new ColorUIResource(0xA3B8CC);
58 private static final ColorUIResource PRIMARY3 =
59 new ColorUIResource(0xB8CFE5);
60 private static final ColorUIResource SECONDARY1 =
61 new ColorUIResource(0x7A8A99);
62 private static final ColorUIResource SECONDARY2 =
63 new ColorUIResource(0xB8CFE5);
64 private static final ColorUIResource SECONDARY3 =
65 new ColorUIResource(0xEEEEEE);
66
67 private static final ColorUIResource CONTROL_TEXT_COLOR =
68 new PrintColorUIResource(0x333333, Color.BLACK);
69 private static final ColorUIResource INACTIVE_CONTROL_TEXT_COLOR =
70 new ColorUIResource(0x999999);
71 private static final ColorUIResource MENU_DISABLED_FOREGROUND =
72 new ColorUIResource(0x999999);
80 // Delegates to different icons based on component orientation
81 private static class COIcon extends IconUIResource {
82 private Icon rtl;
83
84 public COIcon(Icon ltr, Icon rtl) {
85 super(ltr);
86 this.rtl = rtl;
87 }
88
89 public void paintIcon(Component c, Graphics g, int x, int y) {
90 if (MetalUtils.isLeftToRight(c)) {
91 super.paintIcon(c, g, x, y);
92 } else {
93 rtl.paintIcon(c, g, x, y);
94 }
95 }
96 }
97
98 // InternalFrame Icon
99 // Delegates to different icons based on button state
100 private static class IFIcon extends IconUIResource {
101 private Icon pressed;
102
103 public IFIcon(Icon normal, Icon pressed) {
104 super(normal);
105 this.pressed = pressed;
106 }
107
108 public void paintIcon(Component c, Graphics g, int x, int y) {
109 ButtonModel model = ((AbstractButton)c).getModel();
110 if (model.isPressed() && model.isArmed()) {
111 pressed.paintIcon(c, g, x, y);
112 } else {
113 super.paintIcon(c, g, x, y);
114 }
115 }
116 }
117
118 /**
119 * Creates an instance of <code>OceanTheme</code>
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
33 import sun.swing.SwingUtilities2;
34 import sun.swing.PrintColorUIResource;
35
36 /**
37 * The default theme for the {@code MetalLookAndFeel}.
38 * <p>
39 * The designers
40 * of the Metal Look and Feel strive to keep the default look up to
41 * date, possibly through the use of new themes in the future.
42 * Therefore, developers should only use this class directly when they
43 * wish to customize the "Ocean" look, or force it to be the current
44 * theme, regardless of future updates.
45
46 * <p>
47 * All colors returned by {@code OceanTheme} are completely
48 * opaque.
49 *
50 * @since 1.5
51 * @see MetalLookAndFeel#setCurrentTheme
52 */
53 @SuppressWarnings("serial") // Superclass is not serializable across versions
54 public class OceanTheme extends DefaultMetalTheme {
55 private static final ColorUIResource PRIMARY1 =
56 new ColorUIResource(0x6382BF);
57 private static final ColorUIResource PRIMARY2 =
58 new ColorUIResource(0xA3B8CC);
59 private static final ColorUIResource PRIMARY3 =
60 new ColorUIResource(0xB8CFE5);
61 private static final ColorUIResource SECONDARY1 =
62 new ColorUIResource(0x7A8A99);
63 private static final ColorUIResource SECONDARY2 =
64 new ColorUIResource(0xB8CFE5);
65 private static final ColorUIResource SECONDARY3 =
66 new ColorUIResource(0xEEEEEE);
67
68 private static final ColorUIResource CONTROL_TEXT_COLOR =
69 new PrintColorUIResource(0x333333, Color.BLACK);
70 private static final ColorUIResource INACTIVE_CONTROL_TEXT_COLOR =
71 new ColorUIResource(0x999999);
72 private static final ColorUIResource MENU_DISABLED_FOREGROUND =
73 new ColorUIResource(0x999999);
81 // Delegates to different icons based on component orientation
82 private static class COIcon extends IconUIResource {
83 private Icon rtl;
84
85 public COIcon(Icon ltr, Icon rtl) {
86 super(ltr);
87 this.rtl = rtl;
88 }
89
90 public void paintIcon(Component c, Graphics g, int x, int y) {
91 if (MetalUtils.isLeftToRight(c)) {
92 super.paintIcon(c, g, x, y);
93 } else {
94 rtl.paintIcon(c, g, x, y);
95 }
96 }
97 }
98
99 // InternalFrame Icon
100 // Delegates to different icons based on button state
101 @SuppressWarnings("serial") // Superclass is not serializable across versions
102 private static class IFIcon extends IconUIResource {
103 private Icon pressed;
104
105 public IFIcon(Icon normal, Icon pressed) {
106 super(normal);
107 this.pressed = pressed;
108 }
109
110 public void paintIcon(Component c, Graphics g, int x, int y) {
111 ButtonModel model = ((AbstractButton)c).getModel();
112 if (model.isPressed() && model.isArmed()) {
113 pressed.paintIcon(c, g, x, y);
114 } else {
115 super.paintIcon(c, g, x, y);
116 }
117 }
118 }
119
120 /**
121 * Creates an instance of <code>OceanTheme</code>
|