You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2007/07/07 23:33:44 UTC
svn commit: r554270 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/roundeddiv/
core/src/main/resources-facesconfig/META-INF/
core/src/main/resources/org/apache/myfaces/custom/roundeddiv/
core/src/main/resources/org/a...
Author: arobinson74
Date: Sat Jul 7 14:33:42 2007
New Revision: 554270
URL: http://svn.apache.org/viewvc?view=rev&rev=554270
Log:
Adding the new rounded div component
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/resource/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/resource/blank.gif (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml (with props)
myfaces/tomahawk/trunk/sandbox/core/src/site/apt/roundedDiv.apt
myfaces/tomahawk/trunk/sandbox/core/src/site/resources/images/roundedDiv.png (with props)
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java (with props)
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp (with props)
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
myfaces/tomahawk/trunk/sandbox/core/src/site/site.xml
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java Sat Jul 7 14:33:42 2007
@@ -0,0 +1,319 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * --
+ * $Id$
+ */
+package org.apache.myfaces.custom.roundeddiv;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.custom.div.Div;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+
+/**
+ * Component that generates a DIV tag with rounded corners that may
+ * be either 3D or 2D in appearence.
+ *
+ * @author Andrew Robinson (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class HtmlRoundedDiv extends Div
+{
+ public final static String COMPONENT_TYPE = "org.apache.myfaces.HtmlRoundedDiv";
+ private final static String DEFAULT_RENDERER_TYPE = HtmlRoundedDivRenderer.RENDERER_TYPE;
+
+ private Color color;
+ private Color backgroundColor;
+ private Color borderColor;
+ private Integer borderWidth;
+ private Integer radius;
+ private Dimension size;
+ private String corners;
+ private Boolean inverse;
+
+ /**
+ * Default constructor
+ */
+ public HtmlRoundedDiv()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTag#getStyle()
+ */
+ public String getStyle()
+ {
+ String style = super.getStyle();
+ if (style == null)
+ {
+ style = "position: relative;";
+ }
+ else if (style.indexOf("position:") < 0)
+ {
+ style = "position: relative;" + style;
+ }
+ return style;
+ }
+
+ /**
+ * @return the backgroundColor
+ */
+ public Color getBackgroundColor()
+ {
+ if (this.backgroundColor != null)
+ return this.backgroundColor;
+ ValueBinding vb = getValueBinding("backgroundColor");
+ return vb == null ? null : asColor(vb.getValue(getFacesContext()));
+ }
+
+ /**
+ * @param backgroundColor the backgroundColor to set
+ */
+ public void setBackgroundColor(Color backgroundColor)
+ {
+ this.backgroundColor = backgroundColor;
+ }
+
+ /**
+ * @return the borderColor
+ */
+ public Color getBorderColor()
+ {
+ if (this.borderColor != null)
+ return this.borderColor;
+ ValueBinding vb = getValueBinding("borderColor");
+ return vb == null ? null : asColor(vb.getValue(getFacesContext()));
+ }
+
+ /**
+ * @param borderColor the borderColor to set
+ */
+ public void setBorderColor(Color borderColor)
+ {
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @return the inverse
+ */
+ public Boolean getInverse()
+ {
+ if (this.inverse != null)
+ return this.inverse;
+ ValueBinding vb = getValueBinding("inverse");
+ Boolean value = vb == null ? null : (Boolean) vb
+ .getValue(getFacesContext());
+ return value == null ? Boolean.FALSE : value;
+ }
+
+ /**
+ * @param inverse the inverse to set
+ */
+ public void setInverse(Boolean inverse)
+ {
+ this.inverse = inverse;
+ }
+
+ /**
+ * @return the borderWidth
+ */
+ public Integer getBorderWidth()
+ {
+ if (this.borderWidth != null)
+ return this.borderWidth;
+ ValueBinding vb = getValueBinding("borderWidth");
+ Object value = vb == null ? null : vb.getValue(getFacesContext());
+ if (value == null || "".equals(value))
+ {
+ value = new Integer(8);
+ }
+ else if (!(value instanceof Integer))
+ {
+ value = new Integer(value.toString());
+ }
+ return (Integer)value;
+ }
+
+ /**
+ * @param borderWidth the borderWidth to set
+ */
+ public void setBorderWidth(Integer borderWidth)
+ {
+ this.borderWidth = borderWidth;
+ }
+
+ /**
+ * @return the corners
+ */
+ public String getCorners()
+ {
+ if (this.corners != null)
+ return this.corners;
+ ValueBinding vb = getValueBinding("corners");
+ String value = vb == null ? null : RendererUtils.getStringValue(
+ getFacesContext(), vb);
+ return value == null || "".equals(value) ? null : value;
+ }
+
+ /**
+ * @param corners the corners to set
+ */
+ public void setCorners(String corners)
+ {
+ this.corners = corners;
+ }
+
+ /**
+ * @return the color
+ */
+ public Color getColor()
+ {
+ if (this.color != null)
+ return this.color;
+ ValueBinding vb = getValueBinding("color");
+ return vb == null ? null : asColor(vb.getValue(getFacesContext()));
+ }
+
+ /**
+ * @param color the color to set
+ */
+ public void setColor(Color color)
+ {
+ this.color = color;
+ }
+
+ /**
+ * @return the radius
+ */
+ public Integer getRadius()
+ {
+ if (this.radius != null)
+ return this.radius;
+ ValueBinding vb = getValueBinding("radius");
+ Object value = vb == null ? null : vb.getValue(getFacesContext());
+ if (value == null || "".equals(value))
+ {
+ value = new Integer(8);
+ }
+ else if (!(value instanceof Integer))
+ {
+ value = new Integer(value.toString());
+ }
+ return (Integer)value;
+ }
+
+ /**
+ * @param radius the radius to set
+ */
+ public void setRadius(Integer radius)
+ {
+ this.radius = radius;
+ }
+
+ /**
+ * @return the size
+ */
+ public Dimension getSize()
+ {
+ if (this.size != null)
+ return this.size;
+ ValueBinding vb = getValueBinding("size");
+ if (vb == null)
+ return null;
+
+ Object value = vb.getValue(getFacesContext());
+
+ if (value == null || "".equals(value))
+ {
+ return null;
+ }
+ else if (value instanceof Dimension)
+ {
+ return (Dimension) value;
+ }
+ else
+ {
+ Matcher m = Pattern.compile("(\\d+)\\D+(\\d+)").matcher(
+ value.toString());
+ if (!m.find())
+ {
+ throw new IllegalArgumentException("Invalid dimension");
+ }
+ return new Dimension(Integer.parseInt(m.group(1)), Integer
+ .parseInt(m.group(2)));
+ }
+ }
+
+ /**
+ * @param size the size to set
+ */
+ public void setSize(Dimension size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTag#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context)
+ {
+ return new Object[] { super.saveState(context), color, backgroundColor,
+ borderColor, borderWidth, radius, size, corners, inverse };
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTag#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] arr = (Object[]) state;
+ int index = -1;
+ super.restoreState(context, arr[++index]);
+ this.color = (Color) arr[++index];
+ this.backgroundColor = (Color) arr[++index];
+ this.borderColor = (Color) arr[++index];
+ this.borderWidth = (Integer) arr[++index];
+ this.radius = (Integer) arr[++index];
+ this.size = (Dimension) arr[++index];
+ this.corners = (String) arr[++index];
+ this.inverse = (Boolean) arr[++index];
+ }
+
+ private Color asColor(Object value)
+ {
+ if (value == null || "".equals(value))
+ {
+ return null;
+ }
+ else if (value instanceof Color)
+ {
+ return (Color) value;
+ }
+ else
+ {
+ return Color.decode(value.toString());
+ }
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDiv.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java Sat Jul 7 14:33:42 2007
@@ -0,0 +1,756 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * --
+ * $Id$
+ */
+package org.apache.myfaces.custom.roundeddiv;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.imageio.ImageIO;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.myfaces.component.html.util.ParameterResourceHandler;
+import org.apache.myfaces.custom.htmlTag.HtmlTagRenderer;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.renderkit.html.util.ResourceLoader;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+
+/**
+ * Renderer for the {@link HtmlRoundedDiv} component.
+ *
+ * @author Andrew Robinson (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class HtmlRoundedDivRenderer extends HtmlTagRenderer implements
+ ResourceLoader
+{
+ public final static String RENDERER_TYPE = "org.apache.myfaces.HtmlRoundedDiv";
+
+ /**
+ * @see org.apache.myfaces.renderkit.html.util.ResourceLoader#serveResource(
+ * javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse, java.lang.String)
+ */
+ public void serveResource(ServletContext context,
+ HttpServletRequest request, HttpServletResponse response,
+ String resourceUri) throws IOException
+ {
+ Color foregroundColor = Color.decode(request.getParameter("c"));
+
+ String param;
+ Color backgroundColor = null, borderColor = null;
+ if ((param = request.getParameter("bgc")) != null)
+ {
+ backgroundColor = Color.decode(param);
+ }
+ if ((param = request.getParameter("bc")) != null)
+ {
+ borderColor = Color.decode(param);
+ }
+
+ int borderWidth = Integer.parseInt(request.getParameter("bw"));
+ int radius = Integer.parseInt(request.getParameter("r"));
+
+ Dimension size = null;
+ if ((param = request.getParameter("s")) != null)
+ {
+ int i = param.indexOf('x');
+ size = new Dimension(Integer.parseInt(param.substring(0, i)),
+ Integer.parseInt(param.substring(i + 1)));
+ }
+ String area = request.getParameter("a");
+
+ boolean inverse = "t".equals(request.getParameter("i"));
+
+ RoundedBorderGenerator borderGen;
+ BufferedImage img;
+
+ // TODO: caching support of images to improve performance
+
+ borderGen = new RoundedBorderGenerator(borderColor, borderWidth,
+ radius, foregroundColor, backgroundColor, size, inverse);
+
+ if (size != null)
+ {
+ img = borderGen.createImage();
+ }
+ else
+ {
+ img = borderGen.createImageSection(getAreaAsSection(area));
+ }
+
+ borderGen.dispose();
+
+ response.setContentType("image/png");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ImageIO.write(img, "png", baos);
+ byte[] data = baos.toByteArray();
+ baos = null;
+
+ response.setContentLength(data.length);
+ OutputStream out = response.getOutputStream();
+ try
+ {
+ out.write(data);
+ }
+ finally
+ {
+ out.close();
+ }
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTagRenderer#encodeBegin(
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ super.encodeBegin(context, component);
+ if (!component.isRendered())
+ return;
+
+ boolean ie = isIE(context);
+
+ HtmlRoundedDiv div = (HtmlRoundedDiv) component;
+ ResponseWriter writer = context.getResponseWriter();
+ Set areas = null;
+
+ if (div.getSize() != null)
+ {
+ addImage(writer, context, div, null, null, ie);
+ }
+ else
+ {
+ areas = getAreasToRender(context, div);
+ for (Iterator iter = areas.iterator(); iter.hasNext();)
+ {
+ String area = (String) iter.next();
+ addImage(writer, context, div, area, areas, ie);
+ }
+ }
+
+ // create a DIV for the contents
+ writer.startElement(HTML.DIV_ELEM, component);
+ StringBuffer style = new StringBuffer("position: relative; z-index: 1;");
+ addPadding(Math.max(div.getBorderWidth().intValue(), div.getRadius()
+ .intValue()), style, areas);
+ writer.writeAttribute(HTML.STYLE_ATTR, style, null);
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTagRenderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ super.encodeEnd(context, component);
+ if (!component.isRendered())
+ {
+ return;
+ }
+ context.getResponseWriter().endElement(HTML.DIV_ELEM);
+ }
+
+ /**
+ * Convert the string area to one of the integer contants from
+ * {@link RoundedBorderGenerator}
+ *
+ * @param area the area as a string
+ * @return integer constant value
+ */
+ protected int getAreaAsSection(String area)
+ {
+ if ("top".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_TOP;
+ }
+ else if ("topright".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_TOPRIGHT;
+ }
+ else if ("right".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_RIGHT;
+ }
+ else if ("bottomright".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_BOTTOMRIGHT;
+ }
+ else if ("bottom".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_BOTTOM;
+ }
+ else if ("bottomleft".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_BOTTOMLEFT;
+ }
+ else if ("left".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_LEFT;
+ }
+ else if ("topleft".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_TOPLEFT;
+ }
+ else if ("center".equals(area))
+ {
+ return RoundedBorderGenerator.SECTION_CENTER;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid area: " + area);
+ }
+ }
+
+ /**
+ * Get the areas to render. This takes into account the corners
+ * that the user has requested to be rendered.
+ *
+ * @param context {@link FacesContext}
+ * @param component The component
+ * @return A set of strings containing the areas to render
+ */
+ protected Set getAreasToRender(FacesContext context,
+ HtmlRoundedDiv component)
+ {
+ String corners = component.getCorners();
+ Set areas = new HashSet();
+
+ if (corners != null)
+ {
+ String[] cornersArr = corners.split("\\s*,\\s*");
+ for (int i = 0; i < cornersArr.length; i++)
+ {
+ if ("topleft".equals(cornersArr[i]))
+ {
+ areas.add("top");
+ areas.add("left");
+ areas.add("topleft");
+ }
+ else if ("topright".equals(cornersArr[i]))
+ {
+ areas.add("top");
+ areas.add("right");
+ areas.add("topright");
+ }
+ else if ("bottomright".equals(cornersArr[i]))
+ {
+ areas.add("right");
+ areas.add("bottom");
+ areas.add("bottomright");
+ }
+ else if ("bottomleft".equals(cornersArr[i]))
+ {
+ areas.add("bottom");
+ areas.add("bottomleft");
+ areas.add("left");
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid corner: "
+ + cornersArr[i]);
+ }
+ }
+ areas.add("center");
+ }
+ else
+ {
+ areas.add("top");
+ areas.add("topright");
+ areas.add("right");
+ areas.add("bottomright");
+ areas.add("bottom");
+ areas.add("bottomleft");
+ areas.add("left");
+ areas.add("topleft");
+ areas.add("center");
+ }
+ return areas;
+ }
+
+ /**
+ * Adds an IMG tag to the response for an image
+ *
+ * @param writer The response writer
+ * @param context The faces context
+ * @param component The component
+ * @param area The area of the image
+ * @param areas All the areas to be rendered
+ * @param ie If the browser is IE
+ * @throws IOException when writing to the writer
+ */
+ protected void addImage(ResponseWriter writer, FacesContext context,
+ HtmlRoundedDiv component, String area, Set areas, boolean ie)
+ throws IOException
+ {
+ StringBuffer style = new StringBuffer(
+ "position: absolute;padding: 0px;margin: 0px;");
+ String url = getImageSource(context, component, area);
+ int padding = Math.max(component.getBorderWidth().intValue(), component
+ .getRadius().intValue());
+
+ if (ie)
+ {
+// NOT CURRENTLY WORKING:
+// // IE transparency fix
+// if (component.getBackgroundColor() == null
+// && ("topright".equals(area) || "topleft".equals(area)
+// || "bottomright".equals(area) || "bottomleft"
+// .equals(area)) && isIE6(context))
+// {
+// setIESrcForCorner(context, component, url, style, padding);
+// url = AddResourceFactory.getInstance(context).getResourceUri(
+// context, HtmlRoundedDiv.class, "blank.gif");
+// }
+
+ if (areas != null)
+ {
+ setIECssPosition(padding, style, area, areas);
+ }
+ }
+ else if (areas != null)
+ {
+ setCssPosition(padding, style, area, areas);
+ }
+
+ writer.startElement(HTML.IMG_ELEM, component);
+ writer.writeAttribute(HTML.SRC_ATTR, url, null);
+ writer.writeAttribute(HTML.STYLE_ATTR, style, null);
+ writer.endElement(HTML.IMG_ELEM);
+ }
+
+ /**
+ * Set the CSS positioning attributes for IE6
+ *
+ * @param padding The size of the image section
+ * @param style The current style
+ * @param area The area
+ * @param areas All the areas to be rendered
+ */
+ protected void setIECssPosition(int padding, StringBuffer style,
+ String area, Set areas)
+ {
+ if ("center".equals(area))
+ {
+ int p = 0;
+ if (areas.contains("left"))
+ {
+ p += padding;
+ }
+ if (areas.contains("right"))
+ {
+ p += padding;
+ }
+ style.append("width: expression((offsetParent.clientWidth - ")
+ .append(p).append(") + 'px');");
+
+ p = 0;
+ if (areas.contains("top"))
+ {
+ p += padding;
+ }
+ if (areas.contains("bottom"))
+ {
+ p += padding;
+ }
+ style.append("height: expression((offsetParent.clientHeight - ")
+ .append(p).append(") + 'px');");
+
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ }
+ else if ("top".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ style.append("height: ").append(padding).append("px;");
+
+ int p = 0;
+ if (areas.contains("left"))
+ {
+ p += padding;
+ }
+ if (areas.contains("right"))
+ {
+ p += padding;
+ }
+ style.append("width: expression((offsetParent.clientWidth - ")
+ .append(p).append(") + 'px');");
+ }
+ else if ("topright".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("right: 0px;");
+ }
+ else if ("right".equals(area))
+ {
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("right: 0px;");
+ style.append("width: ").append(padding).append("px;");
+
+ int p = 0;
+ if (areas.contains("top"))
+ {
+ p += padding;
+ }
+ if (areas.contains("bottom"))
+ {
+ p += padding;
+ }
+ style.append("height: expression((offsetParent.clientHeight - ")
+ .append(p).append(") + 'px');");
+ }
+ else if ("bottomright".equals(area))
+ {
+ style.append("right: 0px;");
+ style.append("bottom: 0px;");
+ }
+ else if ("bottom".equals(area))
+ {
+ style.append("bottom: 0px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ style.append("height: ").append(padding).append("px;");
+
+ int p = 0;
+ if (areas.contains("left"))
+ {
+ p += padding;
+ }
+ if (areas.contains("right"))
+ {
+ p += padding;
+ }
+ style.append("width: expression((offsetParent.clientWidth - ")
+ .append(p).append(") + 'px');");
+ }
+ else if ("bottomleft".equals(area))
+ {
+ style.append("bottom: 0px;");
+ style.append("left: 0px;");
+ }
+ else if ("left".equals(area))
+ {
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("left: 0px;");
+ style.append("width: ").append(padding).append("px;");
+
+ int p = 0;
+ if (areas.contains("top"))
+ {
+ p += padding;
+ }
+ if (areas.contains("bottom"))
+ {
+ p += padding;
+ }
+ style.append("height: expression((offsetParent.clientHeight - ")
+ .append(p).append(") + 'px');");
+ }
+ else
+ //if ("topleft".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("left: 0px;");
+ }
+ }
+
+// NOT CURRENTLY WORKING:
+// /**
+// * Set the CSS style for IE6 to work-around the IE6 PNG alpha-transparency
+// * bug
+// *
+// * @param context The faces context
+// * @param component The component
+// * @param url The URL of the image
+// * @param style The current style
+// */
+// protected void setIESrcForCorner(FacesContext context,
+// HtmlRoundedDiv component, String url, StringBuffer style,
+// int imageSize)
+// {
+// style
+// .append(
+// " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='")
+// .append(url).append("', sizingMethod='image', enabled=true);").append(
+// "height: ").append(imageSize).append("px; width: ")
+// .append(imageSize).append("px;");
+// }
+
+ /**
+ * Set the CSS position using CSS2 attributes
+ *
+ * @param padding The size of the image section
+ * @param style The current style
+ * @param area The area
+ * @param areas All the areas to be rendered
+ */
+ protected void setCssPosition(int padding, StringBuffer style, String area,
+ Set areas)
+ {
+ if ("center".equals(area))
+ {
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("right: ").append(
+ areas.contains("right") ? padding : 0).append("px;");
+ style.append("bottom: ").append(
+ areas.contains("bottom") ? padding : 0).append("px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ }
+ else if ("top".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("right: ").append(
+ areas.contains("right") ? padding : 0).append("px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ style.append("height: ").append(padding).append("px;");
+ }
+ else if ("topright".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("right: 0px;");
+ }
+ else if ("right".equals(area))
+ {
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("right: 0px;");
+ style.append("bottom: ").append(
+ areas.contains("bottom") ? padding : 0).append("px;");
+ style.append("width: ").append(padding).append("px;");
+ }
+ else if ("bottomright".equals(area))
+ {
+ style.append("right: 0px;");
+ style.append("bottom: 0px;");
+ }
+ else if ("bottom".equals(area))
+ {
+ style.append("right: ").append(
+ areas.contains("right") ? padding : 0).append("px;");
+ style.append("bottom: 0px;");
+ style.append("left: ").append(areas.contains("left") ? padding : 0)
+ .append("px;");
+ style.append("height: ").append(padding).append("px;");
+ }
+ else if ("bottomleft".equals(area))
+ {
+ style.append("bottom: 0px;");
+ style.append("left: 0px;");
+ }
+ else if ("left".equals(area))
+ {
+ style.append("top: ").append(areas.contains("top") ? padding : 0)
+ .append("px;");
+ style.append("bottom: ").append(
+ areas.contains("bottom") ? padding : 0).append("px;");
+ style.append("left: 0px;");
+ style.append("width: ").append(padding).append("px;");
+ }
+ else
+ //if ("topleft".equals(area))
+ {
+ style.append("top: 0px;");
+ style.append("left: 0px;");
+ }
+ }
+
+ /**
+ * Get the URL to use to let this class work with the MyFaces resource handling
+ * in order to generate the image
+ *
+ * @param context The faces context
+ * @param component The component
+ * @param area The area
+ * @return The URL of the image
+ */
+ protected String getImageSource(FacesContext context,
+ HtmlRoundedDiv component, String area)
+ {
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ return addResource.getResourceUri(context,
+ new ParameterResourceHandler(this.getClass(),
+ buildParameterMap(component, area)));
+ }
+
+ /**
+ * Adds padding to the inner DIV so that the contents do not overlap
+ * the rounded corner
+ *
+ * @param padding The max of the border width and radius
+ * @param style The style
+ * @param areas The areas to render
+ */
+ protected void addPadding(int padding, StringBuffer style, Set areas)
+ {
+ int top = 0, right = 0, bottom = 0, left = 0;
+ if (areas == null || areas.contains("top"))
+ {
+ top = padding;
+ }
+ if (areas == null || areas.contains("right"))
+ {
+ right = padding;
+ }
+ if (areas == null || areas.contains("bottom"))
+ {
+ bottom = padding;
+ }
+ if (areas == null || areas.contains("left"))
+ {
+ left = padding;
+ }
+
+ style.append(" padding: ").append(top).append("px ").append(right)
+ .append("px ").append(bottom).append("px ").append(left)
+ .append("px;");
+ }
+
+ /**
+ * Build a set of parameters as a map that are needed for the rendering
+ *
+ * @param component The component
+ * @param area The area
+ * @return Map of parameters
+ */
+ protected Map buildParameterMap(HtmlRoundedDiv component, String area)
+ {
+ Map map = new HashMap(7);
+ map.put("c", colorToHtml(component.getColor()));
+ Color c;
+ if ((c = component.getBackgroundColor()) != null)
+ {
+ map.put("bgc", colorToHtml(component.getBackgroundColor()));
+ }
+ if ((c = component.getBorderColor()) != null)
+ {
+ map.put("bc", colorToHtml(component.getBorderColor()));
+ }
+
+ map.put("bw", component.getBorderWidth().toString());
+ map.put("r", component.getRadius().toString());
+ Dimension d;
+ if ((d = component.getSize()) != null)
+ {
+ map.put("s", component.getSize().width + "x"
+ + component.getSize().height);
+ }
+ if (area != null)
+ {
+ map.put("a", area);
+ }
+ map.put("i", component.getInverse().booleanValue() ? "t" : "f");
+ return map;
+ }
+
+ /**
+ * Convert a color to an HTML style color (i.e. #FFFFFF)
+ *
+ * @param c The color
+ * @return Color as hexidemal representation
+ */
+ protected String colorToHtml(Color c)
+ {
+ int rbg = c.getRGB();
+ String[] strs = { Integer.toHexString((rbg >> 16) & 0xFF),
+ Integer.toHexString((rbg >> 8) & 0xFF),
+ Integer.toHexString(rbg & 0xFF) };
+
+ StringBuffer sb = new StringBuffer("#");
+ for (int i = 0; i < strs.length; i++)
+ {
+ if (strs[i].length() == 1)
+ {
+ sb.append('0');
+ }
+ sb.append(strs[i]);
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Check if the user is using IE
+ *
+ * @param context Faces context
+ * @return True if IE
+ */
+ protected boolean isIE(FacesContext context)
+ {
+ try
+ {
+ String userAgent = context.getExternalContext()
+ .getRequestHeaderMap().get("User-Agent").toString();
+
+ return userAgent.toUpperCase().indexOf("MSIE") >= 0;
+ }
+ catch (NullPointerException ex)
+ {
+ // should never happen, but just in case
+ return false;
+ }
+ }
+
+// /**
+// * Check if the user is using IE6
+// *
+// * @param context Faces context
+// * @return True if IE
+// */
+// protected boolean isIE6(FacesContext context)
+// {
+// try
+// {
+// String userAgent = context.getExternalContext()
+// .getRequestHeaderMap().get("User-Agent").toString();
+//
+// return userAgent.toUpperCase().indexOf("MSIE 6") >= 0;
+// }
+// catch (NullPointerException ex)
+// {
+// // should never happen, but just in case
+// return false;
+// }
+// }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivRenderer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java Sat Jul 7 14:33:42 2007
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * --
+ * $Id$
+ */
+package org.apache.myfaces.custom.roundeddiv;
+
+import java.awt.Color;
+
+import javax.faces.component.UIComponent;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.custom.div.DivTag;
+
+/**
+ * The Tag implementation for the {@link HtmlRoundedDiv} component and those sorry
+ * souls using JSP instead of facelets.
+ *
+ * @author Andrew Robinson (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class HtmlRoundedDivTag extends DivTag
+{
+ private String color;
+ private String backgroundColor;
+ private String borderColor;
+ private String borderWidth;
+ private String radius;
+ private String size;
+ private String corners;
+ private String inverse;
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTagTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ return HtmlRoundedDivRenderer.RENDERER_TYPE;
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.div.DivTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return HtmlRoundedDiv.COMPONENT_TYPE;
+ }
+
+ /**
+ * @param inverse the inverse to set
+ */
+ public void setInverse(String inverse)
+ {
+ this.inverse = inverse;
+ }
+
+ /**
+ * @param backgroundColor the backgroundColor to set
+ */
+ public void setBackgroundColor(String backgroundColor)
+ {
+ this.backgroundColor = backgroundColor;
+ }
+
+ /**
+ * @param borderColor the borderColor to set
+ */
+ public void setBorderColor(String borderColor)
+ {
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @param borderWidth the borderWidth to set
+ */
+ public void setBorderWidth(String borderWidth)
+ {
+ this.borderWidth = borderWidth;
+ }
+
+ /**
+ * @param corners the corners to set
+ */
+ public void setCorners(String corners)
+ {
+ this.corners = corners;
+ }
+
+ /**
+ * @param color the color to set
+ */
+ public void setColor(String color)
+ {
+ this.color = color;
+ }
+
+ /**
+ * @param radius the radius to set
+ */
+ public void setRadius(String radius)
+ {
+ this.radius = radius;
+ }
+
+ /**
+ * @param size the size to set
+ */
+ public void setSize(String size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.div.DivTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setColorProperty(component, "color", this.color);
+ setColorProperty(component, "backgroundColor", this.backgroundColor);
+ setColorProperty(component, "borderColor", this.borderColor);
+ setIntegerProperty(component, "borderWidth", this.borderWidth);
+ setIntegerProperty(component, "radius", this.radius);
+ setStringProperty(component, "size", this.size);
+ setStringProperty(component, "corners", this.corners);
+ setBooleanProperty(component, "inverse", this.inverse);
+ }
+
+ protected void setColorProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else {
+ component.getAttributes().put(propName, Color.decode(value));
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.htmlTag.HtmlTagTag#release()
+ */
+ public void release()
+ {
+ super.release();
+ backgroundColor = null;
+ borderColor = null;
+ borderWidth = null;
+ radius = null;
+ size = null;
+ corners = null;
+ inverse = null;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/HtmlRoundedDivTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java Sat Jul 7 14:33:42 2007
@@ -0,0 +1,501 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * --
+ * $Id$
+ */
+package org.apache.myfaces.custom.roundeddiv;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Transparency;
+import java.awt.geom.Arc2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileOutputStream;
+
+import javax.imageio.ImageIO;
+
+/**
+ * Class that generates rounded images
+ *
+ * @author Andrew Robinson (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RoundedBorderGenerator
+{
+ public final static int SECTION_TOPLEFT = 1;
+ public final static int SECTION_TOP = 2;
+ public final static int SECTION_TOPRIGHT = 3;
+ public final static int SECTION_LEFT = 4;
+ public final static int SECTION_CENTER = 5;
+ public final static int SECTION_RIGHT = 6;
+ public final static int SECTION_BOTTOMLEFT = 7;
+ public final static int SECTION_BOTTOM = 8;
+ public final static int SECTION_BOTTOMRIGHT = 9;
+
+ private final static int CORNER_DEGREES = 3;
+
+ private transient BufferedImage cachedImage;
+ private int borderWidth;
+ private int cornerRadius;
+ private Color color;
+ private Color background;
+ private Color borderColor;
+ private Dimension size;
+ private boolean inverse;
+
+ /**
+ * Constructor
+ *
+ * @param borderColor Border color
+ * @param borderWidth Border width
+ * @param cornerRadius Corner radius
+ * @param color Foreground color
+ * @param background Background color
+ * @param size Image size
+ * @param inverse if the 3D border should be inverse (depressed look)
+ */
+ public RoundedBorderGenerator(Color borderColor, int borderWidth,
+ int cornerRadius, Color color, Color background, Dimension size,
+ boolean inverse)
+ {
+ this.borderWidth = borderWidth;
+ this.cornerRadius = cornerRadius;
+ this.color = color;
+ this.background = background;
+ this.borderColor = borderColor;
+ this.size = size;
+ this.inverse = inverse;
+ }
+
+ public void dispose()
+ {
+ cachedImage = null;
+ }
+
+ /**
+ * @return the inverse
+ */
+ public boolean isInverse()
+ {
+ return this.inverse;
+ }
+
+ /**
+ * @return the background
+ */
+ public Color getBackground()
+ {
+ return this.background;
+ }
+
+ /**
+ * @return the borderColor
+ */
+ public Color getBorderColor()
+ {
+ return this.borderColor;
+ }
+
+ /**
+ * @return the borderWidth
+ */
+ public int getBorderWidth()
+ {
+ return this.borderWidth;
+ }
+
+ /**
+ * @return the color
+ */
+ public Color getColor()
+ {
+ return this.color;
+ }
+
+ /**
+ * @return the cornerRadius
+ */
+ public int getCornerRadius()
+ {
+ return this.cornerRadius;
+ }
+
+ /**
+ * @return the size
+ */
+ public Dimension getSize()
+ {
+ return this.size;
+ }
+
+ public BufferedImage createImageSection(int section)
+ {
+ BufferedImage img = createImage();
+
+ int max = Math.max(borderWidth, cornerRadius);
+
+ int x, y;
+ switch (section)
+ {
+ case SECTION_CENTER:
+ x = y = max;
+ break;
+ case SECTION_TOPLEFT:
+ x = y = 0;
+ break;
+ case SECTION_TOP:
+ x = max;
+ y = 0;
+ break;
+ case SECTION_TOPRIGHT:
+ x = img.getWidth() - max;
+ y = 0;
+ break;
+ case SECTION_RIGHT:
+ x = img.getWidth() - max;
+ y = max;
+ break;
+ case SECTION_BOTTOMRIGHT:
+ x = img.getWidth() - max;
+ y = img.getHeight() - max;
+ break;
+ case SECTION_BOTTOM:
+ x = max;
+ y = img.getHeight() - max;
+ break;
+ case SECTION_BOTTOMLEFT:
+ x = 0;
+ y = img.getHeight() - max;
+ break;
+ case SECTION_LEFT:
+ default:
+ x = 0;
+ y = max;
+ break;
+ }
+
+ return img.getSubimage(x, y, max, max);
+ }
+
+ public BufferedImage createImage()
+ {
+ if (cachedImage != null)
+ return cachedImage;
+
+ // create the canvas image
+ int w, h;
+ if (size != null)
+ {
+ w = (int) size.getWidth();
+ h = (int) size.getHeight();
+ }
+ else
+ {
+ h = w = Math.max(borderWidth, cornerRadius) * 3;
+ }
+
+ BufferedImage canvas = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g = canvas.createGraphics();
+ Graphics2D g2 = null;
+
+ try
+ {
+ // either paint the background of the image, or set it to transparent
+ paintBackground(g, w, h);
+
+ RoundRectangle2D shape = new RoundRectangle2D.Float(0f, 0f, w, h,
+ cornerRadius * 2, cornerRadius * 2);
+
+ BufferedImage shapedImage = createImageForShape(g, shape);
+ g2 = shapedImage.createGraphics();
+
+ fillForeground(g2, shape);
+
+ // 3D or 2D?
+ if (borderColor == null)
+ create3DImage(g2, shape);
+ else
+ create2DImage(g2, shape);
+
+ g.drawImage(shapedImage, 0, 0, null);
+
+ cachedImage = canvas;
+ return canvas;
+ }
+ finally
+ {
+ if (g2 != null)
+ try
+ {
+ g2.dispose();
+ }
+ catch (Exception ex)
+ {
+ }
+ g.dispose();
+ }
+ }
+
+ private BufferedImage createImageForShape(Graphics2D g,
+ RoundRectangle2D shape)
+ {
+ int w = shape.getBounds().width;
+ int h = shape.getBounds().height;
+
+ BufferedImage img = g.getDeviceConfiguration().createCompatibleImage(w,
+ h, Transparency.TRANSLUCENT);
+ Graphics2D g2 = img.createGraphics();
+
+ try
+ {
+ // Clear the image so all pixels have zero alpha
+ g2.setComposite(AlphaComposite.Clear);
+ g2.fillRect(0, 0, w, h);
+
+ // Render our clip shape into the image. Note that we enable
+ // antialiasing to achieve the soft clipping effect. Try
+ // commenting out the line that enables antialiasing, and
+ // you will see that you end up with the usual hard clipping.
+ g2.setComposite(AlphaComposite.Src);
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setColor(Color.WHITE);
+ g2.fill(shape);
+ }
+ finally
+ {
+ g2.dispose();
+ }
+
+ return img;
+ }
+
+ private void paintBackground(Graphics2D g, int width, int height)
+ {
+ // treat a null background as fully transparent
+ if (background == null)
+ {
+ BufferedImage img = g.getDeviceConfiguration()
+ .createCompatibleImage(width, height,
+ Transparency.TRANSLUCENT);
+ Graphics2D g2 = img.createGraphics();
+
+ // Clear the image so all pixels have zero alpha
+ g2.setComposite(AlphaComposite.Clear);
+ g2.fillRect(0, 0, width, height);
+
+ g2.dispose();
+ }
+ else
+ {
+ g.setColor(background);
+ g.fillRect(0, 0, width, height);
+ }
+ }
+
+ private void fillForeground(Graphics2D g, RoundRectangle2D shape)
+ {
+ // use anti-aliasing, looks like garbage without it
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setComposite(AlphaComposite.SrcAtop);
+ g.setPaint(color);
+ g.fill(shape);
+ }
+
+ /**
+ * Create a 3D lighting effect using the "computer standard" light from the upper left
+ */
+ private void create3DImage(Graphics2D g, RoundRectangle2D shape)
+ {
+ int w = (int) shape.getWidth();
+ int h = (int) shape.getHeight();
+
+ // Create a 3D lighting effect on the border of the rectangle
+ float factor = .3f;
+ Color lighter = lighter(color, factor);
+ Color darker = darker(color, factor);
+
+ // top-left
+ g.setClip(new Polygon(new int[] { 0, w, 0 }, new int[] { 0, 0, h }, 3));
+ paint3DBorder(g, inverse ? darker : lighter, shape);
+
+ // bottom-right
+ g.setClip(new Polygon(new int[] { 0, w, w }, new int[] { h, 0, h }, 3));
+ paint3DBorder(g, inverse ? lighter : darker, shape);
+
+ // create a transition at the top-right and bottom-left colors to blend
+ // where the darker & lighter colors meet
+ g.setClip(null);
+ int corner = Math.max(borderWidth, cornerRadius);
+ paint3DBorderTransition(g, inverse ? darker : lighter,
+ inverse ? lighter : darker, w - corner * 2, 0, true);
+ paint3DBorderTransition(g, inverse ? darker : lighter,
+ inverse ? lighter : darker, 0, h - corner * 2, false);
+ g.setClip(null);
+ }
+
+ private void paint3DBorderTransition(Graphics2D g, Color c1, Color c2,
+ int x, int y, boolean upperLeft)
+ {
+ // starting with a double-width stroke, use an algorithm that stays closer to the
+ // middle color at first and then increasingly approaches outside (lighter or darker)
+ // towards the end to simulate the light increasing or fading at the edges
+ // (the image will clip any content outside of its bounds, so half of each stroke is lost)
+ int width = borderWidth * 2;
+ int size = Math.max(borderWidth, cornerRadius);
+
+ int startAngle = upperLeft ? 0 : 180;
+
+ for (int i = 0; i < 90; i += CORNER_DEGREES)
+ {
+ Color outerColor = combineColors(c1, c2, (upperLeft ? i : 90 - i) / 90f);
+ g.setClip(new Arc2D.Float(x, y, size * 2, size * 2,
+ startAngle + i, CORNER_DEGREES, Arc2D.PIE));
+ paint3DBorder(g, outerColor, new Arc2D.Float(x, y, size * 2, size * 2,
+ startAngle + i, CORNER_DEGREES, Arc2D.OPEN));
+ }
+ }
+
+ private void paint3DBorder(Graphics2D g, Color c, Shape shape)
+ {
+ // starting with a double-width stroke, use an algorithm that stays closer to the
+ // middle color at first and then increasingly approaches outside (lighter or darker)
+ // towards the end to simulate the light increasing or fading at the edges
+ // (the image will clip any content outside of its bounds, so half of each stroke is lost)
+ int width = borderWidth * 2;
+ for (float i = 0; i <= width; i += 1)
+ {
+ float percent = (float) Math.pow((i / width), 3);
+ g.setPaint(combineColors(c, color, percent));
+ g.setStroke(new BasicStroke(width - i));
+ g.draw(shape);
+ }
+ }
+
+ private void create2DImage(Graphics2D g, RoundRectangle2D shape)
+ {
+ if (borderWidth == 0)
+ return;
+ // put the border inside the shape
+ RoundRectangle2D borderShape = new RoundRectangle2D.Float(0f, 0f,
+ (float) shape.getWidth() - 1, (float) shape.getHeight() - 1,
+ cornerRadius * 2, cornerRadius * 2);
+
+ g.setStroke(new BasicStroke(borderWidth));
+ g.setColor(borderColor);
+ g.draw(borderShape);
+ }
+
+ /**
+ * Averages the red, green, blue and alpha of two colors
+ */
+ private Color combineColors(Color c1, Color c2, float weight)
+ {
+ float r = c1.getRed() * weight + c2.getRed() * (1 - weight);
+ float g = c1.getGreen() * weight + c2.getGreen() * (1 - weight);
+ float b = c1.getBlue() * weight + c2.getBlue() * (1 - weight);
+ float a = c1.getAlpha() * weight + c2.getAlpha() * (1 - weight);
+ return new Color((int) r, (int) g, (int) b, (int) a);
+ }
+
+ /**
+ * Similar to {@link Color#brighter()}, but this method lightens by bringing the color
+ * closer to white (not just making it brighter) by using a custom factor (instead of 0.7)
+ *
+ * @param c the color to lighten
+ * @param factor the factor to use (between 0 and 1)
+ * @return the lighter color
+ */
+ private Color lighter(Color c, float factor)
+ {
+ return new Color(Math
+ .min((int) (Math.max(c.getRed(), 50) / factor), 255), Math.min(
+ (int) (Math.max(c.getGreen(), 50) / factor), 255), Math.min(
+ (int) (Math.max(c.getBlue(), 50) / factor), 255));
+ }
+
+ /**
+ * Like {@link Color#darker()}, this method darkens a color, but with a custom factor
+ * (instead of 0.7)
+ *
+ * @param c the color to darken
+ * @param factor the factor to use (between 0 and 1)
+ * @return the darker color
+ */
+ private Color darker(Color c, float factor)
+ {
+ return new Color(Math.max((int) (c.getRed() * factor), 0), Math.max(
+ (int) (c.getGreen() * factor), 0), Math.max(
+ (int) (c.getBlue() * factor), 0));
+ }
+
+ public static void main(String[] args)
+ {
+ FileOutputStream fos = null;
+
+ try
+ {
+ File file;
+ if (args.length == 1)
+ {
+ file = new File(args[0]);
+ }
+ else
+ {
+ file = File.createTempFile("tmp_", ".png");
+ }
+
+ RoundedBorderGenerator rbg = new RoundedBorderGenerator(null, 10,
+ 10, Color.GRAY, null, new Dimension(120,
+ 60), false);
+ fos = new FileOutputStream(file);
+
+ ImageIO.write(rbg.createImage(), "png", fos);
+
+ System.out.println("written to " + file.getAbsolutePath());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.exit(1);
+ }
+ finally
+ {
+ if (fos != null)
+ {
+ try
+ {
+ fos.close();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/roundeddiv/RoundedBorderGenerator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?view=diff&rev=554270&r1=554269&r2=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Sat Jul 7 14:33:42 2007
@@ -283,6 +283,11 @@
<component-type>org.apache.myfaces.UILimitRendered</component-type>
<component-class>org.apache.myfaces.custom.limitrendered.UILimitRendered</component-class>
</component>
+
+ <component>
+ <component-type>org.apache.myfaces.HtmlRoundedDiv</component-type>
+ <component-class>org.apache.myfaces.custom.roundeddiv.HtmlRoundedDiv</component-class>
+ </component>
<!-- sandbox converters -->
@@ -601,7 +606,13 @@
<component-family>javax.faces.Command</component-family>
<renderer-type>org.apache.myfaces.Button</renderer-type>
<renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlButtonExRenderer</renderer-class>
- </renderer>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.Output</component-family>
+ <renderer-type>org.apache.myfaces.HtmlRoundedDiv</renderer-type>
+ <renderer-class>org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivRenderer</renderer-class>
+ </renderer>
</render-kit>
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/resource/blank.gif
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/resource/blank.gif?view=auto&rev=554270
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/roundeddiv/resource/blank.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml Sat Jul 7 14:33:42 2007
@@ -0,0 +1,93 @@
+<!-- HtmlRoundedDiv attributes -->
+<attribute>
+ <name>style</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The style to use for this div.
+ </description>
+</attribute>
+<attribute>
+ <name>styleClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The class to use for this div.
+ </description>
+</attribute>
+<attribute>
+ <name>backgroundColor</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ Background color to give the corners. Leave blank (null)
+ to have a transparent background. If the user is using IE6, this has to be set,
+ or the corners will not look good due to IE6's lack of PNG support.
+ </description>
+</attribute>
+<attribute>
+ <name>borderColor</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The color of the border. If specified, this will cause the DIV
+ to be 2D, if it isn't the border with have a 3D effect with
+ lighting effects to produce the border color.
+ </description>
+</attribute>
+<attribute>
+ <name>borderWidth</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The width of the border in pixels. (Default: 8)
+ </description>
+</attribute>
+<attribute>
+ <name>color</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The foreground color of the DIV
+ </description>
+</attribute>
+<attribute>
+ <name>corners</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ This allows you to specify a comma-separated list of corners to
+ include. If not given, all four corners will be rendered. The corners
+ include the sides they touch. So for example, if used as a tab for a
+ tabbed pane, you could specify "topleft,topright" to have everything
+ but the bottom corners and side have the border. Valid values are:
+ topleft, topright, bottomright, bottomleft
+ </description>
+</attribute>
+<attribute>
+ <name>radius</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The radius of the corners in pixels. (Default: 8)
+ </description>
+</attribute>
+<attribute>
+ <name>size</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ If given, a static size image will be produced. This could be
+ useful for older browsers. If not given, the DIV that will be created
+ will stretch to its contents using CSS2 (and CSS expressions in IE6).
+ Value must contain two numbers, with width first. Example: 640x480
+ </description>
+</attribute>
+<attribute>
+ <name>inverse</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ Flips the lightening/darkening effect for 3D borders. (Default: false)
+ </description>
+</attribute>
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_roundeddiv_attributes.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?view=diff&rev=554270&r1=554269&r2=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sat Jul 7 14:33:42 2007
@@ -148,6 +148,7 @@
<!ENTITY html_imageloopitems_attributes SYSTEM "entities/html_imageloopitems_attributes.xml">
<!ENTITY validation_script_attributes SYSTEM "entities/validation_script_attributes.xml">
<!ENTITY ui_limitRendered_attributes SYSTEM "entities/ui_limitRendered_attributes.xml">
+<!ENTITY html_roundeddiv_attributes SYSTEM "entities/html_roundeddiv_attributes.xml">
]>
<taglib>
@@ -1676,5 +1677,17 @@
&ui_component_attributes;
&ui_limitRendered_attributes;
</tag>
-
+
+ <tag>
+ <name>roundedDiv</name>
+ <tag-class>org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Component that allows for a rounded border effect on DIV tags that is supported
+ in CSS2 compatible browsers and IE6.
+ </description>
+ &ui_component_attributes;
+ &user_role_attributes;
+ &html_roundeddiv_attributes;
+ </tag>
</taglib>
Added: myfaces/tomahawk/trunk/sandbox/core/src/site/apt/roundedDiv.apt
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/site/apt/roundedDiv.apt?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/site/apt/roundedDiv.apt (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/site/apt/roundedDiv.apt Sat Jul 7 14:33:42 2007
@@ -0,0 +1,88 @@
+~~~~~~~~~~~~~~~~~~~~
+Description
+
+ The <<<roundedDiv>>> component creates a DIV tag that contains images to
+ produce rounded corners. The rounded effect can be either 3D with lighting effects
+ or 2D with a solid color border.
+
+~~~~~~~~~~~~~~~~~~~~
+Screen Shot
+
+[images/roundedDiv.png]
+
+~~~~~~~~~~~~~~~~~~~~
+API
+
+*--+--+
+component-family | javax.faces.Output
+*--+--+
+component-type | org.apache.myfaces.HtmlRoundedDiv
+*--+--+
+component-class | org.apache.myfaces.custom.roundeddiv.HtmlRoundedDiv
+*--+--+
+renderer-type | org.apache.myfaces.HtmlRoundedDiv
+*--+--+
+renderer-class | org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivRenderer
+*--+--+
+tag-class | org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivTag
+*--+--+
+
+~~~~~~~~~~~~~~~~~~~~
+Usage
+
++--------+
+<s:roundedDiv
+ id="String"
+ binding="EL"
+ rendered="Boolean"
+ backgroundColor="Color|HEX Color String"
+ borderColor="Color|HEX Color String"
+ color="Color|HEX Color String"
+ borderWidth="Integer"
+ radius="Integer"
+ size="Dimension|String"
+ corners="String"
+ inverse="Boolean">
+ ...Contents...
+</s:roundedDiv>
++--------+
+
+~~~~~~~~~~~~~~~~~~~~
+Syntax
+
+* \<s:roundedDiv /\>
+
+ <<<backgroundColor>>> - The background color of the corners. If null, a transparent
+ background is used. Supports <<<java.awt.Color>>> instance or <<<String>>> parsable by
+ <<<java.awt.Color.decode(String)>>>. If the user is using IE6, this has to be set,
+ or the corners will not look good due to IE6's lack of PNG support. (Default: null)
+
+ <<<borderColor>>> - If set, a 2D border with this solid color will be used as the border.
+ If null, a 3D border will be created. Supports <<<java.awt.Color>>> instance or
+ <<<String>>> parsable by <<<java.awt.Color.decode(String)>>>. (Default: null)
+
+ <<<color>>> (Required) - The foreground color. Supports <<<java.awt.Color>>> instance or
+ <<<String>>> parsable by <<<java.awt.Color.decode(String)>>>.
+
+ <<<borderWidth>>> - For 2D border, the size of the border in pixels, for 3D, the size
+ of the area of the lighting effect in pixels. Supports <<<Integer>>> or
+ <<<String>>> parsable by <<<Integer.parseInt(String)>>>. (Default: 8)
+
+ <<<radius>>> - The radius of the corners in pixels. Supports <<<Integer>>> or
+ <<<String>>> parsable by <<<Integer.parseInt(String)>>>. (Default: 8)
+
+ <<<size>>> - If given, a static size image will be produced. This could be
+ useful for older browsers. If not given, the DIV that will be created
+ will stretch to its contents using CSS2 (and CSS expressions in IE6).
+ Supports <<<java.awt.Dimension>>> or <<<String>>> that consists
+ of 2 numbers (typical format: WxH. Example: 640x480). (Default: null)
+
+ <<<corners>>> - This allows you to specify a comma-separated list of corners to
+ include. If not given, all four corners will be rendered. The corners
+ include the sides they touch. So for example, if used as a tab for a
+ tabbed pane, you could specify "topleft,topright" to have everything
+ but the bottom corners and side have the border. Valid values are:
+ topleft, topright, bottomright, bottomleft. (Default: null)
+
+ <<<inverse>>> - Flips the lightening/darkening effect for 3D borders.
+ (Default: false)
\ No newline at end of file
Added: myfaces/tomahawk/trunk/sandbox/core/src/site/resources/images/roundedDiv.png
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/site/resources/images/roundedDiv.png?view=auto&rev=554270
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/site/resources/images/roundedDiv.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Modified: myfaces/tomahawk/trunk/sandbox/core/src/site/site.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/site/site.xml?view=diff&rev=554270&r1=554269&r2=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/site/site.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/site/site.xml Sat Jul 7 14:33:42 2007
@@ -45,6 +45,7 @@
<item name="ExcelExport" href="excelexport.html"/>
<item name="SecurityContext" href="securityContext.html"/>
<item name="Limit Rendered" href="limitRendered.html"/>
+ <item name="Rounded DIV" href="roundedDiv.html"/>
</menu>
<menu name="Converters">
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java Sat Jul 7 14:33:42 2007
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * --
+ * $Id$
+ */
+package org.apache.myfaces.examples.roundeddiv;
+
+import java.io.Serializable;
+
+import javax.faces.event.ActionEvent;
+
+/**
+ * Backing bean for the rounded div example.
+ *
+ * @author Andrew Robinson (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RoundedDivBean implements Serializable
+{
+ private String borderWidth = "8";
+ private String radius = "8";
+ private String borderColor = null;
+ private String backgroundColor = null;
+ private String color = "#CCCCCC";
+ private String corners = null;
+ private String size = null;
+ private String height = "100px";
+ private String width = "200px";
+
+ public String getHeight()
+ {
+ return this.height;
+ }
+
+ public void setHeight(String height)
+ {
+ this.height = height;
+ }
+
+ public String getWidth()
+ {
+ return this.width;
+ }
+
+ public void setWidth(String width)
+ {
+ this.width = width;
+ }
+
+ public String getBackgroundColor()
+ {
+ return this.backgroundColor;
+ }
+
+ public void setBackgroundColor(String backgroundColor)
+ {
+ this.backgroundColor = backgroundColor;
+ }
+
+ public String getBorderColor()
+ {
+ return this.borderColor;
+ }
+
+ public void setBorderColor(String borderColor)
+ {
+ this.borderColor = borderColor;
+ }
+
+ public String getBorderWidth()
+ {
+ return this.borderWidth;
+ }
+
+ public void setBorderWidth(String borderWidth)
+ {
+ this.borderWidth = borderWidth;
+ }
+
+ public String getColor()
+ {
+ return this.color;
+ }
+
+ public void setColor(String color)
+ {
+ this.color = color;
+ }
+
+ public String getCorners()
+ {
+ return this.corners;
+ }
+
+ public void setCorners(String corners)
+ {
+ this.corners = corners;
+ }
+
+ public String getRadius()
+ {
+ return this.radius;
+ }
+
+ public void setRadius(String radius)
+ {
+ this.radius = radius;
+ }
+
+ public String getSize()
+ {
+ return this.size;
+ }
+
+ public void setSize(String size)
+ {
+ if ("".equals(size))
+ {
+ size = null;
+ }
+ this.size = size;
+ }
+
+ public void reset(ActionEvent evt)
+ {
+ borderWidth = "8";
+ radius = "8";
+ borderColor = null;
+ backgroundColor = null;
+ color = "#CCCCCC";
+ corners = null;
+ size = null;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/roundeddiv/RoundedDivBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml?view=diff&rev=554270&r1=554269&r2=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml Sat Jul 7 14:33:42 2007
@@ -544,6 +544,13 @@
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+ <!-- managed bean for roundedDiv -->
+ <managed-bean>
+ <managed-bean-name>roundedDiv</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.examples.roundeddiv.RoundedDivBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
<!-- navigation rules -->
<navigation-rule>
<navigation-case>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?view=diff&rev=554270&r1=554269&r2=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Sat Jul 7 14:33:42 2007
@@ -175,6 +175,14 @@
</h:outputLink>
</h:panelGrid>
+ <h:outputText value="Rounded DIV"/>
+ <h:panelGrid style="padding-left:25px">
+ <h:outputLink value="roundedDiv.jsf" >
+ <f:verbatim>Rounded DIV - DIV with rounded corners</f:verbatim>
+ </h:outputLink>
+ </h:panelGrid>
+
+
<f:verbatim><br/><br/><br/><br/><br/><br/><br/></f:verbatim>
</h:form>
</f:view>
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp?view=auto&rev=554270
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp Sat Jul 7 14:33:42 2007
@@ -0,0 +1,137 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+<html>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//-->
+
+<%@include file="inc/head.inc" %>
+
+<body>
+<f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:panelGrid columns="2" style="border: 1px double black;">
+ <f:facet name="header">
+ <h:outputText value="Attributes" />
+ </f:facet>
+ <h:outputText value="Color:" />
+ <h:panelGroup>
+ <h:inputText id="Color"
+ value="#{roundedDiv.color}"
+ required="true" />
+ <t:message for="Color" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Background color:" />
+ <h:panelGroup>
+ <h:inputText id="BackgroundColor"
+ value="#{roundedDiv.backgroundColor}" />
+ <t:message for="BackgroundColor" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Border color:" />
+ <h:panelGroup>
+ <h:inputText id="BorderColor"
+ value="#{roundedDiv.borderColor}" />
+ <t:message for="BorderColor" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Border width:" />
+ <h:panelGroup>
+ <h:inputText id="BorderWidth"
+ value="#{roundedDiv.borderWidth}" />
+ <t:message for="BorderWidth" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Radius:" />
+ <h:panelGroup>
+ <h:inputText id="Radius"
+ value="#{roundedDiv.radius}" />
+ <t:message for="Radius" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Corners:" />
+ <h:panelGroup>
+ <h:inputText id="Corners"
+ value="#{roundedDiv.corners}" />
+ <t:message for="Corners" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="Size:" />
+ <h:panelGroup>
+ <h:inputText id="Size"
+ value="#{roundedDiv.size}" />
+ <t:message for="Size" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="DIV width:" />
+ <h:panelGroup>
+ <h:inputText id="Width"
+ value="#{roundedDiv.width}" />
+ <t:message for="Width" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <h:outputText value="DIV height:" />
+ <h:panelGroup>
+ <h:inputText id="Height"
+ value="#{roundedDiv.height}" />
+ <t:message for="Height" errorStyle="color: red;"
+ fatalStyle="color: red;" replaceIdWithLabel="true"
+ tooltip="true" warnStyle="color: orange;" />
+ </h:panelGroup>
+ <f:facet name="footer">
+ <h:panelGroup>
+ <h:commandButton value="Update" />
+ <h:commandButton value="Reset" actionListener="#{roundedDiv.reset}" />
+ </h:panelGroup>
+ </f:facet>
+ </h:panelGrid>
+ <s:roundedDiv
+ backgroundColor="#{roundedDiv.backgroundColor}"
+ borderColor="#{roundedDiv.borderColor}"
+ borderWidth="#{roundedDiv.borderWidth}"
+ color="#{roundedDiv.color}"
+ corners="#{roundedDiv.corners}"
+ radius="#{roundedDiv.radius}"
+ size="#{roundedDiv.size}"
+ style="height: #{roundedDiv.height}; width: #{roundedDiv.width};">
+ <h:outputText value="Contents" />
+ </s:roundedDiv>
+ </h:panelGrid>
+ </h:form>
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+</html>
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/roundedDiv.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL