fop 1.0

org.apache.fop.render.intermediate
Class AbstractIFPainter

java.lang.Object
  extended by org.apache.fop.render.intermediate.AbstractIFPainter
All Implemented Interfaces:
IFPainter
Direct Known Subclasses:
AFPPainter, Java2DPainter, PCLPainter, PDFPainter, PSPainter, SVGPainter

public abstract class AbstractIFPainter
extends java.lang.Object
implements IFPainter

Abstract base class for IFPainter implementations.


Field Summary
protected static java.lang.String INSTREAM_OBJECT_URI
          non-URI that can be used in feedback messages that an image is an instream-object
protected  IFState state
          Holds the intermediate format state
 
Constructor Summary
AbstractIFPainter()
          Default constructor.
 
Method Summary
protected  java.util.Map createDefaultImageProcessingHints(org.apache.xmlgraphics.image.loader.ImageSessionContext sessionContext)
          Creates the default map of processing hints for the image loading framework.
protected abstract  RenderingContext createRenderingContext()
          Creates a new RenderingContext instance.
 void drawBorderRect(java.awt.Rectangle rect, BorderProps before, BorderProps after, BorderProps start, BorderProps end)
          Draws a border rectangle.
protected  void drawImage(org.apache.xmlgraphics.image.loader.Image image, java.awt.Rectangle rect, RenderingContext context)
          Draws an image using a suitable image handler.
protected  void drawImage(org.apache.xmlgraphics.image.loader.Image image, java.awt.Rectangle rect, RenderingContext context, boolean convert, java.util.Map additionalHints)
          Draws an image using a suitable image handler.
protected  void drawImageUsingDocument(org.w3c.dom.Document doc, java.awt.Rectangle rect)
          Default drawing method for handling a foreign object in the form of a DOM document.
protected  void drawImageUsingImageHandler(org.apache.xmlgraphics.image.loader.ImageInfo info, java.awt.Rectangle rect)
          Loads a preloaded image and draws it using a suitable image handler.
protected  void drawImageUsingURI(java.lang.String uri, java.awt.Rectangle rect)
          Default drawing method for handling an image referenced by a URI.
 void drawLine(java.awt.Point start, java.awt.Point end, int width, java.awt.Color color, RuleStyle style)
          Draws a line.
protected abstract  IFContext getContext()
          Returns the intermediate format context object.
protected  FopFactory getFopFactory()
          Returns the FOP factory.
protected  org.apache.xmlgraphics.image.loader.ImageInfo getImageInfo(java.lang.String uri)
          Returns an ImageInfo instance for the given URI.
protected  java.awt.Rectangle getLineBoundingBox(java.awt.Point start, java.awt.Point end, int width)
          Calculates the bounding box for a line.
protected  FOUserAgent getUserAgent()
          Returns the user agent.
 void setFont(java.lang.String family, java.lang.String style, java.lang.Integer weight, java.lang.String variant, java.lang.Integer size, java.awt.Color color)
          Updates the current font.
 void startGroup(java.awt.geom.AffineTransform[] transforms)
          Starts a new group of graphical elements.
 void startViewport(java.awt.geom.AffineTransform[] transforms, java.awt.Dimension size, java.awt.Rectangle clipRect)
          Starts a new viewport, establishing a new coordinate system.
static java.awt.geom.AffineTransform toPoints(java.awt.geom.AffineTransform transform)
          Converts a transformation matrix from millipoints to points.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.fop.render.intermediate.IFPainter
clipRect, drawImage, drawImage, drawText, endGroup, endViewport, fillRect, startGroup, startViewport
 

Field Detail

INSTREAM_OBJECT_URI

protected static final java.lang.String INSTREAM_OBJECT_URI
non-URI that can be used in feedback messages that an image is an instream-object

See Also:
Constant Field Values

state

protected IFState state
Holds the intermediate format state

Constructor Detail

AbstractIFPainter

public AbstractIFPainter()
Default constructor.

Method Detail

getContext

protected abstract IFContext getContext()
Returns the intermediate format context object.

Returns:
the context object

getUserAgent

protected FOUserAgent getUserAgent()
Returns the user agent.

Returns:
the user agent

getFopFactory

protected FopFactory getFopFactory()
Returns the FOP factory.

Returns:
the FOP factory.

startViewport

public void startViewport(java.awt.geom.AffineTransform[] transforms,
                          java.awt.Dimension size,
                          java.awt.Rectangle clipRect)
                   throws IFException
Starts a new viewport, establishing a new coordinate system. A viewport has a size and can optionally be clipped. Corresponds to SVG's svg element.

Specified by:
startViewport in interface IFPainter
Parameters:
transforms - a series of transformation matrices establishing the new coordinate system
size - the size of the viewport
clipRect - the clipping rectangle (may be null)
Throws:
IFException - if an error occurs while handling this element

startGroup

public void startGroup(java.awt.geom.AffineTransform[] transforms)
                throws IFException
Starts a new group of graphical elements. Corresponds to SVG's g element.

Specified by:
startGroup in interface IFPainter
Parameters:
transforms - a series of transformation matrices establishing the new coordinate system
Throws:
IFException - if an error occurs while handling this element

createRenderingContext

protected abstract RenderingContext createRenderingContext()
Creates a new RenderingContext instance.

Returns:
the new rendering context.

drawImageUsingImageHandler

