001: /*
002: * @(#)SBorderFactory.java 1.0 01/01/02
003: *
004: * Factory inspired by javax.swing.BorderFactory
005: */
006: package org.wings;
007:
008: import java.awt.Color;
009: import java.awt.Font;
010: import org.wings.SComponent;
011: import org.wings.border.*;
012:
013: /**
014: * Factory class for standard <code>SBorder</code> elements.
015: */
016: public class SBorderFactory {
017:
018: /** We are static */
019: private SBorderFactory() {
020: }
021:
022: //// LineBorder ///////////////////////////////////////////////////////////////
023:
024: /**
025: * Creates a line SBorder withe the specified color.
026: *
027: * @param color a <code>Color</code> to use for the line
028: * @return the <code>SBorder</code> object
029: */
030: public static SBorder createSLineBorder(Color color) {
031: return new SLineBorder(color, 1);
032: }
033:
034: /**
035: * Creates a line SBorder with the specified color
036: * and width. The width applies to all four sides of the
037: * SBorder. To specify widths individually for the top,
038: * bottom, left, and right, use
039: * {@link #createSEmptyBorder(int, int, int, int)}.
040: *
041: * @param color a <code>Color</code> to use for the line
042: * @param thickness an integer specifying the width in pixels
043: * @return the <code>SBorder</code> object
044: */
045: public static SBorder createSLineBorder(Color color, int thickness) {
046: return new SLineBorder(color, thickness);
047: }
048:
049: //// BevelBorder /////////////////////////////////////////////////////////////
050:
051: /**
052: * Creates a SBorder with a raised beveled edge, using
053: * brighter shades of the component's current background color
054: * for highlighting, and darker shading for shadows.
055: * (In a raised SBorder, highlights are on top and shadows
056: * are underneath.)
057: *
058: * @return the <code>SBorder</code> object
059: */
060: public static SBorder createRaisedSBevelBorder() {
061: return new SBevelBorder(SBevelBorder.RAISED);
062: }
063:
064: /**
065: * Creates a SBorder with a lowered beveled edge, using
066: * brighter shades of the component's current background color
067: * for highlighting, and darker shading for shadows.
068: * (In a lowered SBorder, shadows are on top and highlights
069: * are underneath.)
070: *
071: * @return the <code>SBorder</code> object
072: */
073: public static SBorder createLoweredSBevelBorder() {
074: return new SBevelBorder(SBevelBorder.LOWERED);
075: }
076:
077: /**
078: * Creates a beveled SBorder of the specified type, using
079: * brighter shades of the component's current background color
080: * for highlighting, and darker shading for shadows.
081: * (In a lowered SBorder, shadows are on top and highlights
082: * are underneath.)
083: *
084: * @param type an integer specifying either
085: * <code>BevelBorder.LOWERED</code> or
086: * <code>BevelBorder.RAISED</code>
087: * @return the <code>SBorder</code> object
088: */
089: public static SBorder createSBevelBorder(int type) {
090: return new SBevelBorder(type);
091: }
092:
093: /**
094: * Creates a beveled SBorder of the specified type, using
095: * the specified highlighting and shadowing. The outer
096: * edge of the highlighted area uses a brighter shade of
097: * the highlight color. The inner edge of the shadow area
098: * uses a brighter shade of the shadow color.
099: *
100: * @param type an integer specifying either
101: * <code>BevelBorder.LOWERED</code> or
102: * <code>BevelBorder.RAISED</code>
103: * @param highlight a <code>Color</code> object for highlights
104: * @param shadow a <code>Color</code> object for shadows
105: * @return the <code>SBorder</code> object
106: */
107: /* public static SBorder createSBevelBorder(int type, Color highlight, Color shadow) {
108: return new SBevelBorder(type, highlight, shadow);
109: } */
110:
111: /**
112: * Creates a beveled SBorder of the specified type, using
113: * the specified colors for the inner and outer highlight
114: * and shadow areas.
115: * <p>
116: * Note: The shadow inner and outer colors are
117: * switched for a lowered bevel SBorder.
118: *
119: * @param type an integer specifying either
120: * <code>BevelBorder.LOWERED</code> or
121: * <code>BevelBorder.RAISED</code>
122: * @param highlightOuter a <code>Color</code> object for the
123: * outer edge of the highlight area
124: * @param highlightInner a <code>Color</code> object for the
125: * inner edge of the highlight area
126: * @param shadowOuter a <code>Color</code> object for the
127: * outer edge of the shadow area
128: * @param shadowInner a <code>Color</code> object for the
129: * inner edge of the shadow area
130: * @return the <code>SBorder</code> object
131: */
132: /* public static SBorder createSBevelBorder(int type,
133: Color highlightOuter, Color highlightInner,
134: Color shadowOuter, Color shadowInner) {
135: return new SBevelBorder(type, highlightOuter, highlightInner,
136: shadowOuter, shadowInner);
137: }
138: */
139:
140: //// EtchedBorder ///////////////////////////////////////////////////////////
141: /**
142: * Creates a SBorder with an "etched" look using
143: * the component's current background color for
144: * highlighting and shading.
145: *
146: * @return the <code>SBorder</code> object
147: */
148: public static SBorder createSEtchedBorder() {
149: return new SEtchedBorder();
150: }
151:
152: /**
153: * Creates a SBorder with an "etched" look using
154: * the specified highlighting and shading colors.
155: *
156: * @param etchedType Raised or Lowered
157: * @return the <code>SBorder</code> object
158: */
159: public static SBorder createSEtchedBorder(int etchedType) {
160: return new SEtchedBorder(etchedType);
161: }
162:
163: /**
164: * Creates a SBorder with an "etched" look using
165: * the specified highlighting and shading colors.
166: *
167: * @param type one of <code>EtchedBorder.RAISED</code>, or
168: * <code>EtchedBorder.LOWERED</code>
169: * @param highlight a <code>Color</code> object for the SBorder highlights
170: * @param shadow a <code>Color</code> object for the SBorder shadows
171: * @return the <code>SBorder</code> object
172: * @since 1.3
173: */
174: /* public static SBorder createSEtchedBorder(int type, Color highlight,
175: Color shadow) {
176: return new SEtchedBorder(type, highlight, shadow);
177: }
178: */
179:
180: //// EmptyBorder ///////////////////////////////////////////////////////////
181: /**
182: * Creates an empty SBorder that takes up no space. (The width
183: * of the top, bottom, left, and right sides are all zero.)
184: *
185: * @return the <code>SBorder</code> object
186: */
187: public static SBorder createSEmptyBorder() {
188: return new SEmptyBorder(0, 0, 0, 0);
189: }
190:
191: /**
192: * Creates an empty SBorder that takes up space but which does
193: * no drawing, specifying the width of the top, left, bottom, and
194: * right sides.
195: *
196: * @param top an integer specifying the width of the top,
197: * in pixels
198: * @param left an integer specifying the width of the left side,
199: * in pixels
200: * @param bottom an integer specifying the width of the bottom,
201: * in pixels
202: * @param right an integer specifying the width of the right side,
203: * in pixels
204: * @return the <code>SBorder</code> object
205: */
206: public static SBorder createSEmptyBorder(int top, int left,
207: int bottom, int right) {
208: return new SEmptyBorder(top, left, bottom, right);
209: }
210: }
|