org.apache.fop.render.afp
Class AFPRenderer

java.lang.Object
  extended byorg.apache.fop.render.AbstractRenderer
      extended byorg.apache.fop.render.PrintRenderer
          extended byorg.apache.fop.render.afp.AFPRenderer
All Implemented Interfaces:
org.apache.fop.render.Renderer

public class AFPRenderer
extends org.apache.fop.render.PrintRenderer

This is an implementaion of an FOP Renderer that renders areas to AFP.

A renderer is primarily designed to convert a given area tree into the output document format. It should be able to produce pages and fill the pages with the text and graphical content. Usually the output is sent to an output stream. Some output formats may support extra information that is not available from the area tree or depends on the destination of the document. Each renderer is given an area tree to render to its output format. The area tree is simply a representation of the pages and the placement of text and graphical objects on those pages.

The renderer will be given each page as it is ready and an output stream to write the data out. All pages are supplied in the order they appear in the document. In order to save memory it is possble to render the pages out of order. Any page that is not ready to be rendered is setup by the renderer first so that it can reserve a space or reference for when the page is ready to be rendered.The renderer is responsible for managing the output format and associated data and flow.

Each renderer is totally responsible for its output format. Because font metrics (and therefore layout) are obtained in two different ways depending on the renderer, the renderer actually sets up the fonts being used. The font metrics are used during the layout process to determine the size of characters.

The render context is used by handlers. It contains information about the current state of the renderer, such as the page, the position, and any other miscellanous objects that are required to draw into the page.

A renderer is created by implementing the Renderer interface. However, the AbstractRenderer does most of what is needed, including iterating through the tree parts, so it is this that is extended. This means that this object only need to implement the basic functionality such as text, images, and lines. AbstractRenderer's methods can easily be overridden to handle things in a different way or do some extra processing.

The relevent AreaTree structures that will need to be rendered are Page, Viewport, Region, Span, Block, Line, Inline. A renderer implementation renders each individual page, clips and aligns child areas to a viewport, handle all types of inline area, text, image etc and draws various lines and rectangles.

Note: There are specific extensions that have been added to the FO. They are specific to their location within the FO and have to be processed accordingly (ie. at the start or end of the page).


Field Summary
protected static org.apache.commons.logging.Log LOGGER
          Static logging instance
 
Fields inherited from class org.apache.fop.render.PrintRenderer
currentFill, currentFontName, currentFontSize, currentStroke, fontInfo, prevLineThroughColor, prevLineThroughSize, prevLineThroughXEndPos, prevLineThroughYEndPos, prevOverlineColor, prevOverlineSize, prevOverlineXEndPos, prevOverlineYEndPos, prevUnderlineColor, prevUnderlineSize, prevUnderlineXEndPos, prevUnderlineYEndPos
 
Fields inherited from class org.apache.fop.render.AbstractRenderer
currentAreaContainerXPosition, currentXPosition, currentYPosition, idReferences, log
 
Constructor Summary
AFPRenderer()
          Constructor for AFPRenderer.
 
Method Summary
protected  void addFilledRect(int x, int y, int w, int h, org.apache.fop.pdf.PDFPathPaint fill)
          Add a filled rectangle to the current stream
protected  void addLine(int x1, int y1, int x2, int y2, int th, int rs, org.apache.fop.pdf.PDFPathPaint stroke)
          Add a line to the current stream.
protected  void addLine(int x1, int y1, int x2, int y2, int th, org.apache.fop.pdf.PDFPathPaint stroke)
          Add a line to the current stream.
protected  void addRect(int x, int y, int w, int h, org.apache.fop.pdf.PDFPathPaint stroke)
           
protected  void addRect(int x, int y, int w, int h, org.apache.fop.pdf.PDFPathPaint stroke, org.apache.fop.pdf.PDFPathPaint fill)
           
protected  void doFrame(org.apache.fop.layout.Area area)
          Override the doFrame(Area area) method so that we draw lines rather than rectangles when processing an area.
protected  void drawImageClipped(int x, int y, int clipX, int clipY, int clipW, int clipH, org.apache.fop.image.FopImage image, org.apache.fop.layout.FontState fs)
           
protected  void drawImageScaled(int x, int y, int w, int h, org.apache.fop.image.FopImage image, org.apache.fop.layout.FontState fs)
           
 void render(org.apache.fop.layout.Page page, java.io.OutputStream stream)
           
 void renderForeignObjectArea(org.apache.fop.layout.inline.ForeignObjectArea area)
           
 void renderPage(org.apache.fop.layout.Page page)
           
 void renderSVGArea(org.apache.fop.svg.SVGArea area)
           
 void renderWordArea(org.apache.fop.layout.inline.WordArea area)
           
 void setLandscapeRotation(int rotation)
          Sets the rotation to be used for landsacpe pages, valid values are 0, 90, 180, 270 (default).
 void setOptions(java.util.Map options)
           
 void setPortraitRotation(int rotation)
          Sets the rotation to be used for portrait pages, valid values are 0 (default), 90, 180, 270.
 void setProducer(java.lang.String producer)
           
 void setupFontInfo(org.apache.fop.layout.FontInfo fontInfo)
          set up the font info
 void startRenderer(java.io.OutputStream outputStream)
           
 void stopRenderer(java.io.OutputStream outputStream)
           
 
