org.foray.render.xml
Class XMLRenderer

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

public class XMLRenderer
extends Renderer

Renderer that renders areas to XML for debugging purposes.


Field Summary
static String DOUBLE_QUOTE
          Constant used in string building.
 
Fields inherited from class org.foray.render.Renderer
SHADING_WEIGHT_BLUE, SHADING_WEIGHT_GREEN, SHADING_WEIGHT_RED
 
Constructor Summary
XMLRenderer(org.apache.commons.logging.Log logger, org.axsl.output.DocumentAreaConfiguration renderConfig)
          Constructor.
 
Method Summary
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.
 int[] getFontSources()
           
 org.axsl.output.DocumentAreaConfiguration getOutputConfiguration()
          Returns the output configuration for this renderer.
protected  void markBorder(org.axsl.galley.BorderPaddingArea area)
          Marks the border, if any, for the given area.
 void outputAllRectangles(org.axsl.galley.Area area)
          Writes information about all of an area's rectangles.
 void outputAttribute(StringBuilder buffer, String attributeName, CharSequence attributeValue)
          Writes information about a specific attribute to a given buffer.
 void outputAttribute(StringBuilder buffer, String attributeName, long attributeValue)
          Writes information about a specific integral attribute to a given buffer.
 void outputBorderRectangle(org.axsl.galley.Area area)
          Writes information about an area's border rectangle to a given buffer.
 void outputColor(org.axsl.galley.GeneralInlineArea area, StringBuilder buffer)
          Writes information about an area's color to a given buffer.
 void outputContentRectangle(org.axsl.galley.Area area)
          Writes information about an area's content rectangle to a given buffer.
 void outputPaddingRectangle(org.axsl.galley.Area area)
          Writes information about an area's padding rectangle to a given buffer.
 void outputText(char[] chars, StringBuilder buffer)
          Writes text to a given buffer, converting it to well-formed XML as it goes.
 void render(org.axsl.galley.Area area)
           
 void render(org.axsl.galley.AreaNode node)
           
 void render(org.axsl.galley.BeforeFloatArea area)
           
 void render(org.axsl.galley.BlockContainerArea area)
           
 void render(org.axsl.galley.BookmarkTree area)
          Render the bookmark tree for this document.
 void render(org.axsl.galley.ExternalGraphicArea area)
           
 void render(org.axsl.galley.FootnoteArea area)
           
 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.ForeignObjectArea area)
           
 void render(org.axsl.galley.InlineArea area)
           
 void render(org.axsl.galley.LeaderArea area)
           
 void render(org.axsl.galley.LineArea area)
           
 void render(org.axsl.galley.MainReferenceArea area)
           
 void render(org.axsl.galley.NormalBlockArea area)
           
 void render(org.axsl.galley.Page page)
           
 void render(org.axsl.galley.RegionArea area)
           
 void render(org.axsl.galley.TableArea area)
           
 void render(org.axsl.galley.TableCellArea area)
           
 void render(org.axsl.galley.TextArea area)
           
protected  void renderContent(CharSequence content)
          Render the content part of an area.
 void renderInlineArea(org.axsl.galley.GeneralInlineArea area)
          Renders an inline area not covered by a more specific method.
 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()
           
protected  void writeCompleteElement(org.axsl.galley.Area area, StringBuilder attributes, String content)
          Write the start tag, attributes, content, and end-tag for an element.
protected  void writeEmptyElement(org.axsl.galley.Area area, StringBuilder attributes)
          Write the start tag, attribues, and end-tag for an element.
protected  void writeEmptyElement(String elementName, StringBuilder attributes)
          Write the start tag, attribues, and end-tag for an element.
protected  void writeEndTag(org.axsl.galley.AreaNode node)
          Write an end tag.
protected  void writeIndent()
          Write out the spaces to make an indentation.
protected  void writeStartTag(org.axsl.galley.AreaNode node, StringBuilder attributes)
          Write the start tag, attribues, and end-tag for an element.
 
Methods inherited from class org.foray.render.Renderer
colorToFloat, convertMillipointRectangle, getAreaTree, getPixelsPerInch, markBackground, 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
 

Field Detail

DOUBLE_QUOTE

public static final String DOUBLE_QUOTE
Constant used in string building.

See Also:
Constant Field Values
Constructor Detail

XMLRenderer

public XMLRenderer(org.apache.commons.logging.Log logger,
                   org.axsl.output.DocumentAreaConfiguration renderConfig)
Constructor.

Parameters:
logger - The logger.
renderConfig - The configuration for this renderer.
Method Detail

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

writeIndent

protected void writeIndent()
Write out the spaces to make an indentation.


writeCompleteElement

protected void writeCompleteElement(org.axsl.galley.Area area,
                                    StringBuilder attributes,
                                    String content)
Write the start tag, attributes, content, and end-tag for an element.

Parameters:
area - The area for whom the element is written.
attributes - Text of the attributes to be written.
content - The element content.

writeEmptyElement

protected void writeEmptyElement(org.axsl.galley.Area area,
                                 StringBuilder attributes)
Write the start tag, attribues, and end-tag for an element.

