|
fop 2.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.java2d.Java2DRenderer
public abstract class 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 anti-aliasing is set |
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 |
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 |
protected boolean |
transparentPageBackground
false: paints a non-transparent white background, true: for a transparent background |
Fields inherited from class org.apache.fop.render.AbstractPathOrientedRenderer |
---|
FOX_TRANSFORM |
Fields inherited from class org.apache.fop.render.PrintRenderer |
---|
embedFontInfoList, fontInfo |
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(FOUserAgent userAgent)
Default constructor |
Method Summary | |
---|---|
protected 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 |
clearViewportList()
Clears the ViewportList. |
protected void |
clip()
Clip using the current path. |
protected void |
clipRect(float x,
float y,
float width,
float height)
Clip using a rectangular area. |
protected 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. |
protected 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. |
static void |
drawBorderLine(java.awt.geom.Rectangle2D.Float lineRect,
boolean horz,
boolean startOrBefore,
int style,
java.awt.Color col,
java.awt.Graphics2D g2d)
Draw a border segment of an XSL-FO style border. |
protected void |
drawImage(java.lang.String uri,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
Draw an image at the indicated location. |
protected void |
endLayer()
Finish current optional content group layer. |
protected void |
endTextObject()
Indicates the end of a text object. |
protected void |
endVParea()
Signals exit from a viewport area. |
protected void |
fillRect(float x,
float y,
float width,
float height)
Fill a rectangular area. |
protected java.awt.image.BufferedImage |
getBufferedImage(int bitmapWidth,
int bitmapHeight)
Returns a specific BufferedImage to paint a page image on. |
int |
getCurrentPageNumber()
|
Graphics2DAdapter |
getGraphics2DAdapter()
|
int |
getNumberOfPages()
Returns the number of pages available. |
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 pageIndex)
Returns a page viewport. |
double |
getScaleFactor()
|
FOUserAgent |
getUserAgent()
Returns the associated user agent. |
boolean |
isRenderingDone()
|
protected void |
lineTo(float x,
float y)
Appends a straight line segment from the current point to (x, y). |
protected void |
moveTo(float x,
float y)
Moves the current point to (x, y), omitting any connecting line segment. |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pageFormat,
int pageIndex)
|
protected void |
rememberPage(PageViewport pageViewport)
Stores the pageViewport in a list of page viewports so they can be rendered later. |
void |
renderImage(Image image,
java.awt.geom.Rectangle2D pos)
Renders an image area. |
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. |
static void |
renderText(TextArea text,
java.awt.Graphics2D g2d,
Font font)
Renders a TextArea to a Graphics2D instance. |
protected void |
restoreGraphicsState()
Restores the last graphics state of the rendering engine. |
protected void |
restoreStateStackAfterBreakOut(java.util.List breakOutList)
Restores the state stack after a break out. |
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 |
setTransparentPageBackground(boolean transparentPageBackground)
Controls the page background. |
void |
setupFontInfo(FontInfo inFontInfo)
Set up the given FontInfo. |
protected void |
startLayer(java.lang.String layer)
Establish new optional content group layer. |
void |
startRenderer(java.io.OutputStream out)
Initiates the rendering phase. |
protected void |
startVParea(CTM ctm,
java.awt.Rectangle clippingRect)
Establishes a new viewport area. |
void |
stopRenderer()
Signals the end of the rendering phase. |
protected void |
updateColor(java.awt.Color col,
boolean fill)
Establishes a new foreground or fill color. |
Methods inherited from class org.apache.fop.render.AbstractPathOrientedRenderer |
---|
clipBackground, drawBackAndBorders, drawBackAndBorders, drawBackground, drawBackground, drawBorders, drawBorders, drawImage, establishTransformationMatrix, handleBlockTraits, handleRegionTraits, renderBlockViewport, renderFlow, renderForeignObject, renderInlineAreaBackAndBorders, renderInlineViewport, renderReferenceArea, renderTextDecoration |
Methods inherited from class org.apache.fop.render.PrintRenderer |
---|
addFontList, getFontFromArea, getFontInfo, getFontList, getInternalFontNameForArea, instantiateRendererContext, renderDocument, setFontList |
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.Renderer |
---|
getMimeType |
Field Detail |
---|
protected double scaleFactor
protected int pageWidth
protected int pageHeight
protected java.util.List pageViewportList
protected boolean antialiasing
protected boolean qualityRendering
protected boolean transparentPageBackground
protected Java2DGraphicsState state
Constructor Detail |
---|
public Java2DRenderer(FOUserAgent userAgent)
userAgent
- the user agent that contains configuration details. This cannot be null.Method Detail |
---|
public FOUserAgent getUserAgent()
AbstractRenderer
getUserAgent
in interface Renderer
getUserAgent
in class AbstractRenderer
public void setupFontInfo(FontInfo inFontInfo)
setupFontInfo
in interface Renderer
setupFontInfo
in class PrintRenderer
inFontInfo
- The font informationpublic Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter
in interface Renderer
getGraphics2DAdapter
in class AbstractRenderer
public void setScaleFactor(double newScaleFactor)
newScaleFactor
- ]0 ; 1]public double getScaleFactor()
public void startRenderer(java.io.OutputStream out) throws java.io.IOException
startRenderer
in interface Renderer
startRenderer
in class AbstractRenderer
out
- The OutputStream to use for output
java.io.IOException
- If an I/O error occurspublic void stopRenderer() throws java.io.IOException
stopRenderer
in interface Renderer
stopRenderer
in class AbstractRenderer
java.io.IOException
- If an I/O error occurspublic boolean isRenderingDone()
public int getCurrentPageNumber()
public void setCurrentPageNumber(int c)
c
- the 0-based current page numberpublic int getNumberOfPages()
Pageable
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
- In case of an I/O error
FOPException
- if cloning of pageViewport is not supportedRenderer
protected void rememberPage(PageViewport pageViewport)
pageViewport
- the page viewportpublic 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.protected java.awt.image.BufferedImage getBufferedImage(int bitmapWidth, int bitmapHeight)
BufferedImage
to paint a page image on. This method can
be overridden in subclasses to produce different image formats (ex. grayscale or b/w).
bitmapWidth
- width of the image in pixelsbitmapHeight
- heigth of the image in pixels
public PageViewport getPageViewport(int pageIndex) throws FOPException
pageIndex
- the page index (zero-based)
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
- If there's a problem preparing the page imageprotected void saveGraphicsState()
saveGraphicsState
in class AbstractPathOrientedRenderer
protected void restoreGraphicsState()
restoreGraphicsState
in class AbstractPathOrientedRenderer
protected void concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
concatenateTransformationMatrix
in class AbstractPathOrientedRenderer
at
- the transformation matrix to process (coordinates in points)protected void startVParea(CTM ctm, java.awt.Rectangle clippingRect)
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.protected void endVParea()
endVParea
in class AbstractRenderer
protected void startLayer(java.lang.String layer)
startLayer
in class AbstractRenderer
layer
- name of layerprotected void endLayer()
endLayer
in class AbstractRenderer
protected java.util.List breakOutOfStateStack()
breakOutOfStateStack
in class AbstractPathOrientedRenderer
protected void restoreStateStackAfterBreakOut(java.util.List breakOutList)
restoreStateStackAfterBreakOut
in class AbstractPathOrientedRenderer
breakOutList
- the state stack to restore.protected void updateColor(java.awt.Color col, boolean fill)
updateColor
in class AbstractPathOrientedRenderer
col
- the color to apply (null skips this operation)fill
- true to set the fill color, false for the foreground colorprotected void clip()
clip
in class AbstractPathOrientedRenderer
protected void closePath()
closePath
in class AbstractPathOrientedRenderer
protected void lineTo(float x, float y)
lineTo
in class AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinateprotected void moveTo(float x, float y)
moveTo
in class AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinateprotected void clipRect(float x, float y, float width, float height)
clipRect
in class AbstractPathOrientedRenderer
x
- 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)protected void fillRect(float x, float y, float width, float height)
fillRect
in class AbstractPathOrientedRenderer
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangleprotected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, java.awt.Color col)
drawBorderLine
in class AbstractPathOrientedRenderer
x1
- 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 segmentpublic static void drawBorderLine(java.awt.geom.Rectangle2D.Float lineRect, boolean horz, boolean startOrBefore, int style, java.awt.Color col, java.awt.Graphics2D g2d)
lineRect
- the line defined by its bounding rectanglehorz
- 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 segmentg2d
- the Graphics2D instance to paint topublic void renderText(TextArea text)
renderText
in class AbstractRenderer
text
- the text to renderpublic static void renderText(TextArea text, java.awt.Graphics2D g2d, Font font)
text
- the TextAreag2d
- the Graphics2D to render tofont
- the font to paint withpublic void renderLeader(Leader area)
renderLeader
in class AbstractRenderer
area
- the leader area to renderpublic void renderImage(Image image, java.awt.geom.Rectangle2D pos)
renderImage
in class AbstractRenderer
image
- The imagepos
- The target position of the image
(todo) Make renderImage() protectedprotected void drawImage(java.lang.String uri, java.awt.geom.Rectangle2D pos, java.util.Map foreignAttributes)
drawImage
in class AbstractPathOrientedRenderer
uri
- the URI/URL of the imagepos
- the position of the imageforeignAttributes
- an optional Map with foreign attributes, may be nullprotected RendererContext createRendererContext(int x, int y, int width, int height, java.util.Map foreignAttributes)
createRendererContext
in class PrintRenderer
x
- 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 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
protected void beginTextObject()
beginTextObject
in class AbstractPathOrientedRenderer
protected void endTextObject()
endTextObject
in class AbstractPathOrientedRenderer
public void setTransparentPageBackground(boolean transparentPageBackground)
transparentPageBackground
- true if the background should be transparent
|
fop 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |