|
fop 1.1 | |||||||||
| 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 |
static java.lang.String |
JAVA2D_TRANSPARENT_PAGE_BACKGROUND
Rendering Options key for the controlling the transparent page background option. |
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, fontResolver |
| 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 |
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. |
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 |
|---|
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, getFontResolver, 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 |
|---|
public static final java.lang.String JAVA2D_TRANSPARENT_PAGE_BACKGROUND
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 RenderergetUserAgent in class AbstractRendererpublic void setupFontInfo(FontInfo inFontInfo)
setupFontInfo in interface RenderersetupFontInfo in class PrintRendererinFontInfo - The font informationpublic Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter in interface RenderergetGraphics2DAdapter in class AbstractRendererpublic void setScaleFactor(double newScaleFactor)
newScaleFactor - ]0 ; 1]public double getScaleFactor()
public void startRenderer(java.io.OutputStream out)
throws java.io.IOException
startRenderer in interface RendererstartRenderer in class AbstractRendererout - The OutputStream to use for output
java.io.IOException - If an I/O error occurs
public void stopRenderer()
throws java.io.IOException
stopRenderer in interface RendererstopRenderer in class AbstractRendererjava.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()
Pageablepublic void clearViewportList()
public void renderPage(PageViewport pageViewport)
throws java.io.IOException,
FOPException
renderPage in interface RendererrenderPage in class AbstractRendererpageViewport - 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 supportedRendererprotected 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 AbstractPathOrientedRendererprotected void restoreGraphicsState()
restoreGraphicsState in class AbstractPathOrientedRendererprotected void concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
concatenateTransformationMatrix in class AbstractPathOrientedRendererat - the transformation matrix to process (coordinates in points)
protected void startVParea(CTM ctm,
java.awt.Rectangle 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.protected void endVParea()
endVParea in class AbstractRendererprotected java.util.List breakOutOfStateStack()
breakOutOfStateStack in class AbstractPathOrientedRendererprotected void restoreStateStackAfterBreakOut(java.util.List breakOutList)
restoreStateStackAfterBreakOut in class AbstractPathOrientedRendererbreakOutList - the state stack to restore.
protected 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 colorprotected void clip()
clip in class AbstractPathOrientedRendererprotected void closePath()
closePath in class AbstractPathOrientedRenderer
protected void lineTo(float x,
float y)
lineTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinate
protected void moveTo(float x,
float y)
moveTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinate
protected 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)
protected 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 rectangle
protected 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 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 AbstractRenderertext - the text to render
public 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 AbstractRendererarea - the leader area to render
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() protected
protected 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
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 int print(java.awt.Graphics g,
java.awt.print.PageFormat pageFormat,
int pageIndex)
throws java.awt.print.PrinterException
print in interface java.awt.print.Printablejava.awt.print.PrinterExceptionprotected void beginTextObject()
beginTextObject in class AbstractPathOrientedRendererprotected void endTextObject()
endTextObject in class AbstractPathOrientedRendererpublic void setTransparentPageBackground(boolean transparentPageBackground)
transparentPageBackground - true if the background should be transparent
|
fop 1.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||