org.apache.myfaces.custom.roundeddiv
Class HtmlRoundedDivRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer
          extended by org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
              extended by org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivRenderer
All Implemented Interfaces:
org.apache.myfaces.renderkit.html.util.ResourceLoader

public class HtmlRoundedDivRenderer
extends org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
implements org.apache.myfaces.renderkit.html.util.ResourceLoader

Renderer for the HtmlRoundedDiv component.

Version:
$Revision: 700624 $ $Date: 2008-09-30 18:04:29 -0500 (Tue, 30 Sep 2008) $
Author:
Andrew Robinson (latest modification by $Author: lu4242 $)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.myfaces.renderkit.html.util.ResourceLoader
org.apache.myfaces.renderkit.html.util.ResourceLoader.ClosedSocketException
 
Field Summary
static java.lang.String RENDERER_TYPE
           
 
Constructor Summary
HtmlRoundedDivRenderer()
           
 
Method Summary
protected  java.awt.Dimension _getSize(HtmlRoundedDiv component)
           
protected  void addImage(javax.faces.context.ResponseWriter writer, javax.faces.context.FacesContext context, HtmlRoundedDiv component, java.lang.String area, java.util.Set areas, boolean ie)
          Adds an IMG tag to the response for an image
protected  void addPadding(int padding, java.lang.StringBuffer style, java.util.Set areas)
          Adds padding to the inner DIV so that the contents do not overlap the rounded corner
protected  RoundedBorderGenerator buildGenerator(javax.servlet.http.HttpServletRequest request)
           
protected  java.util.Map buildParameterMap(HtmlRoundedDiv component, java.lang.String area)
          Build a set of parameters as a map that are needed for the rendering
protected  java.lang.String colorToHtml(java.awt.Color c)
          Convert a color to an HTML style color (i.e.
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeContentColumn(javax.faces.context.ResponseWriter writer, javax.faces.context.FacesContext context, HtmlRoundedDiv component, java.util.Set areas, boolean ie)
           
protected  void encodeDivBegin(javax.faces.context.FacesContext context, boolean ie, HtmlRoundedDiv div, javax.faces.context.ResponseWriter writer, java.util.Set areas)
           
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeImageColumn(javax.faces.context.ResponseWriter writer, javax.faces.context.FacesContext context, HtmlRoundedDiv component, java.lang.String area, java.util.Set areas, int padding, boolean ie)
           
protected  void encodeTable(javax.faces.context.FacesContext context, boolean ie, HtmlRoundedDiv div, javax.faces.context.ResponseWriter writer, java.util.Set areas)
           
protected  int getAreaAsSection(java.lang.String area)
          Convert the string area to one of the integer constants from RoundedBorderGenerator
protected  java.util.Set getAreasToRender(javax.faces.context.FacesContext context, HtmlRoundedDiv component)
          Get the areas to render.
protected  java.lang.String getCacheKey(java.lang.String queryString)
           
protected  java.lang.String getImageSource(javax.faces.context.FacesContext context, HtmlRoundedDiv component, java.lang.String area)
          Get the URL to use to let this class work with the MyFaces resource handling in order to generate the image
 boolean getRendersChildren()
           
protected  RoundedBorderGenerator initCachedGenerator(javax.servlet.http.HttpServletRequest request, java.lang.String cacheKey)
           
protected  boolean isIE(javax.faces.context.FacesContext context)
          Check if the user is using IE
 void serveResource(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String resourceUri)
           
protected  void setCssPosition(int padding, java.lang.StringBuffer style, java.lang.String area, java.util.Set areas)
          Set the CSS position using CSS2 attributes
protected  void setIECssPosition(int padding, java.lang.StringBuffer style, java.lang.String area, java.util.Set areas)
          Set the CSS positioning attributes for IE6
 
Methods inherited from class org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
getParameterMap
 
Methods inherited from class org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer
getActionUrl, getChildCount, getChildren, getClientId, renderId, shouldRenderId, toUri
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, decode, getConvertedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RENDERER_TYPE

public static final java.lang.String RENDERER_TYPE
See Also:
Constant Field Values
Constructor Detail

HtmlRoundedDivRenderer

public HtmlRoundedDivRenderer()
Method Detail

serveResource

public void serveResource(javax.servlet.ServletContext context,
                          javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          java.lang.String resourceUri)
                   throws java.io.IOException
Specified by:
serveResource in interface org.apache.myfaces.renderkit.html.util.ResourceLoader
Throws:
java.io.IOException
See Also:
ResourceLoader.serveResource( javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)

initCachedGenerator

protected RoundedBorderGenerator initCachedGenerator(javax.servlet.http.HttpServletRequest request,
                                                     java.lang.String cacheKey)
Parameters:
request -
cacheKey -
Returns:

buildGenerator

protected RoundedBorderGenerator buildGenerator(javax.servlet.http.HttpServletRequest request)

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws java.io.IOException
Overrides:
encodeBegin in class org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
Throws:
java.io.IOException
See Also:
HtmlTagRenderer.encodeBegin( javax.faces.context.FacesContext, javax.faces.component.UIComponent)

encodeDivBegin

protected void encodeDivBegin(javax.faces.context.FacesContext context,
                              boolean ie,
                              HtmlRoundedDiv div,
                              javax.faces.context.ResponseWriter writer,
                              java.util.Set areas)
                       throws java.io.IOException
Throws:
java.io.IOException

encodeTable

protected void encodeTable(javax.faces.context.FacesContext context,
                           boolean ie,
                           HtmlRoundedDiv div,
                           javax.faces.context.ResponseWriter writer,
                           java.util.Set areas)
                    throws java.io.IOException
Throws:
java.io.IOException

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws java.io.IOException
Overrides:
encodeChildren in class org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
Throws:
java.io.IOException
See Also:
Renderer.encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component)
               throws java.io.IOException