protected void drawImageUsingImageHandler(org.apache.xmlgraphics.image.loader.ImageInfo info,
                                          java.awt.Rectangle rect)
                                   throws org.apache.xmlgraphics.image.loader.ImageException,
                                          java.io.IOException
Loads a preloaded image and draws it using a suitable image handler.

Parameters:
info - the information object of the preloaded image
rect - the rectangle in which to paint the image
Throws:
org.apache.xmlgraphics.image.loader.ImageException - if there's an error while processing the image
java.io.IOException - if there's an I/O error while loading the image

createDefaultImageProcessingHints

protected java.util.Map createDefaultImageProcessingHints(org.apache.xmlgraphics.image.loader.ImageSessionContext sessionContext)
Creates the default map of processing hints for the image loading framework.

Parameters:
sessionContext - the session context for access to resolution information
Returns:
the default processing hints

drawImage

protected void drawImage(org.apache.xmlgraphics.image.loader.Image image,
                         java.awt.Rectangle rect,
                         RenderingContext context)
                  throws java.io.IOException,
                         org.apache.xmlgraphics.image.loader.ImageException
Draws an image using a suitable image handler.

Parameters:
image - the image to be painted (it needs to of a supported image flavor)
rect - the rectangle in which to paint the image
context - a suitable rendering context
Throws:
java.io.IOException - in case of an I/O error while handling/writing the image
org.apache.xmlgraphics.image.loader.ImageException - if an error occurs while converting the image to a suitable format

drawImage

protected void drawImage(org.apache.xmlgraphics.image.loader.Image image,
                         java.awt.Rectangle rect,
                         RenderingContext context,
                         boolean convert,
                         java.util.Map additionalHints)
                  throws java.io.IOException,
                         org.apache.xmlgraphics.image.loader.ImageException
Draws an image using a suitable image handler.

Parameters:
image - the image to be painted (it needs to of a supported image flavor)
rect - the rectangle in which to paint the image
context - a suitable rendering context
convert - true to run the image through image conversion if that is necessary
additionalHints - additional image processing hints
Throws:
java.io.IOException - in case of an I/O error while handling/writing the image
org.apache.xmlgraphics.image.loader.ImageException - if an error occurs while converting the image to a suitable format

getImageInfo

protected org.apache.xmlgraphics.image.loader.ImageInfo getImageInfo(java.lang.String uri)
Returns an ImageInfo instance for the given URI. If there's an error, null is returned. The caller can assume that any exceptions have already been handled properly. The caller simply skips painting anything in this case.

Parameters:
uri - the URI identifying the image
Returns:
the ImageInfo instance or null if there has been an error.

drawImageUsingURI

protected void drawImageUsingURI(java.lang.String uri,
                                 java.awt.Rectangle rect)
Default drawing method for handling an image referenced by a URI.

Parameters:
uri - the image's URI
rect - the rectangle in which to paint the image

drawImageUsingDocument

protected void drawImageUsingDocument(org.w3c.dom.Document doc,
                                      java.awt.Rectangle rect)
Default drawing method for handling a foreign object in the form of a DOM document.

Parameters:
doc - the DOM document containing the foreign object
rect - the rectangle in which to paint the image

drawBorderRect

public void drawBorderRect(java.awt.Rectangle rect,
                           BorderProps before,
                           BorderProps after,
                           BorderProps start,
                           BorderProps end)
                    throws IFException
Draws a border rectangle. The border segments are specified through BorderProps instances.

Specified by:
drawBorderRect in interface IFPainter
Parameters:
rect - the rectangle's coordinates and extent
before - the border segment on the before-side (top)
after - the border segment on the after-side (bottom)
start - the border segment on the start-side (left)
end - the border segment on the end-side (right)
Throws:
IFException - if an error occurs while handling this event

drawLine

public void drawLine(java.awt.Point start,
                     java.awt.Point end,
                     int width,
                     java.awt.Color color,
                     RuleStyle style)
              throws IFException
Draws a line. NOTE: Currently, only horizontal lines are implemented!

Specified by:
drawLine in interface IFPainter
Parameters:
start - the start point of the line
end - the end point of the line
width - the line width
color - the line color
style - the line style (using the Constants.EN_* constants for the rule-style property)
Throws:
IFException - if an error occurs while handling this event

getLineBoundingBox

protected java.awt.Rectangle getLineBoundingBox(java.awt.Point start,
                                                java.awt.Point end,
                                                int width)
Calculates the bounding box for a line. Currently, only horizontal and vertical lines are needed and supported.

Parameters:
start - the starting point of the line (coordinates in mpt)
end - the ending point of the line (coordinates in mpt)
width - the line width (in mpt)
Returns:
the bounding box (coordinates in mpt)

setFont

public void setFont(java.lang.String family,
                    java.lang.String style,
                    java.lang.Integer weight,
                    java.lang.String variant,
                    java.lang.Integer size,
                    java.awt.Color color)
             throws IFException
Updates the current font.

Specified by:
setFont in interface IFPainter
Parameters:
family - the font family (or null if there's no change)
style - the font style (or null if there's no change)
weight - the font weight (or null if there's no change)
variant - the font variant (or null if there's no change)
size - the font size (or null if there's no change)
color - the text color (or null if there's no change)
Throws:
IFException - if an error occurs while handling this event

toPoints

public static java.awt.geom.AffineTransform toPoints(java.awt.geom.AffineTransform transform)
Converts a transformation matrix from millipoints to points.

Parameters:
transform - the transformation matrix (in millipoints)
Returns:
the converted transformation matrix (in points)

fop 1.0

Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.