net.sf.jasperreports.renderers
Class BatikRenderer

java.lang.Object
  extended by net.sf.jasperreports.engine.JRAbstractRenderer
      extended by net.sf.jasperreports.engine.JRAbstractSvgRenderer
          extended by net.sf.jasperreports.renderers.BatikRenderer
All Implemented Interfaces:
java.io.Serializable, JRImageMapRenderer, JRRenderable

public class BatikRenderer
extends JRAbstractSvgRenderer
implements JRImageMapRenderer

SVG renderer implementation based on Batik.

Version:
$Id: BatikRenderer.java 3035 2009-08-27 12:05:03Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)
See Also:
Serialized Form

Nested Class Summary
protected static class BatikRenderer.JRUserAgent
           
 
Field Summary
 
Fields inherited from interface net.sf.jasperreports.engine.JRRenderable
IMAGE_TYPE_GIF, IMAGE_TYPE_JPEG, IMAGE_TYPE_PNG, IMAGE_TYPE_TIFF, IMAGE_TYPE_UNKNOWN, MIME_TYPE_GIF, MIME_TYPE_JPEG, MIME_TYPE_PNG, MIME_TYPE_TIFF, TYPE_IMAGE, TYPE_SVG
 
Constructor Summary
  BatikRenderer(byte[] svgData, java.util.List areaHyperlinks)
          Creates a SVG renderer.
protected BatikRenderer(java.util.List areaHyperlinks)
           
  BatikRenderer(java.lang.String svgText, java.util.List areaHyperlinks)
          Creates a SVG renderer.
 
Method Summary
protected  java.awt.Graphics2D createGraphics(java.awt.image.BufferedImage bi)
           
protected  void ensureData()
           
protected  void ensureSvg()
           
 java.awt.geom.Dimension2D getDimension()
           
 java.util.List getImageAreaHyperlinks(java.awt.geom.Rectangle2D renderingArea)
          Deprecated. Replaced by renderWithHyperlinks(Graphics2D, Rectangle2D)
static BatikRenderer getInstance(byte[] svgData)
          Creates a SVG renderer from binary data.
static BatikRenderer getInstance(java.io.File svgFile)
          Creates a SVG renderer from a file.
static BatikRenderer getInstance(java.io.InputStream svgDataStream)
          Creates a SVG renderer from a data stream.
static BatikRenderer getInstance(java.net.URL svgURL)
          Creates a SVG renderer from a URL.
static BatikRenderer getInstanceFromLocation(java.lang.String location)
          Creates a SVG renderer by loading data from a generic location.
static BatikRenderer getInstanceFromLocation(java.lang.String location, java.lang.ClassLoader classLoader, java.net.URLStreamHandlerFactory urlHandlerFactory, FileResolver fileResolver)
          Creates a SVG renderer by loading data from a generic location.
static BatikRenderer getInstanceFromText(java.lang.String svgText)
          Creates a SVG renderer from SVG text.
static BatikRenderer getLocationInstance(java.lang.String location)
          Creates a lazily loaded SVG renderer for a location.
 boolean hasImageAreaHyperlinks()
          Indicates whether the renderer actually includes any image map areas.
 void render(java.awt.Graphics2D grx, java.awt.geom.Rectangle2D rectangle)
           
 java.util.List renderWithHyperlinks(java.awt.Graphics2D grx, java.awt.geom.Rectangle2D rectangle)
          Returns the list of image map areas.
protected  void setSvgDataLocation(java.lang.String svgDataLocation)
           
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractSvgRenderer
getBackcolor, getImageData, getImageType, getType
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractRenderer
getId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jasperreports.engine.JRRenderable
getId, getImageData, getImageType, getType
 

Constructor Detail

BatikRenderer

protected BatikRenderer(java.util.List areaHyperlinks)

BatikRenderer

public BatikRenderer(java.lang.String svgText,
                     java.util.List areaHyperlinks)
Creates a SVG renderer.

Parameters:
svgText - the SVG text
areaHyperlinks - a list of area hyperlinks

BatikRenderer

public BatikRenderer(byte[] svgData,
                     java.util.List areaHyperlinks)
Creates a SVG renderer.

Parameters:
svgData - the SVG (binary) data
areaHyperlinks - a list of area hyperlinks
Method Detail

render

public void render(java.awt.Graphics2D grx,
                   java.awt.geom.Rectangle2D rectangle)
            throws JRException
Specified by:
render in interface JRRenderable
Throws:
JRException

getDimension

