org.infoglue.deliver.util.graphics
Class AdvancedImageRenderer

java.lang.Object
  extended by org.infoglue.deliver.util.graphics.AdvancedImageRenderer

public class AdvancedImageRenderer
extends java.lang.Object

Renders images and saves them.

Version:
1.1 fixed reading properties from file, some optimizations and added a imageFileFormat,
Author:
Per Jonsson - per.jonsson@it-huset.se

Constructor Summary
AdvancedImageRenderer()
          Creates a new instance of tne NewImageRenderer and reads in properties from the property file if exists.
 
Method Summary
 java.lang.String getImageFormatName()
          Get the image format name, default is "png" if none is set.
 boolean hasAttribute(java.lang.CharSequence attributeName)
          Check if this class has a specific attribute, name of attribute is case insensitive. ie.
 java.awt.image.BufferedImage renderImage(java.text.AttributedString attributedString, java.util.Map renderAttributes)
          Renders a text returnes the rendered picture.
 java.awt.image.BufferedImage renderImage(java.lang.CharSequence text, java.util.Map renderAttributes)
          Renders a text returnes the rendered picture.
 void setAlign(int align)
           
 void setAttribute(java.lang.CharSequence attribute, java.lang.CharSequence value)
          Using reflection to set the fields corresponing to the attribute. tries to convert to the right object.
 void setBackgroundImage(java.awt.image.BufferedImage backgroundImage)
           
 void setBackgroundImageUrl(java.lang.String backgroundImageUrl)
           
 void setBackgroundImageURL(java.lang.String backgroundImageUrl)
           
 void setBgColor(java.awt.Color bgColor)
           
 void setFgColor(java.awt.Color fgColor)
           
 void setFontName(java.lang.String fontName)
           
 void setFontSize(int fontSize)
           
 void setFontStyle(int fontStyle)
           
 void setImageFormatName(java.lang.String imageFormatName)
           
 void setImageType(int imageType)
           
 void setMaxRows(int maxRows)
           
 void setPad(int pad)
          Sets all paddings to the same value.
 void setPadBottom(int padBottom)
           
 void setPadLeft(int padLeft)
           
 void setPadRight(int padRight)
           
 void setPadTop(int padTop)
           
 void setRenderHints(java.util.Map renderHints)
           
 void setRenderWidth(int renderWidth)
           
 void setTemplateImage(java.awt.image.BufferedImage templateImage)
           
 void setTileBackgroundImage(int tileBackgroundImage)
           
 void setTrimEdges(int trimEdges)
           
 boolean writeImage(java.io.File file)
          Write the rendered image to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedImageRenderer

public AdvancedImageRenderer()
Creates a new instance of tne NewImageRenderer and reads in properties from the property file if exists. The propertieas must have the suffix of "rendertext" ie. rendertext.fontname.

Method Detail

writeImage

public boolean writeImage(java.io.File file)
Write the rendered image to a file.

Parameters:
file - the file of the image to create.
Returns:
true if success, false if error

renderImage

public java.awt.image.BufferedImage renderImage(java.lang.CharSequence text,
                                                java.util.Map renderAttributes)
Renders a text returnes the rendered picture.

Parameters:
text - The text to be rendered.
Returns:
an rendered image

renderImage

public java.awt.image.BufferedImage renderImage(java.text.AttributedString attributedString,
                                                java.util.Map renderAttributes)
Renders a text returnes the rendered picture.

Parameters:
attributedString - an attributed string, to enable multicolored or similar texts.
Returns:
an rendered image

hasAttribute

public boolean hasAttribute(java.lang.CharSequence attributeName)
Check if this class has a specific attribute, name of attribute is case insensitive. ie. "fontname", "fontsize", "bgcolor"

Parameters:
attributeName - name of the attribute to check
Returns:
true if attribute exisist, false otherwise

setAttribute

public void setAttribute(java.lang.CharSequence attribute,
                         java.lang.CharSequence value)
Using reflection to set the fields corresponing to the attribute. tries to convert to the right object. The attribute is caseinsesitive.
If it's a color value it has to be a string in the format "252:123:133:255" where they are "R:G:B:A" values from 0-255.

Parameters:
attribute - the field/property to set
value - the value to set.

setAlign

public void setAlign(int align)
Parameters:
align - The align to set.

setBackgroundImage

public void setBackgroundImage(java.awt.image.BufferedImage backgroundImage)
Parameters:
backgroundImage - The backgroundImage to set.

setBackgroundImageURL

public void setBackgroundImageURL(java.lang.String backgroundImageUrl)
Parameters:
backgroundImageUrl - The backgroundImageUrl to set.

setBgColor

public void setBgColor(java.awt.Color bgColor)
Parameters:
bgColor - The bgColor to set.

setFgColor

public void setFgColor(java.awt.Color fgColor)
Parameters:
fgColor - The fgColor to set.

setFontName

public void setFontName(java.lang.String fontName)
Parameters:
fontName - The fontName to set.

setFontSize

public void setFontSize(int fontSize)
Parameters:
fontSize - The fontSize to set.

setFontStyle

public void setFontStyle(int fontStyle)
Parameters:
fontStyle - The fontStyle to set.

setImageType

public void setImageType(int imageType)
Parameters:
imageType - The imageType to set.

setPadBottom

public void setPadBottom(int padBottom)
Parameters:
padBottom - The padBottom to set.

setPadLeft

public void setPadLeft(int padLeft)
Parameters:
padLeft - The padLeft to set.

setPadRight

public void setPadRight(int padRight)
Parameters:
padRight - The padRight to set.

setPad

public void setPad(int pad)
Sets all paddings to the same value.

Parameters:
pad - The padRight, padLeft, padTop andpadBottom to set.

setPadTop

public void setPadTop(int padTop)
Parameters:
padTop - The padTop to set.

setRenderHints

public void setRenderHints(java.util.Map renderHints)
Parameters:
renderHints - The renderHints to set.

setRenderWidth

public void setRenderWidth(int renderWidth)
Parameters:
renderWidth - The renderWidth to set.

setTemplateImage

public void setTemplateImage(java.awt.image.BufferedImage templateImage)
Parameters:
templateImage - The templateImage to set.

setTileBackgroundImage

public void setTileBackgroundImage(int tileBackgroundImage)
Parameters:
tileBackgroundImage - The tileBackgroundImage to set.

setBackgroundImageUrl

public void setBackgroundImageUrl(java.lang.String backgroundImageUrl)
Parameters:
backgroundImageUrl - The backgroundImageUrl to set.

setMaxRows

public void setMaxRows(int maxRows)
Parameters:
maxRows - The maxRows to set.

setTrimEdges

public void setTrimEdges(int trimEdges)
Parameters:
trimEdges - The trimEdges to set.

setImageFormatName

public void setImageFormatName(java.lang.String imageFormatName)
Parameters:
imageFormatName - the format of the image. ie ( PNG, GIF);

getImageFormatName

public java.lang.String getImageFormatName()
Get the image format name, default is "png" if none is set.

Returns:
a string with the image format name used by the renderer.


Copyright © 2005 InfoGlue.org All Rights Reserved.