Parameters:
area - The area for whom element is written.
attributes - Text of the attributes to be written.

writeEmptyElement

protected void writeEmptyElement(String elementName,
                                 StringBuilder attributes)
Write the start tag, attribues, and end-tag for an element.

Parameters:
elementName - The name of the element to be written.
attributes - Text of the attributes to be written.

writeStartTag

protected void writeStartTag(org.axsl.galley.AreaNode node,
                             StringBuilder attributes)
Write the start tag, attribues, and end-tag for an element.

Parameters:
node - The area for whom element is written.
attributes - Text of the attributes to be written.

writeEndTag

protected void writeEndTag(org.axsl.galley.AreaNode node)
Write an end tag.

Parameters:
node - The area whose end-tag should be written.

drawGraphic

protected void drawGraphic(org.axsl.galley.GraphicArea area,
                           org.axsl.graphic.Graphic image,
                           Rectangle contentRectangle,
                           Rectangle clipRectangle)
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.
See Also:
Renderer.drawGraphic(GraphicArea, Graphic, Rectangle, Rectangle)

render

public void render(org.axsl.galley.BlockContainerArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.MainReferenceArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.RegionArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.FootnoteArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.BeforeFloatArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.NormalBlockArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

renderInlineArea

public void renderInlineArea(org.axsl.galley.GeneralInlineArea area)
                      throws org.axsl.galley.GalleyVisitorException
Renders an inline area not covered by a more specific method.

Parameters:
area - The Area to be rendered.
Throws:
org.axsl.galley.GalleyVisitorException - For errors during rendering.

render

public void render(org.axsl.galley.ForeignObjectArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.ForeignContentSvg area)
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.

render

public void render(org.axsl.galley.ForeignContentMath area)
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.

render

public void render(org.axsl.galley.ExternalGraphicArea area)
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer

renderTextSegment

public void renderTextSegment(org.axsl.galley.TextArea area,
                              CharSequence text)
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.

render

public void render(org.axsl.galley.LineArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

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.

render

public void render(org.axsl.galley.LeaderArea area)

render

public void render(org.axsl.galley.TextArea area)

renderContent

protected void renderContent(CharSequence content)
Render the content part of an area.

Parameters:
content - The content to be rendered.

render

public void render(org.axsl.galley.InlineArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.TableArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.TableCellArea area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.AreaNode node)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

render

public void render(org.axsl.galley.Area area)
            throws org.axsl.galley.GalleyVisitorException
Specified by:
render in interface org.axsl.galley.RenderVisitor
Overrides:
render in class Renderer
Throws:
org.axsl.galley.GalleyVisitorException

startOutput

public void startOutput()

stopOutput

public void stopOutput()

getFontSources

public int[] getFontSources()

drawLine

protected void drawLine(int startX,
                        int startY,
                        int endX,
                        int endY,
                        int thickness,
                        org.axsl.common.value.RuleStyle ruleStyle,
                        Color strokeColor)
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.

drawRectangle

protected void drawRectangle(int x,
                             int y,
                             int w,
                             int h,
                             Color strokeColor,
                             Color fillColor)
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.

markBorder

protected void markBorder(org.axsl.galley.BorderPaddingArea area)
Description copied from class: Renderer
Marks the border, if any, for the given area.

Specified by:
markBorder in class Renderer
Parameters:
area - The area whose border is to be drawn.

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

outputAllRectangles

public void outputAllRectangles(org.axsl.galley.Area area)
Writes information about all of an area's rectangles.

Parameters:
area - The area whose rectangles are to be written.

outputBorderRectangle

public void outputBorderRectangle(org.axsl.galley.Area area)
Writes information about an area's border rectangle to a given buffer.

Parameters:
area - The area whose border rectangle information should be written.

outputPaddingRectangle

public void outputPaddingRectangle(org.axsl.galley.Area area)
Writes information about an area's padding rectangle to a given buffer.

Parameters:
area - The area whose padding rectangle information should be written.

outputContentRectangle

public void outputContentRectangle(org.axsl.galley.Area area)
Writes information about an area's content rectangle to a given buffer.

Parameters:
area - The area whose content rectangle information should be written.

outputColor

public void outputColor(org.axsl.galley.GeneralInlineArea area,
                        StringBuilder buffer)
Writes information about an area's color to a given buffer.

Parameters:
area - The area whose color information should be written.
buffer - The buffer to which the attributes should be added.

outputAttribute

public void outputAttribute(StringBuilder buffer,
                            String attributeName,
                            CharSequence attributeValue)
Writes information about a specific attribute to a given buffer.

Parameters:
buffer - The buffer to which the attribute should be added.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.

outputAttribute

public void outputAttribute(StringBuilder buffer,
                            String attributeName,
                            long attributeValue)
Writes information about a specific integral attribute to a given buffer.

Parameters:
buffer - The buffer to which the attribute should be added.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.

outputText

public void outputText(char[] chars,
                       StringBuilder buffer)
Writes text to a given buffer, converting it to well-formed XML as it goes.

Parameters:
chars - The text to be written.
buffer - The buffer to which the text should be written.

getOutputConfiguration

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

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


Copyright © 2017. All rights reserved.