|
fop 1.0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.fop.render.AbstractRenderer
org.apache.fop.render.PrintRenderer
org.apache.fop.render.AbstractPathOrientedRenderer
org.apache.fop.render.afp.AFPRenderer
This is an implementation of a 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 possible 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 miscellaneous 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 relevant 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 |
| Fields inherited from class org.apache.fop.render.AbstractPathOrientedRenderer |
FOX_TRANSFORM |
| Fields inherited from class org.apache.fop.render.PrintRenderer |
embedFontInfoList, fontInfo, fontResolver |
| Fields inherited from class org.apache.fop.render.AbstractRenderer |
containingBPPosition, containingIPPosition, currentBPPosition, currentIPPosition, currentPageViewport, log, userAgent |
| Fields inherited from interface org.apache.fop.render.Renderer |
ROLE |
| Constructor Summary | |
AFPRenderer()
Constructor for AFPRenderer. |
|
| Method Summary | |
void |
beginTextObject()
Indicates the beginning of a text object. |
protected java.util.List |
breakOutOfStateStack()
Breaks out of the state stack to handle fixed block-containers. |
void |
clip()
Clip using the current path. |
void |
clipRect(float x,
float y,
float width,
float height)
Clip using a rectangular area. |
void |
closePath()
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath. |
protected void |
concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
Concatenates the current transformation matrix with the given one, therefore establishing a new coordinate system. |
protected RendererContext |
createRendererContext(int x,
int y,
int width,
int height,
java.util.Map foreignAttributes)
Creates a RendererContext for an image. |
void |
drawBorderLine(float x1,
float y1,
float x2,
float y2,
boolean horz,
boolean startOrBefore,
int style,
java.awt.Color col)
Draw a border segment of an XSL-FO style border. |
void |
drawImage(java.lang.String uri,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
Draw an image at the indicated location. |
void |
endTextObject()
Indicates the end of a text object. |
void |
endVParea()
Signals exit from a viewport area. Subclasses can restore transformation matrices valid before the viewport area was started. |
protected void |
establishTransformationMatrix(java.awt.geom.AffineTransform at)
Establishes a new coordinate system with the given transformation matrix. The current graphics state is saved and the new coordinate system is concatenated. |
void |
fillRect(float x,
float y,
float width,
float height)
Fill a rectangular area. |
Graphics2DAdapter |
getGraphics2DAdapter()
|
java.lang.String |
getMimeType()
Get the MIME type of the renderer. |
int |
getResolution()
Returns the output/device resolution. |
protected RendererContext |
instantiateRendererContext()
Instantiates a RendererContext for an image |
void |
lineTo(float x,
float y)
Appends a straight line segment from the current point to (x, y). The new current point is (x, y). |
void |
moveTo(float x,
float y)
Moves the current point to (x, y), omitting any connecting line segment. |
void |
preparePage(PageViewport page)
This is called if the renderer supports out of order rendering. The renderer should prepare the page so that a page further on in the set of pages can be rendered. The body of the page should not be rendered. The page will be rendered at a later time by the call to Renderer.renderPage(PageViewport). |
void |
processOffDocumentItem(OffDocumentItem odi)
Tells the renderer to process an item not explicitly placed on the document (e.g., PDF bookmarks). Note - not all renderers will process all off-document items. |
void |
renderImage(Image image,
java.awt.geom.Rectangle2D pos)
Renders an image area. |
void |
renderLeader(Leader area)
Render leader area. |
void |
renderPage(PageViewport pageViewport)
Tells the renderer to render a particular page. A renderer typically reponds by packing up the current page and writing it immediately to the output device. |
void |
renderText(TextArea text)
Render the given TextArea. |
void |
restoreGraphicsState()
Restores the last graphics state of the rendering engine. |
void |
restoreStateStackAfterBreakOut(java.util.List breakOutList)
Restores the state stack after a break out. |
void |
saveGraphicsState()
Saves the graphics state of the rendering engine. |
void |
setBitsPerPixel(int bitsPerPixel)
Sets the number of bits used per pixel |
void |
setCMYKImagesSupported(boolean value)
Controls whether CMYK images (IOCA FS45) are enabled. By default, support is disabled for wider compatibility. When disabled, any CMYK image is converted to the selected color format. |
void |
setColorImages(boolean colorImages)
Sets whether images are color or not |
void |
setDefaultResourceGroupFilePath(java.lang.String filePath)
Sets the default resource group file path |
void |
setDitheringQuality(float quality)
Sets the dithering quality setting to use when converting images to monochrome images. |
void |
setLandscapeRotation(int rotation)
Sets the rotation to be used for landscape pages, valid values are 0, 90, 180, 270 (default). |
void |
setNativeImagesSupported(boolean nativeImages)
Sets whether images are supported natively or not |
void |
setPortraitRotation(int rotation)
Sets the rotation to be used for portrait pages, valid values are 0 (default), 90, 180, 270. |
void |
setResolution(int resolution)
Sets the output/device resolution |
void |
setResourceLevelDefaults(AFPResourceLevelDefaults defaults)
Sets the resource level defaults. The object passed in provides information which resource level shall be used by default for various kinds of resources. |
void |
setShadingMode(AFPShadingMode shadingMode)
Sets the shading mode for painting filled rectangles. |
void |
setupFontInfo(FontInfo inFontInfo)
Set up the given FontInfo. |
void |
setUserAgent(FOUserAgent agent)
Set the User Agent. |
void |
startPageSequence(PageSequence pageSequence)
Tells the renderer that a new page sequence starts. |
void |
startRenderer(java.io.OutputStream outputStream)
Initiates the rendering phase. This must only be called once for a rendering. If stopRenderer is called then this may be called again for a new document rendering. |
void |
startVParea(CTM ctm,
java.awt.geom.Rectangle2D clippingRect)
Establishes a new viewport area. |
void |
stopRenderer()
Signals the end of the rendering phase. The renderer should reset to an initial state and dispose of any resources for the completed rendering. |
boolean |
supportsOutOfOrder()
Check if this renderer supports out of order rendering. If this renderer supports out of order rendering then it means that the pages that are not ready will be prepared and a future page will be rendered. |
void |
updateColor(java.awt.Color col,
boolean fill)
Establishes a new foreground or fill color. |
static void |
writeImage(java.awt.image.RenderedImage image,
java.io.OutputStream out)
Deprecated. use ImageEncodingHelper.encodeRenderedImageAsRGB(image, out) directly instead |
| Methods inherited from class org.apache.fop.render.AbstractPathOrientedRenderer |
drawBackAndBorders, drawBackAndBorders, drawBackground, drawBorders, drawBorders, drawImage, handleBlockTraits, handleRegionTraits, renderBlockViewport, renderFlow, renderForeignObject, renderInlineAreaBackAndBorders, renderReferenceArea, renderTextDecoration, renderViewport |
| Methods inherited from class org.apache.fop.render.PrintRenderer |
addFontList, getFontFromArea, getFontInfo, getFontList, getFontResolver, getInternalFontNameForArea, renderDocument, setFontList |
| Methods inherited from class org.apache.fop.render.AbstractRenderer |
convertTitleToString, getCurrentPageViewport, getImageAdapter, getUserAgent, mptToPt, ptToMpt, renderBeforeFloat, renderBlock, renderBlocks, renderBodyRegion, renderContainer, renderFootnote, renderInlineArea, renderInlineBlockParent, renderInlineParent, renderInlineSpace, renderLineArea, renderMainReference, renderPageAreas, renderRegion, renderRegionViewport, renderSpace, renderWord, renderXML, startPageSequence |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AFPRenderer()
| Method Detail |
public void setupFontInfo(FontInfo inFontInfo)
setupFontInfo in interface RenderersetupFontInfo in class PrintRendererpublic void setUserAgent(FOUserAgent agent)
setUserAgent in interface RenderersetUserAgent in class AbstractRenderer
public void startRenderer(java.io.OutputStream outputStream)
throws java.io.IOException
startRenderer in interface RendererstartRenderer in class AbstractRendererjava.io.IOException
public void stopRenderer()
throws java.io.IOException
stopRenderer in interface RendererstopRenderer in class AbstractRendererjava.io.IOExceptionpublic void startPageSequence(PageSequence pageSequence)
startPageSequence in interface RendererstartPageSequence in class AbstractRendererpublic boolean supportsOutOfOrder()
supportsOutOfOrder in interface RenderersupportsOutOfOrder in class AbstractRendererpublic void preparePage(PageViewport page)
Renderer.renderPage(PageViewport).
preparePage in interface RendererpreparePage in class AbstractRendererpublic void processOffDocumentItem(OffDocumentItem odi)
processOffDocumentItem in interface RendererprocessOffDocumentItem in class AbstractRendererpublic Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter in interface RenderergetGraphics2DAdapter in class AbstractRenderer
public void startVParea(CTM ctm,
java.awt.geom.Rectangle2D clippingRect)
startVParea in class AbstractRendererctm - the coordinate transformation matrix to useclippingRect - the clipping rectangle if the viewport should be clipping,
null if no clipping is performed.public void endVParea()
endVParea in class AbstractRendererprotected void concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
concatenateTransformationMatrix in class AbstractPathOrientedRendererat - the transformation matrix to process (coordinates in points)
public void renderPage(PageViewport pageViewport)
throws java.io.IOException,
FOPException
renderPage in interface RendererrenderPage in class AbstractRendererjava.io.IOException
FOPException
public void drawBorderLine(float x1,
float y1,
float x2,
float y2,
boolean horz,
boolean startOrBefore,
int style,
java.awt.Color col)
drawBorderLine in class AbstractPathOrientedRendererx1 - starting x coordinatey1 - starting y coordinatex2 - ending x coordinatey2 - ending y coordinatehorz - true for horizontal border segments, false for vertical border segmentsstartOrBefore - true for border segments on the start or before edge,
false for end or after.style - the border style (one of Constants.EN_DASHED etc.)col - the color for the border segment
public void fillRect(float x,
float y,
float width,
float height)
fillRect in class AbstractPathOrientedRendererx - the x coordinatey - the y coordinatewidth - the width of the rectangleheight - the height of the rectangleprotected RendererContext instantiateRendererContext()
instantiateRendererContext in class PrintRenderer
protected RendererContext createRendererContext(int x,
int y,
int width,
int height,
java.util.Map foreignAttributes)
createRendererContext in class PrintRendererx - the x coordinate (in millipoints)y - the y coordinate (in millipoints)width - the width of the image (in millipoints)height - the height of the image (in millipoints)foreignAttributes - a Map or foreign attributes, may be null
public void drawImage(java.lang.String uri,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
drawImage in class AbstractPathOrientedRendereruri - the URI/URL of the imagepos - the position of the imageforeignAttributes - an optional Map with foreign attributes, may be null
public static void writeImage(java.awt.image.RenderedImage image,
java.io.OutputStream out)
throws java.io.IOException
image - the RenderedImageout - the OutputStream
java.io.IOException - In case of an I/O error.
public void updateColor(java.awt.Color col,
boolean fill)
updateColor in class AbstractPathOrientedRenderercol - the color to apply (null skips this operation)fill - true to set the fill color, false for the foreground colorpublic void restoreStateStackAfterBreakOut(java.util.List breakOutList)
restoreStateStackAfterBreakOut in class AbstractPathOrientedRendererbreakOutList - the state stack to restore.protected java.util.List breakOutOfStateStack()
breakOutOfStateStack in class AbstractPathOrientedRendererpublic void saveGraphicsState()
saveGraphicsState in class AbstractPathOrientedRendererpublic void restoreGraphicsState()
restoreGraphicsState in class AbstractPathOrientedRenderer
public void renderImage(Image image,
java.awt.geom.Rectangle2D pos)
renderImage in class AbstractRendererimage - The imagepos - The target position of the image
(todo) Make renderImage() protectedpublic void renderText(TextArea text)
renderText in class AbstractRenderertext - the text to renderpublic void renderLeader(Leader area)
renderLeader in class AbstractRendererarea - the leader area to renderpublic java.lang.String getMimeType()
getMimeType in interface Rendererpublic void setPortraitRotation(int rotation)
rotation - The rotation in degrees.public void setLandscapeRotation(int rotation)
rotation - The rotation in degrees.public void setBitsPerPixel(int bitsPerPixel)
setBitsPerPixel in interface AFPCustomizablebitsPerPixel - number of bits per pixelpublic void setColorImages(boolean colorImages)
setColorImages in interface AFPCustomizablecolorImages - color image outputpublic void setNativeImagesSupported(boolean nativeImages)
setNativeImagesSupported in interface AFPCustomizablenativeImages - native image supportpublic void setCMYKImagesSupported(boolean value)
setCMYKImagesSupported in interface AFPCustomizablevalue - true to enabled CMYK imagespublic void setDitheringQuality(float quality)
setDitheringQuality in interface AFPCustomizablequality - Defines the desired quality level for the conversion.
Valid values: a value between 0.0f (fastest) and 1.0f (best)public void setShadingMode(AFPShadingMode shadingMode)
setShadingMode in interface AFPCustomizableshadingMode - the shading modepublic void setResolution(int resolution)
setResolution in interface AFPCustomizableresolution - the output resolution (dpi)public int getResolution()
getResolution in interface AFPCustomizablepublic void setDefaultResourceGroupFilePath(java.lang.String filePath)
setDefaultResourceGroupFilePath in interface AFPCustomizablefilePath - the default resource group file pathpublic void setResourceLevelDefaults(AFPResourceLevelDefaults defaults)
setResourceLevelDefaults in interface AFPCustomizabledefaults - the resource level defaultsprotected void establishTransformationMatrix(java.awt.geom.AffineTransform at)
establishTransformationMatrix in class AbstractPathOrientedRendererat - the transformation matrixpublic void clip()
clip in class AbstractPathOrientedRenderer
public void clipRect(float x,
float y,
float width,
float height)
clipRect in class AbstractPathOrientedRendererx - the x coordinate (in points)y - the y coordinate (in points)width - the width of the rectangle (in points)height - the height of the rectangle (in points)
public void moveTo(float x,
float y)
moveTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinate
public void lineTo(float x,
float y)
lineTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinatepublic void closePath()
closePath in class AbstractPathOrientedRendererpublic void beginTextObject()
beginTextObject in class AbstractPathOrientedRendererpublic void endTextObject()
endTextObject in class AbstractPathOrientedRenderer
|
fop 1.0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||