1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.roundeddiv;
20
21 import org.apache.myfaces.custom.div.Div;
22
23 /**
24 * Component that allows for a rounded border effect on DIV tags that is supported in CSS2 compatible browsers and IE6.
25 * <p>
26 * Component that generates a DIV tag with rounded corners that may
27 * be either 3D or 2D in appearence.
28 * </p><p>
29 * The "roundedDiv" component creates a DIV tag that contains images to
30 * produce rounded corners. The rounded effect can be either 3D with lighting effects
31 * or 2D with a solid color border.
32 * </p>
33 *
34 * @JSFComponent
35 * name = "s:roundedDiv"
36 * class = "org.apache.myfaces.custom.roundeddiv.HtmlRoundedDiv"
37 * tagClass = "org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivTag"
38 *
39 * @author Andrew Robinson (latest modification by $Author: skitching $)
40 * @version $Revision: 676950 $ $Date: 2008-07-15 11:09:46 -0500 (Tue, 15 Jul 2008) $
41 */
42 public abstract class AbstractHtmlRoundedDiv extends Div
43 {
44 public final static String COMPONENT_TYPE = "org.apache.myfaces.HtmlRoundedDiv";
45 private final static String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlRoundedDiv";
46
47 /**
48 * Default constructor
49 */
50 public AbstractHtmlRoundedDiv()
51 {
52 setRendererType(DEFAULT_RENDERER_TYPE);
53 }
54
55 /**
56 * The CSS style to give to the content DIV or TD (based on layout)
57 *
58 * @JSFProperty
59 * @return the contentStyle
60 */
61 public abstract String getContentStyle();
62
63 /**
64 * The CSS style class to give to the content DIV or TD (based on layout)
65 *
66 * @JSFProperty
67 * @return the contentStyleClass
68 */
69 public abstract String getContentStyleClass();
70
71 /**
72 * Either "table" or "div". Specifies how the output should be rendered.
73 * Size must be null if using "table" (if it is not, a div will be rendered).
74 * (Default: div)
75 *
76 * @JSFProperty
77 * defaultValue = "div"
78 * @return
79 */
80 public abstract String getLayout();
81
82 /**
83 * Background color to give the corners. Leave blank (null) to have a transparent
84 * background. If the user is using IE6, this has to be set, or the corners
85 * will not look good due to IE6's lack of PNG support.
86 *
87 * @JSFProperty
88 * @return the backgroundColor
89 */
90 public abstract String getBackgroundColor();
91
92 /**
93 * The color of the border. If specified, this will cause the DIV to be 2D, if
94 * it isn't the border with have a 3D effect with lighting effects to produce
95 * the border color.
96 *
97 * @JSFProperty
98 * @return the borderColor
99 */
100 public abstract String getBorderColor();
101
102 /**
103 * Flips the lightening/darkening effect for 3D borders. (Default: false)
104 *
105 * @JSFProperty
106 * defaultValue = "false";
107 * @return the inverse
108 */
109 public abstract Boolean getInverse();
110
111 /**
112 * The width of the border in pixels. (Default: 8)
113 *
114 * @JSFProperty
115 * defaultValue = "Integer.valueOf(8)"
116 * @return the borderWidth
117 */
118 public abstract Integer getBorderWidth();
119
120 /**
121 * This allows you to specify a comma-separated list of corners to include.
122 * If not given, all four corners will be rendered. The corners include the
123 * sides they touch. So for example, if used as a tab for a tabbed pane, you
124 * could specify "topleft,topright" to have everything but the bottom corners
125 * and side have the border. Valid values are: topleft, topright, bottomright,
126 * bottomleft
127 *
128 * @JSFProperty
129 * @return the corners
130 */
131 public abstract String getCorners();
132
133 /**
134 * The foreground color of the DIV
135 *
136 * @JSFProperty
137 * @return the color
138 */
139 public abstract String getColor();
140
141 /**
142 * The radius of the corners in pixels. (Default: 8)
143 *
144 * @JSFProperty
145 * defaultValue = "Integer.valueOf(8)"
146 * @return the radius
147 */
148 public abstract Integer getRadius();
149
150 /**
151 * If given, a static size image will be produced. This could be useful for
152 * older browsers. If not given, the DIV that will be created will stretch
153 * to its contents using CSS2 (and CSS expressions in IE6). Value must
154 * contain two numbers, with width first. Example: 640x480
155 *
156 * @JSFProperty
157 * @return the size
158 */
159 public abstract String getSize();
160
161 /**
162 * @see org.apache.myfaces.custom.htmlTag.HtmlTag#getStyle()
163 */
164 public String getStyle()
165 {
166 String style = super.getStyle();
167 StringBuffer sb = (style == null) ? new StringBuffer() : new StringBuffer(style).append(';');
168
169 if (style == null || style.indexOf("position:") < 0)
170 {
171 sb.append("position: relative;");
172 }
173 if ("table".equals(getValue()))
174 {
175 sb.append("border-collapse: collapse;");
176 }
177
178 return sb.toString();
179 }
180
181 /**
182 * @JSFProperty
183 * @see org.apache.myfaces.custom.div.Div#getValue()
184 */
185 public Object getValue()
186 {
187 if ("table".equalsIgnoreCase(getLayout()) && getSize() == null)
188 {
189 return "table";
190 }
191 return "div";
192 }
193
194 }