001: /*
002: * ExecuteQueryTheme2.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.executequery.plaf;
023:
024: import java.awt.Color;
025: import java.awt.Font;
026: import java.awt.Insets;
027: import java.util.Arrays;
028: import javax.swing.UIDefaults;
029:
030: import javax.swing.UIManager;
031: import javax.swing.plaf.ColorUIResource;
032: import javax.swing.plaf.FontUIResource;
033: import javax.swing.plaf.metal.OceanTheme;
034: import javax.swing.plaf.metal.DefaultMetalTheme;
035: import org.underworldlabs.swing.plaf.UIUtils;
036:
037: /* ----------------------------------------------------------
038: * CVS NOTE: Changes to the CVS repository prior to the
039: * release of version 3.0.0beta1 has meant a
040: * resetting of CVS revision numbers.
041: * ----------------------------------------------------------
042: */
043:
044: /**
045: * Simple theme applied to the Java Metal look and feel.
046: *
047: * @author Takis Diakoumis
048: * @version $Revision: 1.6 $
049: * @date $Date: 2006/06/28 09:25:58 $
050: */
051: public class ExecuteQueryTheme2 extends OceanTheme {
052:
053: // ---------------------------------
054: // --------- System Fonts ----------
055: // ---------------------------------
056: private FontUIResource menuFont;
057: private FontUIResource controlFont;
058: private FontUIResource systemFont;
059: private FontUIResource userFont;
060: private FontUIResource smallFont;
061:
062: // --------------------------------------------
063: // ------ Primary and Secondary Colours -------
064: // --------------------------------------------
065: // ********************************************
066: // --------------------------------------------
067: // ------------ Java Look and Feel ------------
068: // --------------------------------------------
069: // -------- primary 1: 102,102,153 --------
070: // -------- primary 2: 153,153,204 --------
071: // -------- primary 3: 204,204,255 --------
072: // -------- secondary 1: 102,102,102 --------
073: // -------- secondary 2: 153,153,153 --------
074: // -------- secondary 3: 204,204,204 --------
075: // --------------------------------------------
076: // ********************************************
077:
078: // --------------------------------------------
079: // ------------ Execute Query Theme -----------
080: // --------------------------------------------
081:
082: // --- active internal frame borders ---
083: private final ColorUIResource primary1 = new ColorUIResource(102,
084: 102, 153);
085:
086: // --- scroll bars, highlights, menu selection etc ---
087: private final ColorUIResource primary2 = new ColorUIResource(145,
088: 145, 207);
089:
090: // --- active internal frame headers ---
091: private final ColorUIResource primary3 = new ColorUIResource(169,
092: 169, 242);
093:
094: // --- dark border for 3D for eg buttons ---
095: private final ColorUIResource secondary1 = new ColorUIResource(102,
096: 102, 102);
097:
098: // --- inactive internal frame borders, dimmed button borders ---
099: private final ColorUIResource secondary2 = new ColorUIResource(153,
100: 153, 153);
101:
102: // --- panel/frame, normal background ---
103: private final ColorUIResource secondary3 = new ColorUIResource(240,
104: 240, 240);
105:
106: private static final ColorUIResource CONTROL_TEXT_COLOR = new ColorUIResource(
107: Color.BLACK);
108:
109: private static final ColorUIResource THEME_BLACK = new ColorUIResource(
110: Color.BLACK);
111:
112: public ExecuteQueryTheme2() {
113: // ------------------------------
114: // add some further l&f defaults
115: // ------------------------------
116:
117: ColorUIResource black = new ColorUIResource(0, 0, 0);
118:
119: // black text for labels
120: UIManager.put("Label.foreground", black);
121: // black text for title border
122: UIManager.put("TitledBorder.titleColor", black);
123: // toggle button selected colour to primary3
124: UIManager.put("ToggleButton.select", primary3);
125:
126: }
127:
128: public static final Color BRIGHTEN_START = new Color(255, 255, 255,
129: 0);
130: public static final Color BRIGHTEN_STOP = new Color(255, 255, 255,
131: 128);
132: public static final Color LT_BRIGHTEN_STOP = new Color(255, 255,
133: 255, 64);
134:
135: public static final Color DARKEN_START = new Color(0, 0, 0, 0);
136: public static final Color DARKEN_STOP = new Color(0, 0, 0, 64);
137: public static final Color LT_DARKEN_STOP = new Color(0, 0, 0, 32);
138:
139: /**
140: * Add this theme's custom entries to the defaults table.
141: *
142: * @param table the defaults table, non-null
143: * @throws NullPointerException if the parameter is null
144: */
145: public void addCustomEntriesToTable(UIDefaults table) {
146: super .addCustomEntriesToTable(table);
147:
148: int treeFontSize = table.getFont("Tree.font").getSize();
149: Integer rowHeight = new Integer(treeFontSize + 5);
150: Object treeExpandedIcon = UIUtils.getExpandedTreeIcon();
151: Object treeCollapsedIcon = UIUtils.getCollapsedTreeIcon();
152: ColorUIResource gray = new ColorUIResource(Color.gray);
153:
154: Color dadada = new ColorUIResource(0xDADADA);
155: Color cccccc = new ColorUIResource(0xCCCCCC);
156:
157: java.util.List buttonGradient = Arrays.asList(
158: //new Object[] {new Float(.15f), new Float(0.05f),
159: new Object[] { new Float(.15f), new Float(-2.0f),
160: new ColorUIResource(BRIGHTEN_START),
161: new ColorUIResource(BRIGHTEN_STOP),
162: getSecondary3() });
163:
164: buttonGradient = Arrays.asList(new Object[] { new Float(0.15f),
165: new Float(-2.0f), new ColorUIResource(Color.BLUE),
166: new ColorUIResource(Color.RED), getSecondary3() });
167:
168: /*
169: java.util.List buttonGradient = Arrays.asList(
170: new Object[] {new Float(0.15f), new Float(-.0f),
171: new ColorUIResource(0xF0F0F0), getWhite(), getSecondary3() });
172: */
173:
174: java.util.List scrollGradient = Arrays.asList(new Object[] {
175: new Float(0.005f), new Float(-2.5f),
176: new ColorUIResource(BRIGHTEN_START),
177: new ColorUIResource(BRIGHTEN_STOP), getPrimary1() });
178:
179: scrollGradient = Arrays.asList(new Object[] { new Float(0.15f),
180: new Float(-1.5f), getWhite(),
181: new ColorUIResource(LT_BRIGHTEN_STOP),
182: getPrimary1().brighter() });
183:
184: Object[] defaults = new Object[] {
185: "Button.gradient",
186: buttonGradient,
187:
188: "ScrollBar.gradient",
189: scrollGradient,
190: "ScrollBar.darkShadow",
191: cccccc,
192:
193: "Button.rollover",
194: Boolean.FALSE,
195: //"ButtonUI", "org.executequery.plaf.smoothgradient.SmoothGradientButtonUI",
196:
197: //"ScrollBarUI", "org.executequery.plaf.smoothgradient.SmoothGradientScrollBarUI",
198:
199: "CheckBox.gradient",
200: null,
201: "CheckBoxMenuItem.gradient",
202: null,
203: "RadioButton.gradient",
204: null,
205: "RadioButtonMenuItem.gradient",
206: null,
207:
208: //"ComboBox.selectionBackground", secondary3,
209:
210: "TabbedPane.borderHightlightColor",
211: secondary1.brighter(), "TabbedPane.contentAreaColor",
212: secondary3, "TabbedPane.contentBorderInsets",
213: new Insets(2, 2, 3, 3), "TabbedPane.selected",
214: secondary3, "TabbedPane.tabAreaBackground", secondary3,
215: "TabbedPane.tabAreaInsets", new Insets(4, 2, 0, 6),
216: "TabbedPane.unselectedBackground", cccccc,
217:
218: "Tree.expandedIcon", treeExpandedIcon,
219: "Tree.collapsedIcon", treeCollapsedIcon, "Tree.line",
220: gray, "Tree.hash", gray, "Tree.rowHeight", rowHeight,
221: /*
222: "Menu.opaque", Boolean.FALSE,
223: "MenuBar.gradient", Arrays.asList(new Object[] {
224: new Float(1f), new Float(0f),
225: getWhite(), dadada,
226: new ColorUIResource(dadada) }),
227: "MenuBar.borderColor", cccccc,
228: "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI"
229: */
230: };
231:
232: table.putDefaults(defaults);
233:
234: }
235:
236: public String getName() {
237: return "Execute Query";
238: }
239:
240: private static final int DEFAULT_FONT_SIZE = 11;
241:
242: public FontUIResource getControlTextFont() {
243:
244: if (controlFont == null) {
245:
246: try {
247: controlFont = new FontUIResource(Font.getFont(
248: "swing.plaf.metal.controlFont",
249: new Font("Dialog", Font.PLAIN,
250: DEFAULT_FONT_SIZE)));
251: } catch (Exception e) {
252: controlFont = new FontUIResource("Dialog", Font.BOLD,
253: DEFAULT_FONT_SIZE);
254: }
255:
256: }
257:
258: return controlFont;
259:
260: }
261:
262: public FontUIResource getSystemTextFont() {
263:
264: if (systemFont == null) {
265:
266: try {
267: systemFont = new FontUIResource(Font.getFont(
268: "swing.plaf.metal.systemFont",
269: new Font("Dialog", Font.PLAIN,
270: DEFAULT_FONT_SIZE)));
271: } catch (Exception e) {
272: systemFont = new FontUIResource("Dialog", Font.PLAIN,
273: DEFAULT_FONT_SIZE);
274: }
275:
276: }
277:
278: return systemFont;
279:
280: }
281:
282: public FontUIResource getUserTextFont() {
283:
284: if (userFont == null) {
285:
286: try {
287: userFont = new FontUIResource(Font.getFont(
288: "swing.plaf.metal.userFont", new Font("Dialog",
289: Font.PLAIN, DEFAULT_FONT_SIZE)));
290: } catch (Exception e) {
291: userFont = new FontUIResource("Dialog", Font.PLAIN,
292: DEFAULT_FONT_SIZE);
293: }
294:
295: }
296:
297: return userFont;
298: }
299:
300: public FontUIResource getMenuTextFont() {
301:
302: if (menuFont == null) {
303:
304: try {
305: menuFont = new FontUIResource(Font.getFont(
306: "swing.plaf.metal.menuFont", new Font("Dialog",
307: Font.PLAIN, DEFAULT_FONT_SIZE)));
308: } catch (Exception e) {
309: menuFont = new FontUIResource("Dialog", Font.PLAIN,
310: DEFAULT_FONT_SIZE);
311: }
312:
313: }
314:
315: return menuFont;
316:
317: }
318:
319: public FontUIResource getWindowTitleFont() {
320:
321: if (controlFont == null) {
322:
323: try {
324: controlFont = new FontUIResource(Font.getFont(
325: "swing.plaf.metal.controlFont",
326: new Font("Dialog", Font.PLAIN,
327: DEFAULT_FONT_SIZE)));
328: } catch (Exception e) {
329: controlFont = new FontUIResource("Dialog", Font.BOLD,
330: DEFAULT_FONT_SIZE);
331: }
332:
333: }
334:
335: return controlFont;
336:
337: }
338:
339: public FontUIResource getSubTextFont() {
340:
341: if (smallFont == null) {
342:
343: try {
344: smallFont = new FontUIResource(Font.getFont(
345: "swing.plaf.metal.smallFont", new Font(
346: "Dialog", Font.PLAIN, 10)));
347: } catch (Exception e) {
348: smallFont = new FontUIResource("Dialog", Font.PLAIN, 10);
349: }
350:
351: }
352:
353: return smallFont;
354:
355: }
356:
357: protected ColorUIResource getPrimary1() {
358: return primary1;
359: }
360:
361: protected ColorUIResource getPrimary2() {
362: return primary2;
363: }
364:
365: protected ColorUIResource getPrimary3() {
366: return primary3;
367: }
368:
369: protected ColorUIResource getSecondary1() {
370: return secondary1;
371: }
372:
373: protected ColorUIResource getSecondary2() {
374: return secondary2;
375: }
376:
377: protected ColorUIResource getSecondary3() {
378: return secondary3;
379: }
380:
381: /**
382: * Return the color that the EQ Look and Feel should use as the default
383: * color for controls. The Look and Feel will use this color
384: * in painting as it sees fit.
385: *
386: * @return the "Control Text" color.
387: */
388: public ColorUIResource getControlTextColor() {
389: return CONTROL_TEXT_COLOR;
390: }
391:
392: /**
393: * Return the color that the EQ Look and Feel should use
394: * as "Black". The Look and Feel will use this color
395: * in painting as it sees fit. This color does not necessarily
396: * synch up with the typical concept of black, nor is
397: * it necessarily used for all black items.
398: *
399: * @return the "Black" color.
400: */
401: protected ColorUIResource getBlack() {
402: return THEME_BLACK;
403: }
404:
405: }
|