org.foray.render.pdf
Class PDFRenderer

java.lang.Object
  extended by org.foray.output.OutputTarget
      extended by org.foray.render.Renderer
          extended by org.foray.render.PrintRenderer
              extended by org.foray.render.pdf.PDFRenderer
All Implemented Interfaces:
org.axsl.galley.RenderVisitor, org.axsl.output.OutputTarget, org.axsl.output.Renderer

public class PDFRenderer
extends PrintRenderer

Renderer for PDF output.


Field Summary
 
Fields inherited from class org.foray.render.Renderer
SHADING_WEIGHT_BLUE, SHADING_WEIGHT_GREEN, SHADING_WEIGHT_RED
 
Constructor Summary
PDFRenderer(org.apache.commons.logging.Log logger, org.axsl.output.DocumentPdfConfiguration renderConfig, org.axsl.pdf.PdfDocument document)
          Constructor.
 
Method Summary
protected  void createBasicLink(org.axsl.galley.Area area)
          Marks a specified area as being a link.
protected  void drawGraphic(org.axsl.galley.GraphicArea area, org.axsl.graphic.Graphic image, Rectangle contentRectangle, Rectangle clipRectangle)
          Renders a Graphic to a given contentRectangle, and clipping it to a given clip rectangle.
protected  void drawLine(int startX, int startY, int endX, int endY, int thickness, org.axsl.common.value.RuleStyle ruleStyle, Color strokeColor)
          Draw a line in the output document.
protected  void drawRectangle(int x, int y, int w, int h, Color strokeColor, Color fillColor)
          Draw a rectangle in the output document.
 org.axsl.output.DocumentPdfConfiguration getOutputConfiguration()
          Returns the output configuration for this renderer.
 org.axsl.pdf.PdfDocument getPDFDocument()
          Returns the PDFDocument instance being rendered.
 void render(org.axsl.galley.BookmarkTree area)
          Render the bookmark tree for this document.
 void render(org.axsl.galley.ForeignContentMath area)
          Render the MathML content of a ForeignObjectArea.
 void render(org.axsl.galley.ForeignContentSvg area)
          Render the SVG content of a ForeignObjectArea.
 void render(org.axsl.galley.Page page)
           
 void renderBookmark(org.axsl.galley.Bookmark area, org.axsl.pdf.PdfOutlineParent parent)
          Render a bookmark, using recursion to render child bookmarks as well.
 void renderTextSegment(org.axsl.galley.TextArea area, CharSequence text)
          Renders an arbitrary text chunk with attributes from an arbitrary Area.
 void resetTextCursor()
          Provides the Renderer with an opportunity to close any text objects that are in progress.
 void startOutput()
           
 void stopOutput()
           
 
Methods inherited from class org.foray.render.PrintRenderer
getFontSources, getOverlineYPosition, getThroughYPosition, getUnderlineYPosition, markBorder, render, render, renderGenericSpace
 
Methods inherited from class org.foray.render.Renderer
colorToFloat, convertMillipointRectangle, getAreaTree, getPixelsPerInch, markBackground, render, render, render, render, render, render, render, render, render, render, render, render, render, render, renderChildren, renderDocumentNodes, renderRegions, setGalley, shadingPercent, toPoints
 
Methods inherited from class org.foray.output.OutputTarget
getApplicationName, getApplicationNameShort, getApplicationVersion, getDeveloperURLShort, getFontConsumer, getLogger, getOutputStream, getStrokeSVGText, outputStreamRequired, setApplicationName, setApplicationNameShort, setApplicationVersion, setDeveloperUrlShort, setFontConsumer, setOutputStream, setStrokeText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axsl.output.OutputTarget
outputStreamRequired, setApplicationName, setApplicationNameShort, setApplicationVersion, setDeveloperUrlShort, setFontConsumer, setOutputStream, setStrokeText
 

Constructor Detail

PDFRenderer

public PDFRenderer(org.apache.commons.logging.Log logger,
                   org.axsl.output.DocumentPdfConfiguration renderConfig,
                   org.axsl.pdf.PdfDocument document)
Constructor.

Parameters:
logger - The logger.
renderConfig - The configuration for this renderer.
document - The PDF document to be created.
Method Detail

startOutput

public void startOutput()
                 throws org.axsl.output.OutputException
Throws:
org.axsl.output.OutputException

stopOutput

public void stopOutput()
                throws org.axsl.output.OutputException
