info.magnolia.cms.taglibs.util
Class BaseImageTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by info.magnolia.cms.taglibs.util.BaseImageTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag
Direct Known Subclasses:
ScaleImageTag, TextToImageTag

public abstract class BaseImageTag
extends javax.servlet.jsp.tagext.SimpleTagSupport

A base class for image related tags e.g. ScaleImageTag.

Author:
Fabrizio Giustina

Field Summary
protected  String imageContentNodeName
          Attribute: The name of the new content node to create.
protected  String parentContentNodeName
          Attribute: The node where the images are to be saved.
protected static String PROPERTIES_CONTENTTYPE_VALUE
          The valye of the contentType nodeData in the properties node.
protected static String PROPERTIES_EXTENSION_VALUE
          The value of the extension nodeData in the properties node.
 
Constructor Summary
BaseImageTag()
           
 
Method Summary
 Color convertHexToColor(String hex)
           
 int[] convertHexToRGB(String hex)
          Converts HEX color to RGB color.
 String convertToSimpleString(String string)
          Replace any special characters that are not letters or numbers with a replacement string.
protected  void createImageNode(File imageFile, Content imageNode)
          Create a new imageNode with the image in it.
protected abstract  String getFilename()
           
protected  Content getImageContentNode()
           
protected  javax.servlet.http.HttpServletRequest getRequest()
           
 void setImageContentNodeName(String imageContentNodeName)
          Setter for the imageContentNodeName tag attribute.
 void setParentContentNodeName(String parentContentNodeName)
          Setter for the parentContentNodeName tag attribute.
 
Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport
doTag, findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_EXTENSION_VALUE

protected static final String PROPERTIES_EXTENSION_VALUE
The value of the extension nodeData in the properties node.

See Also:
Constant Field Values

PROPERTIES_CONTENTTYPE_VALUE

protected static final String PROPERTIES_CONTENTTYPE_VALUE
The valye of the contentType nodeData in the properties node.

See Also:
Constant Field Values

parentContentNodeName

protected String parentContentNodeName
Attribute: The node where the images are to be saved. If null, the default will be the current active page.


imageContentNodeName

protected String imageContentNodeName
Attribute: The name of the new content node to create. The images will be saved under this node. If this name starts with a '/', it will be assumed to be a node handle that is relative to the rooot of the website. Otherwise, it is assumed to be a path relative to the currentActivePage.

Constructor Detail

BaseImageTag

public BaseImageTag()
Method Detail

setImageContentNodeName

public void setImageContentNodeName(String imageContentNodeName)
Setter for the imageContentNodeName tag attribute.

Parameters:
imageContentNodeName -

setParentContentNodeName

public void setParentContentNodeName(String parentContentNodeName)
Setter for the parentContentNodeName tag attribute.

Parameters:
parentContentNodeName -

getFilename

protected abstract String getFilename()

getRequest

protected javax.servlet.http.HttpServletRequest getRequest()

getImageContentNode

protected Content getImageContentNode()
                               throws javax.jcr.PathNotFoundException,
                                      javax.jcr.RepositoryException,
                                      AccessDeniedException
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
javax.jcr.AccessDeniedException
AccessDeniedException

convertToSimpleString

public String convertToSimpleString(String string)
Replace any special characters that are not letters or numbers with a replacement string. The two exceptions are '-' and '_', which are allowed.


convertHexToRGB

public int[] convertHexToRGB(String hex)
Converts HEX color to RGB color.

Parameters:
hex - HEX value

convertHexToColor

public Color convertHexToColor(String hex)

createImageNode

protected void createImageNode(File imageFile,
                               Content imageNode)
                        throws javax.jcr.PathNotFoundException,
                               javax.jcr.AccessDeniedException,
                               javax.jcr.RepositoryException,
                               FileNotFoundException,
                               IOException
Create a new imageNode with the image in it. The node is saved under a node that groups all image nodes, whose name is set to the value of the attribute imageContentNodeName. The name of the node will be set to a name that is unique for the image. The property that stores the image will be set to the value of PROPERTIES_FILENAME_VALUE. A sub-node is also created that stores the image properties.

Parameters:
subString - The text.
textImageNode - The node that will contain the text images.
Throws:
javax.jcr.PathNotFoundException
javax.jcr.AccessDeniedException
javax.jcr.RepositoryException
FileNotFoundException
IOException


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.