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