001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Sergey Burlak
020: * @version $Revision$
021: */package javax.swing.plaf;
022:
023: import java.awt.Color;
024: import java.awt.Component;
025: import java.awt.Font;
026: import java.awt.Graphics;
027: import java.awt.Insets;
028: import java.io.Serializable;
029: import javax.swing.Icon;
030: import javax.swing.border.BevelBorder;
031: import javax.swing.border.Border;
032: import javax.swing.border.CompoundBorder;
033: import javax.swing.border.EmptyBorder;
034: import javax.swing.border.EtchedBorder;
035: import javax.swing.border.LineBorder;
036: import javax.swing.border.MatteBorder;
037: import javax.swing.border.TitledBorder;
038:
039: import org.apache.harmony.x.swing.internal.nls.Messages;
040:
041: public class BorderUIResource implements Border, UIResource,
042: Serializable {
043: private static Border etched;
044: private static Border blackLine;
045: private static Border raisedBevel;
046: private static Border loweredBevel;
047:
048: public static class BevelBorderUIResource extends BevelBorder
049: implements UIResource {
050:
051: public BevelBorderUIResource(final int bevelType,
052: final Color highlightOuter, final Color highlightInner,
053: final Color shadowOuter, final Color shadowInner) {
054: super (bevelType, highlightOuter, highlightInner,
055: shadowOuter, shadowInner);
056: }
057:
058: public BevelBorderUIResource(final int bevelType,
059: final Color highlight, final Color shadow) {
060: super (bevelType, highlight, shadow);
061: }
062:
063: public BevelBorderUIResource(final int bevelType) {
064: super (bevelType);
065: }
066:
067: }
068:
069: public static class CompoundBorderUIResource extends CompoundBorder
070: implements UIResource {
071:
072: public CompoundBorderUIResource(final Border out,
073: final Border in) {
074: super (out, in);
075: }
076:
077: }
078:
079: public static class EmptyBorderUIResource extends EmptyBorder
080: implements UIResource {
081:
082: public EmptyBorderUIResource(final Insets ins) {
083: super (ins);
084: }
085:
086: public EmptyBorderUIResource(final int top, final int left,
087: final int bottom, final int right) {
088: super (top, left, bottom, right);
089: }
090: }
091:
092: public static class EtchedBorderUIResource extends EtchedBorder
093: implements UIResource {
094:
095: public EtchedBorderUIResource(final Color highlight,
096: final Color shadow) {
097: super (highlight, shadow);
098: }
099:
100: public EtchedBorderUIResource(final int etchType,
101: final Color highlight, final Color shadow) {
102: super (etchType, highlight, shadow);
103: }
104:
105: public EtchedBorderUIResource(final int etchType) {
106: super (etchType);
107: }
108:
109: public EtchedBorderUIResource() {
110: }
111:
112: }
113:
114: public static class LineBorderUIResource extends LineBorder
115: implements UIResource {
116:
117: public LineBorderUIResource(final Color color, final int thick) {
118: super (color, thick);
119: }
120:
121: public LineBorderUIResource(final Color color) {
122: super (color);
123: }
124:
125: }
126:
127: public static class MatteBorderUIResource extends MatteBorder
128: implements UIResource {
129:
130: public MatteBorderUIResource(final Icon icon) {
131: super (icon);
132: }
133:
134: public MatteBorderUIResource(final int top, final int left,
135: final int bottom, final int right, final Icon icon) {
136: super (top, left, bottom, right, icon);
137: }
138:
139: public MatteBorderUIResource(final int top, final int left,
140: final int bottom, final int right, final Color color) {
141: super (top, left, bottom, right, color);
142: }
143:
144: }
145:
146: public static class TitledBorderUIResource extends TitledBorder
147: implements UIResource {
148:
149: public TitledBorderUIResource(final Border border,
150: final String title, final int justification,
151: final int position, final Font font, final Color color) {
152: super (border, title, justification, position, font, color);
153: }
154:
155: public TitledBorderUIResource(final Border border,
156: final String title, final int justification,
157: final int position, final Font font) {
158: super (border, title, justification, position, font);
159: }
160:
161: public TitledBorderUIResource(final Border border,
162: final String title, final int justification,
163: final int position) {
164: super (border, title, justification, position);
165: }
166:
167: public TitledBorderUIResource(final Border border,
168: final String title) {
169: super (border, title);
170: }
171:
172: public TitledBorderUIResource(final Border border) {
173: super (border);
174: }
175:
176: public TitledBorderUIResource(final String title) {
177: super (title);
178: }
179:
180: }
181:
182: private Border border;
183:
184: public BorderUIResource(final Border border) {
185: if (border == null) {
186: throw new IllegalArgumentException(Messages
187: .getString("swing.6B")); //$NON-NLS-1$
188: }
189: this .border = border;
190: }
191:
192: public Insets getBorderInsets(final Component c) {
193: return border.getBorderInsets(c);
194: }
195:
196: public void paintBorder(final Component c, final Graphics g,
197: final int x, final int y, final int w, final int h) {
198: border.paintBorder(c, g, x, y, w, h);
199: }
200:
201: public boolean isBorderOpaque() {
202: return border.isBorderOpaque();
203: }
204:
205: /**
206: * Return raised bevel border
207: * @return Border result
208: */
209: public static Border getRaisedBevelBorderUIResource() {
210: if (raisedBevel == null) {
211: raisedBevel = new BevelBorderUIResource(0);
212: }
213: return raisedBevel;
214: }
215:
216: /**
217: * Return lowered bevel border
218: * @return Border result
219: */
220: public static Border getLoweredBevelBorderUIResource() {
221: if (loweredBevel == null) {
222: loweredBevel = new BevelBorderUIResource(1);
223: }
224: return loweredBevel;
225: }
226:
227: /**
228: * Return etched border
229: * @return Border result
230: */
231: public static Border getEtchedBorderUIResource() {
232: if (etched == null) {
233: etched = new EtchedBorderUIResource(1);
234: }
235: return etched;
236: }
237:
238: /**
239: * Return black line border
240: * @return Border result
241: */
242: public static Border getBlackLineBorderUIResource() {
243: if (blackLine == null) {
244: blackLine = new LineBorderUIResource(Color.black);
245: }
246: return blackLine;
247: }
248: }
|