001: /*
002: * Copyright 2005 Patrick Gotthardt
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package com.pagosoft.plaf;
017:
018: import javax.swing.*;
019: import javax.swing.plaf.*;
020: import javax.swing.plaf.metal.*;
021: import java.awt.*;
022:
023: public class PgsTheme extends DefaultMetalTheme {
024: private String name;
025: private ColorUIResource primary1;
026: private ColorUIResource primary2;
027: private ColorUIResource primary3;
028: private ColorUIResource secondary1;
029: private ColorUIResource secondary2;
030: private ColorUIResource secondary3;
031: private ColorUIResource black;
032: private ColorUIResource white;
033: private FontUIResource menuFont;
034: private Object[] defaults;
035:
036: public PgsTheme(String name) {
037: this .name = name;
038: if (PlafOptions.useBoldMenuFonts()) {
039: menuFont = super .getMenuTextFont();
040: } else {
041: menuFont = new FontUIResource(super .getMenuTextFont()
042: .deriveFont(Font.PLAIN));
043: }
044: }
045:
046: /**
047: * Convert a common MetalTheme to a PgsTheme (using colors only)
048: * /// (seems to be not required!)/
049: * public PgsTheme(MetalTheme t) {
050: * this(
051: * t.getName(),
052: * t.getPrimaryControlDarkShadow(), t.getPrimaryControlShadow(), t.getPrimaryControl(),
053: * t.getControlDarkShadow(), t.getControlShadow(), t.getControl(),
054: * t.getControlInfo(), t.getControlHighlight()
055: * );
056: * }//
057: */
058:
059: public PgsTheme(Color p1, Color p2, Color p3, Color s1, Color s2,
060: Color s3) {
061: this ("PgsTheme", p1, p2, p3, s1, s2, s3, Color.black,
062: Color.white);
063: }
064:
065: public PgsTheme(String themeName, Color p1, Color p2, Color p3,
066: Color s1, Color s2, Color s3) {
067: this (themeName, p1, p2, p3, s1, s2, s3, Color.black,
068: Color.white);
069: }
070:
071: public PgsTheme(Color p1, Color p2, Color p3, Color s1, Color s2,
072: Color s3, Color bl, Color wh) {
073: this ("PgsTheme", p1, p2, p3, s1, s2, s3, bl, wh);
074: }
075:
076: public PgsTheme(String themeName, Color p1, Color p2, Color p3,
077: Color s1, Color s2, Color s3, Color bl, Color wh) {
078: this (themeName, p1, p2, p3, s1, s2, s3, bl, wh, null);
079: }
080:
081: public PgsTheme(String themeName, Color p1, Color p2, Color p3,
082: Color s1, Color s2, Color s3, Color bl, Color wh, Object[] d) {
083: // Common things
084: name = themeName;
085: // Primary colos
086: primary1 = new ColorUIResource(p1);
087: primary2 = new ColorUIResource(p2);
088: primary3 = new ColorUIResource(p3);
089: // Secondary colors
090: secondary1 = new ColorUIResource(s1);
091: secondary2 = new ColorUIResource(s2);
092: secondary3 = new ColorUIResource(s3);
093: // black 'n white
094: black = new ColorUIResource(bl);
095: white = new ColorUIResource(wh);
096: // Custom entries
097: defaults = d;
098: if (PlafOptions.useBoldMenuFonts()) {
099: menuFont = new FontUIResource(super .getMenuTextFont()
100: .deriveFont(Font.BOLD));
101: } else {
102: menuFont = super .getMenuTextFont();
103: }
104: }
105:
106: public void setBlack(ColorUIResource black) {
107: this .black = black;
108: }
109:
110: public void setDefaults(Object[] defaults) {
111: this .defaults = defaults;
112: }
113:
114: public void setMenuFont(FontUIResource menuFont) {
115: this .menuFont = menuFont;
116: }
117:
118: public void setName(String name) {
119: this .name = name;
120: }
121:
122: public void setPrimary1(ColorUIResource primary1) {
123: this .primary1 = primary1;
124: }
125:
126: public void setPrimary2(ColorUIResource primary2) {
127: this .primary2 = primary2;
128: }
129:
130: public void setPrimary3(ColorUIResource primary3) {
131: this .primary3 = primary3;
132: }
133:
134: public void setSecondary1(ColorUIResource secondary1) {
135: this .secondary1 = secondary1;
136: }
137:
138: public void setSecondary2(ColorUIResource secondary2) {
139: this .secondary2 = secondary2;
140: }
141:
142: public void setSecondary3(ColorUIResource secondary3) {
143: this .secondary3 = secondary3;
144: }
145:
146: public void setWhite(ColorUIResource white) {
147: this .white = white;
148: }
149:
150: public ColorUIResource getPrimary1() {
151: return primary1;
152: }
153:
154: public ColorUIResource getPrimary2() {
155: return primary2;
156: }
157:
158: public ColorUIResource getPrimary3() {
159: return primary3;
160: }
161:
162: public ColorUIResource getSecondary1() {
163: return secondary1;
164: }
165:
166: public ColorUIResource getSecondary2() {
167: return secondary2;
168: }
169:
170: public ColorUIResource getSecondary3() {
171: return secondary3;
172: }
173:
174: public ColorUIResource getBlack() {
175: return black;
176: }
177:
178: public ColorUIResource getWhite() {
179: return white;
180: }
181:
182: public String getName() {
183: return name;
184: }
185:
186: public FontUIResource getMenuTextFont() {
187: return menuFont;
188: }
189:
190: public void addCustomEntriesToTable(UIDefaults table) {
191: if (defaults != null) {
192: table.putDefaults(defaults);
193: }
194: }
195: }
|