|
fop 0.92beta | ||||||||||
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.java2d.Java2DRenderer
The Java2DRenderer
class provides the abstract technical
foundation for all rendering with the Java2D API. Renderers like
AWTRenderer
subclass it and provide the concrete output paths.
A lot of the logic is performed by AbstractRenderer
. The
class-variables currentIPPosition
and
currentBPPosition
hold the position of the currently rendered
area.
Java2DGraphicsState state
holds the Graphics2D
,
which is used along the whole rendering. state
also acts as a
stack (state.push()
and state.pop()
).
The rendering process is basically always the same:
void renderXXXXX(Area area) {
//calculate the currentPosition
state.updateFont(name, size, null);
state.updateColor(ct, false, null);
state.getGraph.draw(new Shape(args));
}
Field Summary | |
protected boolean |
antialiasing
true if antialiasing is set |
protected FontInfo |
fontInfo
Font configuration |
protected java.util.Map |
fontNames
|
protected java.util.Map |
fontStyles
|
protected java.awt.geom.Line2D.Float |
line
a Line2D.Float used to draw text decorations and leaders |
protected int |
pageHeight
The page height in pixels |
protected java.util.List |
pageViewportList
List of Viewports |
protected int |
pageWidth
The page width in pixels |
protected boolean |
qualityRendering
true if qualityRendering is set |
boolean |
renderingDone
true if the renderer has finished rendering all the pages |
protected double |
scaleFactor
The scale factor for the image size, values: ]0 ; 1] |
protected Java2DGraphicsState |
state
The current state, holds a Graphics2D and its context |
Fields inherited from class org.apache.fop.render.AbstractRenderer |
containingBPPosition, containingIPPosition, currentBPPosition, currentIPPosition, currentPageViewport, log, userAgent |
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Fields inherited from interface org.apache.fop.render.Renderer |
ROLE |
Constructor Summary | |
Java2DRenderer()
Default constructor |
Method Summary | |
void |
clearViewportList()
Clears the ViewportList. |
protected void |
clipRect(float x,
float y,
float width,
float height)
Clip an area. write a clipping operation given coordinates in the current transform. |
protected void |
drawBackAndBorders(Area area,
float startx,
float starty,
float width,
float height)
Draw the background and borders. |
protected void |
drawBackground(Trait.Background back,
float sx,
float sy,
float paddRectWidth,
float paddRectHeight)
Draw the Background Rectangle of a given area. |
protected void |
endVParea()
Signals exit from a viewport area. |
int |
getCurrentPageNumber()
|
protected Font |
getFontFromArea(Area area)
Returns a Font object constructed based on the font traits in an area |
Graphics2DAdapter |
getGraphics2DAdapter()
|
int |
getNumberOfPages()
|
java.awt.image.BufferedImage |
getPageImage(int pageNum)
Generates a desired page from the renderer's page viewport list. |
java.awt.image.BufferedImage |
getPageImage(PageViewport pageViewport)
Generates a desired page from the renderer's page viewport list. |
PageViewport |
getPageViewport(int pageNum)
Returns the page viewport |
double |
getScaleFactor()
|
FOUserAgent |
getUserAgent()
|
protected void |
handleBlockTraits(Block block)
Handle block traits. |
protected void |
handleRegionTraits(RegionViewport region)
Handle the traits for a region This is used to draw the traits for the given page region. |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pageFormat,
int pageIndex)
|
protected void |
putImage(java.lang.String pUrl,
java.awt.geom.Rectangle2D pos)
Draws an image |
protected void |
renderBlockViewport(BlockViewport bv,
java.util.List children)
Renders a block viewport. |
void |
renderDocument(org.w3c.dom.Document doc,
java.lang.String ns,
java.awt.geom.Rectangle2D pos)
Renders an XML document (SVG for example). |
void |
renderForeignObject(ForeignObject fo,
java.awt.geom.Rectangle2D pos)
Renders a foreign object area. |
void |
renderImage(Image image,
java.awt.geom.Rectangle2D pos)
Renders an image area. |
protected void |
renderInlineAreaBackAndBorders(InlineArea area)
Common method to render the background and borders for any inline area. |
protected void |
renderInlineBlockParent(InlineBlockParent ibp)
Render the given InlineBlockParent. |
protected void |
renderInlineParent(InlineParent ip)
Render the given InlineParent. |
protected void |
renderInlineSpace(Space space)
Render the given Space. |
void |
renderLeader(Leader area)
Render leader area. |
void |
renderPage(PageViewport pageViewport)
This method override only stores the PageViewport in a List. |
void |
renderText(TextArea text)
Render the given TextArea. |
protected void |
renderTextDecoration(Font fs,
InlineArea inline,
float baseline,
float startIPD)
Paints the text decoration marks. |
void |
renderViewport(Viewport viewport)
Render an inline viewport. |
protected void |
restoreGraphicsState()
Restores the last graphics state of the rendering engine. |
protected void |
saveGraphicsState()
Saves the graphics state of the rendering engine. |
void |
setCurrentPageNumber(int c)
|
void |
setScaleFactor(double newScaleFactor)
Sets the new scale factor. |
void |
setupFontInfo(FontInfo inFontInfo)
Set up the given FontInfo. |
void |
setUserAgent(FOUserAgent foUserAgent)
Set the User Agent. |
void |
startRenderer(java.io.OutputStream out)
Initiates the rendering phase. |
protected void |
startVParea(CTM ctm,
java.awt.geom.Rectangle2D clippingRect)
Establishes a new viewport area. |
void |
stopRenderer()
Signals the end of the rendering phase. |
Methods inherited from class org.apache.fop.render.AbstractRenderer |
configure, convertTitleToString, getCurrentPageViewport, getHandlerConfig, getImageAdapter, getMimeType, preparePage, processOffDocumentItem, renderBeforeFloat, renderBlock, renderBlocks, renderBodyRegion, renderCharacter, renderContainer, renderFlow, renderFootnote, renderInlineArea, renderLineArea, renderMainReference, renderPageAreas, renderRegion, renderRegionViewport, renderSpace, renderWord, renderXML, startPageSequence, supportsOutOfOrder |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected double scaleFactor
protected int pageWidth
protected int pageHeight
protected java.util.List pageViewportList
protected boolean antialiasing
protected boolean qualityRendering
protected Java2DGraphicsState state
protected java.awt.geom.Line2D.Float line
protected FontInfo fontInfo
protected java.util.Map fontNames
protected java.util.Map fontStyles
public boolean renderingDone
Constructor Detail |
public Java2DRenderer()
Method Detail |
public void setUserAgent(FOUserAgent foUserAgent)
Renderer
setUserAgent
in interface Renderer
setUserAgent
in class AbstractRenderer
Renderer.setUserAgent(org.apache.fop.apps.FOUserAgent)
public FOUserAgent getUserAgent()
public void setupFontInfo(FontInfo inFontInfo)
Renderer
setupFontInfo
in interface Renderer
setupFontInfo
in class AbstractRenderer
Renderer.setupFontInfo(org.apache.fop.fonts.FontInfo)
public Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter
in interface Renderer
getGraphics2DAdapter
in class AbstractRenderer
Renderer.getGraphics2DAdapter()
public void setScaleFactor(double newScaleFactor)
newScaleFactor
- ]0 ; 1]public double getScaleFactor()
public void startRenderer(java.io.OutputStream out) throws java.io.IOException
Renderer
startRenderer
in interface Renderer
startRenderer
in class AbstractRenderer
java.io.IOException
Renderer.startRenderer(OutputStream)
public void stopRenderer() throws java.io.IOException
Renderer
stopRenderer
in interface Renderer
stopRenderer
in class AbstractRenderer
java.io.IOException
Renderer.stopRenderer()
public int getCurrentPageNumber()
public void setCurrentPageNumber(int c)
c
- the 0-based current page numberpublic int getNumberOfPages()
public void clearViewportList()
public void renderPage(PageViewport pageViewport) throws java.io.IOException, FOPException
renderPage
in interface Renderer
renderPage
in class AbstractRenderer
pageViewport
- the PageViewport
object supplied by
the Area Tree
java.io.IOException
FOPException
Renderer
public java.awt.image.BufferedImage getPageImage(PageViewport pageViewport)
pageViewport
- the PageViewport to be rendered
java.awt.image.BufferedImage
corresponding to
the page or null if the page doesn't exist.public PageViewport getPageViewport(int pageNum) throws FOPException
pageNum
- the page number
FOPException
- If the page is out of range.public java.awt.image.BufferedImage getPageImage(int pageNum) throws FOPException
pageNum
- the 0-based page number to generate
java.awt.image.BufferedImage
corresponding to
the page or null if the page doesn't exist.
FOPException
protected void handleRegionTraits(RegionViewport region)
handleRegionTraits
in class AbstractRenderer
region
- the RegionViewport whose region is to be drawnpublic void renderViewport(Viewport viewport)
renderViewport
in class AbstractRenderer
viewport
- the viewport to handleprotected void saveGraphicsState()
protected void restoreGraphicsState()
protected void startVParea(CTM ctm, java.awt.geom.Rectangle2D clippingRect)
AbstractRenderer
startVParea
in class AbstractRenderer
ctm
- the coordinate transformation matrix to useclippingRect
- the clipping rectangle if the viewport should be clipping,
null if no clipping is performed.AbstractRenderer.startVParea(CTM, Rectangle2D)
protected void endVParea()
AbstractRenderer
endVParea
in class AbstractRenderer
AbstractRenderer.endVParea()
protected void renderInlineSpace(Space space)
AbstractRenderer
renderInlineSpace
in class AbstractRenderer
space
- the space to renderAbstractRenderer
protected void renderInlineParent(InlineParent ip)
AbstractRenderer
renderInlineParent
in class AbstractRenderer
ip
- the inline parent to renderAbstractRenderer
protected void renderInlineBlockParent(InlineBlockParent ibp)
AbstractRenderer
renderInlineBlockParent
in class AbstractRenderer
ibp
- the inline block parent to renderAbstractRenderer
protected void renderBlockViewport(BlockViewport bv, java.util.List children)
AbstractRenderer
renderBlockViewport
in class AbstractRenderer
bv
- The block viewportchildren
- The children to render within the block viewportAbstractRenderer.renderBlockViewport(BlockViewport,
List)
protected void clipRect(float x, float y, float width, float height)
x
- the x coordinatey
- the y coordinatewidth
- the width of the areaheight
- the height of the areaprotected void drawBackAndBorders(Area area, float startx, float starty, float width, float height)
area
- the area whose traits are usedstartx
- the start x positionstarty
- the start y positionwidth
- the width of the areaheight
- the height of the areaprotected void drawBackground(Trait.Background back, float sx, float sy, float paddRectWidth, float paddRectHeight)
back
- the Trait.Backgroundsx
- x coordinate of the rectangle to be filled.sy
- y the y coordinate of the rectangle to be filled.paddRectWidth
- the width of the rectangle to be filled.paddRectHeight
- the height of the rectangle to be filled.protected void renderInlineAreaBackAndBorders(InlineArea area)
area
- the inline area for which the background, border and padding is to be
renderedprotected void handleBlockTraits(Block block)
handleBlockTraits
in class AbstractRenderer
block
- the block to render the traitsprotected Font getFontFromArea(Area area)
area
- the area from which to retrieve the font triplet information
public void renderText(TextArea text)
AbstractRenderer
renderText
in class AbstractRenderer
text
- the text to renderAbstractRenderer.renderText(TextArea)
protected void renderTextDecoration(Font fs, InlineArea inline, float baseline, float startIPD)
fs
- Current fontinline
- inline area to paint the marks forbaseline
- position of the baselinestartIPD
- start IPDpublic void renderLeader(Leader area)
renderLeader
in class AbstractRenderer
area
- the leader area to renderpublic void renderImage(Image image, java.awt.geom.Rectangle2D pos)
AbstractRenderer
renderImage
in class AbstractRenderer
image
- The imagepos
- The target position of the image
(todo) Make renderImage() protectedAbstractRenderer.renderImage(Image,
Rectangle2D)
protected void putImage(java.lang.String pUrl, java.awt.geom.Rectangle2D pos)
pUrl
- URL of the bitmappos
- Position of the bitmappublic void renderForeignObject(ForeignObject fo, java.awt.geom.Rectangle2D pos)
AbstractRenderer
renderForeignObject
in class AbstractRenderer
fo
- The foreign object areapos
- The target position of the foreign object
(todo) Make renderForeignObject() protectedAbstractRenderer.renderForeignObject(ForeignObject,
Rectangle2D)
public void renderDocument(org.w3c.dom.Document doc, java.lang.String ns, java.awt.geom.Rectangle2D pos)
doc
- DOM document representing the XML documentns
- Namespace for the documentpos
- Position on the pagepublic int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex) throws java.awt.print.PrinterException
print
in interface java.awt.print.Printable
java.awt.print.PrinterException
Printable.print(java.awt.Graphics,
java.awt.print.PageFormat, int)
|
fop 0.92beta | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |