KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > border > STitledBorder


1 /*
2  * $Id: STitledBorder.java,v 1.6 2005/05/27 09:17:33 blueshift Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.border;
15
16 import org.wings.SFont;
17 import org.wings.style.CSSProperty;
18 import org.wings.style.CSSAttributeSet;
19 import org.wings.style.CSSStyleSheet;
20
21 import java.awt.*;
22
23 /**
24  * @version $Revision: 1.6 $
25  */

26 public class STitledBorder extends SAbstractBorder {
27     private SBorder border;
28
29     private String JavaDoc title;
30     private CSSAttributeSet titleAttributes = new CSSAttributeSet();
31
32     /**
33      * Constructor for STitledBorder.
34      */

35     public STitledBorder(SBorder border) {
36         setBorder(border);
37         attributes.put(CSSProperty.PADDING_TOP, "1em");
38     }
39
40     /**
41      * Constructor for STitledBorder.
42      *
43      * @param border the border to use
44      * @param title the title to display
45      */

46     public STitledBorder(SBorder border, String JavaDoc title) {
47         this(border);
48         setTitle(title);
49     }
50
51     /**
52      * Constructor for STitledBorder. Default border
53      * type is {@link SEtchedBorder}, thickness 2
54      */

55     public STitledBorder(String JavaDoc title) {
56         this(new SEtchedBorder(SEtchedBorder.LOWERED));
57         border.setThickness(2);
58         setTitle(title);
59     }
60
61     /**
62      * Gets the border.
63      *
64      * @return Returns a SBorder
65      */

66     public SBorder getBorder() {
67         return border;
68     }
69
70     /**
71      * Sets the border.
72      *
73      * @param border The border to set
74      */

75     public void setBorder(SBorder border) {
76         this.border = border;
77         attributes = border.getAttributes();
78     }
79
80     /**
81      * Gets the title.
82      *
83      * @return Returns a String
84      */

85     public String JavaDoc getTitle() {
86         return title;
87     }
88
89     /**
90      * Sets the title.
91      *
92      * @param title The title to set
93      */

94     public void setTitle(String JavaDoc title) {
95         this.title = title;
96     }
97
98     public CSSAttributeSet getTitleAttributes() {
99         return titleAttributes;
100     }
101
102     /**
103      * Gets the title color.
104      *
105      * @return Returns a Color
106      */

107     public Color getTitleColor() {
108         return CSSStyleSheet.getForeground(titleAttributes);
109     }
110
111     /**
112      * Sets the title color.
113      *
114      * @param color the title color to set
115      */

116     public void setTitleColor(Color color) {
117         titleAttributes.put(CSSProperty.COLOR, CSSStyleSheet.getAttribute(color));
118     }
119
120     /**
121      * Set the border color.
122      */

123     public void setTitleBackground(Color color) {
124         titleAttributes.put(CSSProperty.BACKGROUND_COLOR, CSSStyleSheet.getAttribute(color));
125     }
126
127     /**
128      * Get the border color.
129      *
130      * @return the color or <code>null</code>,
131      * if border is <code>null</code>
132      * @see #setBorder(SBorder)
133      */

134     public Color getTitleBackground() {
135         return CSSStyleSheet.getBackground(titleAttributes);
136     }
137
138     /**
139      * Gets the title font.
140      *
141      * @return Returns a SFont
142      */

143     public SFont getTitleFont() {
144         return CSSStyleSheet.getFont(titleAttributes);
145     }
146
147     /**
148      * Sets the title font.
149      *
150      * @param titleFont The title font to set
151      */

152     public void setTitleFont(SFont titleFont) {
153         titleAttributes.putAll(CSSStyleSheet.getAttributes(titleFont));
154     }
155 }
156
Popular Tags