|
fop 0.93 | ||||||||||
| 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
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 |
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.PrintRenderer |
fontInfo, fontList |
| 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 | |
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. |
void |
configure(org.apache.avalon.framework.configuration.Configuration cfg)
|
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 url,
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()
|
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 a page viewport. |
double |
getScaleFactor()
|
FOUserAgent |
getUserAgent()
|
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)
|
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 |
setupFontInfo(FontInfo inFontInfo)
Set up the font info |
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. |
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, drawBorders, drawImage, handleBlockTraits, handleRegionTraits, renderBlockViewport, renderForeignObject, renderInlineAreaBackAndBorders, renderTextDecoration, renderViewport |
| Methods inherited from class org.apache.fop.render.PrintRenderer |
getFontFromArea, getInternalFontNameForArea, lightenColor, renderDocument |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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()
| Method Detail |
public void configure(org.apache.avalon.framework.configuration.Configuration cfg)
throws org.apache.avalon.framework.configuration.ConfigurationException
configure in interface org.apache.avalon.framework.configuration.Configurableconfigure in class AbstractRendererorg.apache.avalon.framework.configuration.ConfigurationExceptionAbstractRenderer.configure(
org.apache.avalon.framework.configuration.Configuration)public void setUserAgent(FOUserAgent foUserAgent)
Renderer
setUserAgent in interface RenderersetUserAgent in class AbstractRendererRenderer.setUserAgent(org.apache.fop.apps.FOUserAgent)public FOUserAgent getUserAgent()
public void setupFontInfo(FontInfo inFontInfo)
PrintRenderer
setupFontInfo in interface RenderersetupFontInfo in class PrintRendererinFontInfo - font info to set upRenderer.setupFontInfo(org.apache.fop.fonts.FontInfo)public Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter in interface RenderergetGraphics2DAdapter in class AbstractRendererRenderer.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 RendererstartRenderer in class AbstractRendererjava.io.IOExceptionRenderer.startRenderer(java.io.OutputStream)
public void stopRenderer()
throws java.io.IOException
Renderer
stopRenderer in interface RendererstopRenderer in class AbstractRendererjava.io.IOExceptionRenderer.stopRenderer()public boolean isRenderingDone()
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
renderPage in interface RendererrenderPage in class AbstractRendererpageViewport - the PageViewport object supplied by
the Area Tree
java.io.IOException - In case of an I/O errorRendererpublic 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 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 - If there's a problem preparing the page imageprotected void saveGraphicsState()
saveGraphicsState in class AbstractPathOrientedRendererprotected void restoreGraphicsState()
restoreGraphicsState in class AbstractPathOrientedRenderer
protected void startVParea(CTM ctm,
java.awt.geom.Rectangle2D clippingRect)
AbstractRenderer
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.AbstractRenderer.startVParea(CTM, Rectangle2D)protected void endVParea()
AbstractRenderer
endVParea in class AbstractRendererAbstractRenderer.endVParea()protected java.util.List breakOutOfStateStack()
AbstractPathOrientedRenderer
breakOutOfStateStack in class AbstractPathOrientedRendererAbstractPathOrientedRenderer.breakOutOfStateStack()protected void restoreStateStackAfterBreakOut(java.util.List breakOutList)
AbstractPathOrientedRenderer
restoreStateStackAfterBreakOut in class AbstractPathOrientedRendererbreakOutList - the state stack to restore.AbstractPathOrientedRenderer.restoreStateStackAfterBreakOut(
java.util.List)
protected void updateColor(java.awt.Color col,
boolean fill)
AbstractPathOrientedRenderer
updateColor in class AbstractPathOrientedRenderercol - the color to apply (null skips this operation)fill - true to set the fill color, false for the foreground colorAbstractPathOrientedRenderer.updateColor(Color, boolean)protected void clip()
AbstractPathOrientedRenderer
clip in class AbstractPathOrientedRendererAbstractPathOrientedRenderer.clip()protected void closePath()
AbstractPathOrientedRenderer
closePath in class AbstractPathOrientedRendererAbstractPathOrientedRenderer.closePath()
protected void lineTo(float x,
float y)
AbstractPathOrientedRenderer
lineTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinateAbstractPathOrientedRenderer.lineTo(float, float)
protected void moveTo(float x,
float y)
AbstractPathOrientedRenderer
moveTo in class AbstractPathOrientedRendererx - x coordinatey - y coordinateAbstractPathOrientedRenderer.moveTo(float, float)
protected void clipRect(float x,
float y,
float width,
float height)
AbstractPathOrientedRenderer
clipRect in class AbstractPathOrientedRendererx - the x coordinatey - the y coordinatewidth - the width of the rectangleheight - the height of the rectangleAbstractPathOrientedRenderer.clipRect(float, float, float, float)
protected void fillRect(float x,
float y,
float width,
float height)
AbstractPathOrientedRenderer
fillRect in class AbstractPathOrientedRendererx - the x coordinatey - the y coordinatewidth - the width of the rectangleheight - the height of the rectangleAbstractPathOrientedRenderer.fillRect(float, float, float, float)
protected void drawBorderLine(float x1,
float y1,
float x2,
float y2,
boolean horz,
boolean startOrBefore,
int style,
java.awt.Color col)
AbstractPathOrientedRenderer
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 segmentAbstractPathOrientedRenderer.drawBorderLine(float, float, float, float, boolean, boolean, int, Color)
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)
AbstractRenderer
renderText in class AbstractRenderertext - the text to renderAbstractRenderer.renderText(TextArea)
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)
AbstractRenderer
renderImage in class AbstractRendererimage - The imagepos - The target position of the image
(todo) Make renderImage() protectedAbstractRenderer.renderImage(Image,
Rectangle2D)
protected void drawImage(java.lang.String url,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
AbstractPathOrientedRenderer
drawImage in class AbstractPathOrientedRendererurl - the URI/URL of the imagepos - the position of the imageforeignAttributes - an optional Map with foreign attributes, may be nullAbstractPathOrientedRenderer.drawImage(
java.lang.String, java.awt.geom.Rectangle2D, java.util.Map)
protected RendererContext createRendererContext(int x,
int y,
int width,
int height,
java.util.Map foreignAttributes)
PrintRenderer
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
PrintRenderer.createRendererContext(
int, int, int, int, java.util.Map)
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.PrinterExceptionPrintable.print(java.awt.Graphics,
java.awt.print.PageFormat, int)protected void beginTextObject()
AbstractPathOrientedRenderer
beginTextObject in class AbstractPathOrientedRendererAbstractPathOrientedRenderer.beginTextObject()protected void endTextObject()
AbstractPathOrientedRenderer
endTextObject in class AbstractPathOrientedRendererAbstractPathOrientedRenderer.endTextObject()
|
fop 0.93 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||