public java.awt.geom.Dimension2D getDimension()
Specified by:
getDimension in interface JRRenderable
Overrides:
getDimension in class JRAbstractSvgRenderer

ensureData

protected void ensureData()
                   throws JRException
Throws:
JRException

ensureSvg

protected void ensureSvg()
                  throws JRException
Throws:
JRException

renderWithHyperlinks

public java.util.List renderWithHyperlinks(java.awt.Graphics2D grx,
                                           java.awt.geom.Rectangle2D rectangle)
                                    throws JRException
Description copied from interface: JRImageMapRenderer
Returns the list of image map areas.

Specified by:
renderWithHyperlinks in interface JRImageMapRenderer
rectangle - the area on which the image would be rendered
Returns:
a list of JRPrintImageAreaHyperlink instances.
Throws:
JRException

getImageAreaHyperlinks

public java.util.List getImageAreaHyperlinks(java.awt.geom.Rectangle2D renderingArea)
                                      throws JRException
Deprecated. Replaced by renderWithHyperlinks(Graphics2D, Rectangle2D)

Description copied from interface: JRImageMapRenderer
Returns the list of image map areas.

Specified by:
getImageAreaHyperlinks in interface JRImageMapRenderer
Parameters:
renderingArea - the area on which the image would be rendered
Returns:
a list of JRPrintImageAreaHyperlink instances.
Throws:
JRException

hasImageAreaHyperlinks

public boolean hasImageAreaHyperlinks()
Description copied from interface: JRImageMapRenderer
Indicates whether the renderer actually includes any image map areas.

Specified by:
hasImageAreaHyperlinks in interface JRImageMapRenderer
Returns:
whether the renderer actually includes any image map areas

createGraphics

protected java.awt.Graphics2D createGraphics(java.awt.image.BufferedImage bi)
Overrides:
createGraphics in class JRAbstractSvgRenderer

setSvgDataLocation

protected void setSvgDataLocation(java.lang.String svgDataLocation)

getInstance

public static BatikRenderer getInstance(byte[] svgData)
Creates a SVG renderer from binary data.

Parameters:
svgData - the SVG (binary) data
Returns:
a SVG renderer

getInstance

public static BatikRenderer getInstance(java.io.InputStream svgDataStream)
                                 throws JRException
Creates a SVG renderer from a data stream.

Note: the data stream is exhausted, but not closed.

Parameters:
svgDataStream - the SVG binary data stream
Returns:
a SVG renderer
Throws:
JRException

getInstance

public static BatikRenderer getInstance(java.io.File svgFile)
                                 throws JRException
Creates a SVG renderer from a file.

Parameters:
svgFile - the SVG file to read
Returns:
a SVG renderer
Throws:
JRException

getInstance

public static BatikRenderer getInstance(java.net.URL svgURL)
                                 throws JRException
Creates a SVG renderer from a URL.

Parameters:
svgURL - the SVG URL
Returns:
a SVG renderer
Throws:
JRException

getInstanceFromText

public static BatikRenderer getInstanceFromText(java.lang.String svgText)
                                         throws JRException
Creates a SVG renderer from SVG text.

Parameters:
svgText - the SVG text
Returns:
a SVG renderer
Throws:
JRException

getInstanceFromLocation

public static BatikRenderer getInstanceFromLocation(java.lang.String location)
                                             throws JRException
Creates a SVG renderer by loading data from a generic location.

Parameters:
location - the location
Returns:
a SVG renderer
Throws:
JRException
See Also:
JRLoader.loadBytesFromLocation(String)

getInstanceFromLocation

public static BatikRenderer getInstanceFromLocation(java.lang.String location,
                                                    java.lang.ClassLoader classLoader,
                                                    java.net.URLStreamHandlerFactory urlHandlerFactory,
                                                    FileResolver fileResolver)
                                             throws JRException
Creates a SVG renderer by loading data from a generic location.

Parameters:
location - the location
classLoader - the classloader to be used to resolve resources
urlHandlerFactory - the URL handler factory used to resolve URLs
fileResolver - the file resolver
Returns:
a SVG renderer
Throws:
JRException
See Also:
JRLoader.loadBytesFromLocation(String, ClassLoader, URLStreamHandlerFactory, FileResolver)

getLocationInstance

public static BatikRenderer getLocationInstance(java.lang.String location)
                                         throws JRException
Creates a lazily loaded SVG renderer for a location.

The returned renderer loads the SVG data lazily, i.e. only when the data is actually required (which is at the first render(Graphics2D, Rectangle2D)}.

Parameters:
location - the SVG location
Throws:
JRException


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com