comparison src/samer/core_/util/swing/SilkyMetalTheme.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bf79fb79ee13
1 package samer.core.util.swing;
2
3 import javax.swing.plaf.*;
4 import javax.swing.*;
5 import java.awt.*;
6
7 public class SilkyMetalTheme extends javax.swing.plaf.metal.MetalTheme {
8
9 private ColorUIResource primary1;
10 private ColorUIResource primary2;
11 private ColorUIResource primary3;
12 private ColorUIResource red, blue, yellow, green, highlight;
13
14 private ColorUIResource secondary1;
15 private ColorUIResource secondary2;
16 private ColorUIResource secondary3;
17
18 private FontUIResource plainFont;
19 private FontUIResource smallFont;
20 private FontUIResource boldFont;
21
22 public String getName() { return "Silk"; }
23
24 public SilkyMetalTheme(Font font, Color bg, double hue)
25 {
26 System.err.println("Metal theme: base font is "+font);
27
28 plainFont = new FontUIResource(font);
29 smallFont = new FontUIResource(font.deriveFont(0.8f*font.getSize2D()));
30 boldFont = new FontUIResource(font.deriveFont(Font.BOLD));
31
32 primary3 = new ColorUIResource(Color.getHSBColor((float)hue,0.3f,1.0f));
33 primary2 =new ColorUIResource(Color.getHSBColor((float)hue,0.4f,.9f));
34 primary1 =new ColorUIResource(Color.getHSBColor((float)hue,0.3f,.3f));
35
36 secondary3 = new ColorUIResource(bg);
37 secondary2 = new ColorUIResource(bg.darker());
38 secondary1 = new ColorUIResource(bg.darker().darker());
39 highlight = new ColorUIResource(bg.brighter());
40
41 red=new ColorUIResource(Color.red);
42 blue=new ColorUIResource(Color.blue);
43 green=new ColorUIResource(Color.green);
44 yellow=new ColorUIResource(Color.yellow);
45 }
46
47 public void addCustomEntriesToTable(UIDefaults table)
48 {
49 table.put( "Button.font", boldFont);
50 table.put( "Label.foreground", getBlack());
51 table.put( "TitledBorder.font", boldFont);
52 table.put( "List.font", plainFont);
53 }
54
55 public ColorUIResource getPrimary1() { return primary1; }
56 public ColorUIResource getPrimary2() { return primary2; }
57 public ColorUIResource getPrimary3() { return primary3; }
58
59 public ColorUIResource getSecondary1() { return secondary1; }
60 public ColorUIResource getSecondary2() { return secondary2; }
61 public ColorUIResource getSecondary3() { return secondary3; }
62
63 public FontUIResource getControlTextFont() { return plainFont;}
64 public FontUIResource getSystemTextFont() { return plainFont;}
65 public FontUIResource getUserTextFont() { return plainFont;}
66 public FontUIResource getMenuTextFont() { return plainFont;}
67 public FontUIResource getWindowTitleFont() { return boldFont;}
68 public FontUIResource getSubTextFont() { return smallFont;}
69
70 // these are fore tweaking
71
72 public ColorUIResource getDesktopColor() { return getPrimary1(); }
73
74 public ColorUIResource getControl() { return getSecondary3(); }
75 public ColorUIResource getControlShadow() { return getSecondary2(); }
76 public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
77 // public ColorUIResource getControlInfo() { return getBlack(); }
78 public ColorUIResource getControlHighlight() { return highlight; } // getWhite(); }
79 // public ColorUIResource getControlDisabled() { return getSecondary2(); }
80
81 // public ColorUIResource getPrimaryControl() { return getPrimary3(); }
82 // public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
83 // public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
84 // public ColorUIResource getPrimaryControlInfo() { return getBlack(); }
85 public ColorUIResource getPrimaryControlHighlight() { return highlight; } // getWhite(); }
86
87 // public ColorUIResource getSystemTextColor() { return getPrimary1(); }
88 // public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
89
90 public ColorUIResource getSeparatorBackground() { return highlight; } // getWhite(); }
91 public ColorUIResource getSeparatorForeground() { return getSecondary2(); } // getPrimary1(); }
92 }