Overrides:
encodeEnd in class org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
Throws:
java.io.IOException
See Also:
HtmlTagRenderer.encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)

getRendersChildren

public boolean getRendersChildren()
Overrides:
getRendersChildren in class org.apache.myfaces.custom.htmlTag.HtmlTagRenderer
See Also:
Renderer.getRendersChildren()

getAreaAsSection

protected int getAreaAsSection(java.lang.String area)
Convert the string area to one of the integer constants from RoundedBorderGenerator

Parameters:
area - the area as a string
Returns:
integer constant value

getAreasToRender

protected java.util.Set getAreasToRender(javax.faces.context.FacesContext context,
                                         HtmlRoundedDiv component)
Get the areas to render. This takes into account the corners that the user has requested to be rendered.

Parameters:
context - FacesContext
component - The component
Returns:
A set of strings containing the areas to render

addImage

protected void addImage(javax.faces.context.ResponseWriter writer,
                        javax.faces.context.FacesContext context,
                        HtmlRoundedDiv component,
                        java.lang.String area,
                        java.util.Set areas,
                        boolean ie)
                 throws java.io.IOException
Adds an IMG tag to the response for an image

Parameters:
writer - The response writer
context - The faces context
component - The component
area - The area of the image
areas - All the areas to be rendered
ie - If the browser is IE
Throws:
java.io.IOException - when writing to the writer

setIECssPosition

protected void setIECssPosition(int padding,
                                java.lang.StringBuffer style,
                                java.lang.String area,
                                java.util.Set areas)
Set the CSS positioning attributes for IE6

Parameters:
padding - The size of the image section
style - The current style
area - The area
areas - All the areas to be rendered

encodeContentColumn

protected void encodeContentColumn(javax.faces.context.ResponseWriter writer,
                                   javax.faces.context.FacesContext context,
                                   HtmlRoundedDiv component,
                                   java.util.Set areas,
                                   boolean ie)
                            throws java.io.IOException
Throws:
java.io.IOException

encodeImageColumn

protected void encodeImageColumn(javax.faces.context.ResponseWriter writer,
                                 javax.faces.context.FacesContext context,
                                 HtmlRoundedDiv component,
                                 java.lang.String area,
                                 java.util.Set areas,
                                 int padding,
                                 boolean ie)
                          throws java.io.IOException
Throws:
java.io.IOException

setCssPosition

protected void setCssPosition(int padding,
                              java.lang.StringBuffer style,
                              java.lang.String area,
                              java.util.Set areas)
Set the CSS position using CSS2 attributes

Parameters:
padding - The size of the image section
style - The current style
area - The area
areas - All the areas to be rendered

getImageSource

protected java.lang.String getImageSource(javax.faces.context.FacesContext context,
                                          HtmlRoundedDiv component,
                                          java.lang.String area)
Get the URL to use to let this class work with the MyFaces resource handling in order to generate the image

Parameters:
context - The faces context
component - The component
area - The area
Returns:
The URL of the image

addPadding

protected void addPadding(int padding,
                          java.lang.StringBuffer style,
                          java.util.Set areas)
Adds padding to the inner DIV so that the contents do not overlap the rounded corner

Parameters:
padding - The max of the border width and radius
style - The style
areas - The areas to render

_getSize

protected java.awt.Dimension _getSize(HtmlRoundedDiv component)

buildParameterMap

protected java.util.Map buildParameterMap(HtmlRoundedDiv component,
                                          java.lang.String area)
Build a set of parameters as a map that are needed for the rendering

Parameters:
component - The component
area - The area
Returns:
Map of parameters

colorToHtml

protected java.lang.String colorToHtml(java.awt.Color c)
Convert a color to an HTML style color (i.e. FFFFFF)

Parameters:
c - The color
Returns:
Color as hexidemal representation

isIE

protected boolean isIE(javax.faces.context.FacesContext context)
Check if the user is using IE

Parameters:
context - Faces context
Returns:
True if IE

getCacheKey

protected java.lang.String getCacheKey(java.lang.String queryString)


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.