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
34 import sun.swing.PrintColorUIResource;
35 import sun.swing.SwingLazyValue;
36
37 /**
38 * The default theme for the {@code MetalLookAndFeel}.
39 * <p>
40 * The designers
41 * of the Metal Look and Feel strive to keep the default look up to
42 * date, possibly through the use of new themes in the future.
43 * Therefore, developers should only use this class directly when they
44 * wish to customize the "Ocean" look, or force it to be the current
45 * theme, regardless of future updates.
46
47 * <p>
48 * All colors returned by {@code OceanTheme} are completely
49 * opaque.
50 *
51 * @since 1.5
52 * @see MetalLookAndFeel#setCurrentTheme
53 */
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 private static class IFIcon extends IconUIResource {
102 private Icon pressed;
103
104 public IFIcon(Icon normal, Icon pressed) {
105 super(normal);
106 this.pressed = pressed;
107 }
108
109 public void paintIcon(Component c, Graphics g, int x, int y) {
110 ButtonModel model = ((AbstractButton)c).getModel();
111 if (model.isPressed() && model.isArmed()) {
112 pressed.paintIcon(c, g, x, y);
113 } else {
114 super.paintIcon(c, g, x, y);
115 }
116 }
117 }
118
119 /**
120 * 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
34 import sun.swing.PrintColorUIResource;
35 import sun.swing.SwingLazyValue;
36
37 /**
38 * The default theme for the {@code MetalLookAndFeel}.
39 * <p>
40 * The designers
41 * of the Metal Look and Feel strive to keep the default look up to
42 * date, possibly through the use of new themes in the future.
43 * Therefore, developers should only use this class directly when they
44 * wish to customize the "Ocean" look, or force it to be the current
45 * theme, regardless of future updates.
46
47 * <p>
48 * All colors returned by {@code OceanTheme} are completely
49 * opaque.
50 *
51 * @since 1.5
52 * @see MetalLookAndFeel#setCurrentTheme
53 */
54 @SuppressWarnings("serial") // Superclass is not serializable across versions
55 public class OceanTheme extends DefaultMetalTheme {
56 private static final ColorUIResource PRIMARY1 =
57 new ColorUIResource(0x6382BF);
58 private static final ColorUIResource PRIMARY2 =
59 new ColorUIResource(0xA3B8CC);
60 private static final ColorUIResource PRIMARY3 =
61 new ColorUIResource(0xB8CFE5);
62 private static final ColorUIResource SECONDARY1 =
63 new ColorUIResource(0x7A8A99);
64 private static final ColorUIResource SECONDARY2 =
65 new ColorUIResource(0xB8CFE5);
66 private static final ColorUIResource SECONDARY3 =
67 new ColorUIResource(0xEEEEEE);
68
69 private static final ColorUIResource CONTROL_TEXT_COLOR =
70 new PrintColorUIResource(0x333333, Color.BLACK);
71 private static final ColorUIResource INACTIVE_CONTROL_TEXT_COLOR =
72 new ColorUIResource(0x999999);
73 private static final ColorUIResource MENU_DISABLED_FOREGROUND =
74 new ColorUIResource(0x999999);
82 // Delegates to different icons based on component orientation
83 private static class COIcon extends IconUIResource {
84 private Icon rtl;
85
86 public COIcon(Icon ltr, Icon rtl) {
87 super(ltr);
88 this.rtl = rtl;
89 }
90
91 public void paintIcon(Component c, Graphics g, int x, int y) {
92 if (MetalUtils.isLeftToRight(c)) {
93 super.paintIcon(c, g, x, y);
94 } else {
95 rtl.paintIcon(c, g, x, y);
96 }
97 }
98 }
99
100 // InternalFrame Icon
101 // Delegates to different icons based on button state
102 @SuppressWarnings("serial") // Superclass is not serializable across versions
103 private static class IFIcon extends IconUIResource {
104 private Icon pressed;
105
106 public IFIcon(Icon normal, Icon pressed) {
107 super(normal);
108 this.pressed = pressed;
109 }
110
111 public void paintIcon(Component c, Graphics g, int x, int y) {
112 ButtonModel model = ((AbstractButton)c).getModel();
113 if (model.isPressed() && model.isArmed()) {
114 pressed.paintIcon(c, g, x, y);
115 } else {
116 super.paintIcon(c, g, x, y);
117 }
118 }
119 }
120
121 /**
122 * Creates an instance of <code>OceanTheme</code>
|