Throws:
org.axsl.output.OutputException

drawLine

protected void drawLine(int startX,
                        int startY,
                        int endX,
                        int endY,
                        int thickness,
                        org.axsl.common.value.RuleStyle ruleStyle,
                        Color strokeColor)
                 throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Draw a line in the output document.

Specified by:
drawLine in class Renderer
Parameters:
startX - The start x location in millipoints.
startY - The start y location in millipoints.
endX - The end x location in millipoints.
endY - The end y location in millipoints.
thickness - The thickness in millipoints.
ruleStyle - The rule style.
strokeColor - The stroke color.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

drawRectangle

protected void drawRectangle(int x,
                             int y,
                             int w,
                             int h,
                             Color strokeColor,
                             Color fillColor)
                      throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Draw a rectangle in the output document.

Specified by:
drawRectangle in class Renderer
Parameters:
x - The x position of left edge in millipoints.
y - The y position of top edge in millipoints.
w - The width in millipoints.
h - The height in millipoints.
strokeColor - The color to be used for the stroke. Stroked means a box will be drawn around the rectangle. Set to null if the rectangle should not be stroked.
fillColor - The color to be used for the fill. Set to null if the rectangle should not be filled.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

drawGraphic

protected void drawGraphic(org.axsl.galley.GraphicArea area,
                           org.axsl.graphic.Graphic image,
                           Rectangle contentRectangle,
                           Rectangle clipRectangle)
                    throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Renders a Graphic to a given contentRectangle, and clipping it to a given clip rectangle. If the content rectangle is the same as the intrinsic dimensions of the image, no scaling is done.

Specified by:
drawGraphic in class Renderer
Parameters:
area - The Area instance from which to obtain traits.
image - The graphic to be rendered.
contentRectangle - The rectangle to which the graphic should be scaled during drawing.
clipRectangle - The rectangle to which the content should be clipped after any scaling.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.
See Also:
Renderer.drawGraphic(GraphicArea, Graphic, Rectangle, Rectangle)

render

public void render(org.axsl.galley.ForeignContentSvg area)
            throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Render the SVG content of a ForeignObjectArea.

Specified by:
render in class Renderer
Parameters:
area - The SVG content to be rendered.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

render

public void render(org.axsl.galley.ForeignContentMath area)
            throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Render the MathML content of a ForeignObjectArea.

Specified by:
render in class Renderer
Parameters:
area - The MathML content to be rendered.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

renderTextSegment

public void renderTextSegment(org.axsl.galley.TextArea area,
                              CharSequence text)
                       throws org.axsl.galley.GalleyVisitorException
Description copied from class: Renderer
Renders an arbitrary text chunk with attributes from an arbitrary Area. Of course, ordinarily, the text will come from the Area, but the caller should decide that.

Specified by:
renderTextSegment in class Renderer
Parameters:
area - An Area instance that contains the traits that should be used to render the text.
text - The text content to be rendered.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

render

public void render(org.axsl.galley.Page page)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.output.Renderer
Specified by:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

createBasicLink

protected void createBasicLink(org.axsl.galley.Area area)
Marks a specified area as being a link.

Parameters:
area - The area which should be marked as a link.

render

public void render(org.axsl.galley.BookmarkTree area)
Description copied from class: Renderer
Render the bookmark tree for this document.

Specified by:
render in class Renderer
Parameters:
area - The bookmark tree to be rendered.

renderBookmark

public void renderBookmark(org.axsl.galley.Bookmark area,
                           org.axsl.pdf.PdfOutlineParent parent)
Render a bookmark, using recursion to render child bookmarks as well.

Parameters:
area - The bookmark area to be rendered.
parent - The PDF outline object to which the rendered bookmarks should be added.

resetTextCursor

public void resetTextCursor()
Description copied from class: Renderer
Provides the Renderer with an opportunity to close any text objects that are in progress.

Specified by:
resetTextCursor in class Renderer

getPDFDocument

public org.axsl.pdf.PdfDocument getPDFDocument()
Returns the PDFDocument instance being rendered.

Returns:
The PDFDocument being rendered.

getOutputConfiguration

public org.axsl.output.DocumentPdfConfiguration getOutputConfiguration()
Description copied from class: OutputTarget
Returns the output configuration for this renderer.

Specified by:
getOutputConfiguration in class PrintRenderer
Returns:
The output configuration for this renderer.


Copyright © 2017. All rights reserved.