Methods inherited from class org.apache.fop.render.PrintRenderer
addFilledRect, addWordLines, renderDisplaySpace, renderInlineSpace, renderLeaderArea
 
Methods inherited from class org.apache.fop.render.AbstractRenderer
doBackground, drawImage, getIDReferences, renderAreaContainer, renderBlockArea, renderBodyAreaContainer, renderImageArea, renderLineArea, renderRegionAreaContainer, renderRegions, renderSpanArea, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.apache.commons.logging.Log LOGGER
Static logging instance

Constructor Detail

AFPRenderer

public AFPRenderer()
Constructor for AFPRenderer.

Method Detail

addLine

protected void addLine(int x1,
                       int y1,
                       int x2,
                       int y2,
                       int th,
                       int rs,
                       org.apache.fop.pdf.PDFPathPaint stroke)
Add a line to the current stream.

Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
rs - the rule style
stroke - the stroke color/gradient

addLine

protected void addLine(int x1,
                       int y1,
                       int x2,
                       int y2,
                       int th,
                       org.apache.fop.pdf.PDFPathPaint stroke)
Add a line to the current stream.

Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
stroke - the stroke color/gradient

addRect

protected void addRect(int x,
                       int y,
                       int w,
                       int h,
                       org.apache.fop.pdf.PDFPathPaint stroke,
                       org.apache.fop.pdf.PDFPathPaint fill)
See Also:
PrintRenderer.addRect(int, int, int, int, PDFPathPaint, PDFPathPaint)

addRect

protected void addRect(int x,
                       int y,
                       int w,
                       int h,
                       org.apache.fop.pdf.PDFPathPaint stroke)
See Also:
PrintRenderer.addRect(int, int, int, int, PDFPathPaint)

addFilledRect

protected void addFilledRect(int x,
                             int y,
                             int w,
                             int h,
                             org.apache.fop.pdf.PDFPathPaint fill)
Add a filled rectangle to the current stream

Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
fill - the fill color/gradient

renderForeignObjectArea

public void renderForeignObjectArea(org.apache.fop.layout.inline.ForeignObjectArea area)
See Also:
Renderer.renderForeignObjectArea(ForeignObjectArea)

renderPage

public void renderPage(org.apache.fop.layout.Page page)
See Also:
Renderer.renderPage(Page)

renderSVGArea

public void renderSVGArea(org.apache.fop.svg.SVGArea area)
See Also:
Renderer.renderSVGArea(SVGArea)

renderWordArea

public void renderWordArea(org.apache.fop.layout.inline.WordArea area)
See Also:
Renderer.renderWordArea(WordArea)

setProducer

public void setProducer(java.lang.String producer)
See Also:
Renderer.setProducer(String)

drawImageClipped

protected void drawImageClipped(int x,
                                int y,
                                int clipX,
                                int clipY,
                                int clipW,
                                int clipH,
                                org.apache.fop.image.FopImage image,
                                org.apache.fop.layout.FontState fs)
See Also:
AbstractRenderer.drawImageClipped(int, int, int, int, int, int, FopImage, FontState)

doFrame

protected void doFrame(org.apache.fop.layout.Area area)
Override the doFrame(Area area) method so that we draw lines rather than rectangles when processing an area.


drawImageScaled

protected void drawImageScaled(int x,
                               int y,
                               int w,
                               int h,
                               org.apache.fop.image.FopImage image,
                               org.apache.fop.layout.FontState fs)
See Also:
AbstractRenderer.drawImageScaled(int, int, int, int, FopImage, FontState)

render

public void render(org.apache.fop.layout.Page page,
                   java.io.OutputStream stream)
            throws java.io.IOException
Throws:
java.io.IOException
See Also:
Renderer.render(Page, OutputStream)

startRenderer

public void startRenderer(java.io.OutputStream outputStream)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
Renderer.startRenderer(java.io.OutputStream)

stopRenderer

public void stopRenderer(java.io.OutputStream outputStream)
                  throws java.io.IOException
Throws:
java.io.IOException
See Also:
Renderer.stopRenderer(java.io.OutputStream)

setOptions

public void setOptions(java.util.Map options)
See Also:
Renderer.setOptions(Map)

setupFontInfo

public void setupFontInfo(org.apache.fop.layout.FontInfo fontInfo)
                   throws org.apache.fop.apps.FOPException
set up the font info

Parameters:
fontInfo - font info to set up
Throws:
org.apache.fop.apps.FOPException

setPortraitRotation

public void setPortraitRotation(int rotation)
Sets the rotation to be used for portrait pages, valid values are 0 (default), 90, 180, 270.

Parameters:
rotation - The rotation in degrees.

setLandscapeRotation

public void setLandscapeRotation(int rotation)
Sets the rotation to be used for landsacpe pages, valid values are 0, 90, 180, 270 (default).

Parameters:
rotation - The rotation in degrees.