Class XMLRenderer

All Implemented Interfaces:
Constants, Renderer

public class XMLRenderer extends AbstractXMLRenderer
Renderer that renders areas to XML for debugging purposes. This creates an xml that contains the information of the area tree. It does not output any state or derived information. The output can be used to build a new area tree which can be rendered to any renderer.
  • Field Details

    • VERSION

      public static final String VERSION
      Area Tree (AT) version, used to express an @version attribute in the root element of the AT document, the initial value of which is set to '2.0' to signify that something preceded it (but didn't happen to be marked as such), and that this version is not necessarily backwards compatible with the unmarked (<2.0) version.
      See Also:
    • XML_MIME_TYPE

      public static final String XML_MIME_TYPE
      XML MIME type
      See Also:
    • mimic

      protected Renderer mimic
      If not null, the XMLRenderer will mimic another renderer by using its font setup.
  • Constructor Details

    • XMLRenderer

      public XMLRenderer(FOUserAgent userAgent)
      Parameters:
      userAgent - the user agent that contains configuration details. This cannot be null.
  • Method Details

    • mimicRenderer

      public void mimicRenderer(Renderer renderer)
      Call this method to make the XMLRenderer mimic a different renderer by using its font setup. This is useful when working with the intermediate format parser.
      Parameters:
      renderer - the renderer to mimic
    • setupFontInfo

      public void setupFontInfo(FontInfo inFontInfo) throws FOPException
      Set up the given FontInfo.
      Specified by:
      setupFontInfo in interface Renderer
      Overrides:
      setupFontInfo in class PrintRenderer
      Parameters:
      inFontInfo - The font information
      Throws:
      FOPException - if an error occurs while setting up the font info object
    • setCompactFormat

      public void setCompactFormat(boolean compact)
      Controls whether to create a more compact format which omit certain attributes.
      Parameters:
      compact - true to activate the compact format
    • addAreaAttributes

      protected void addAreaAttributes(Area area)
      Adds the general Area attributes.
      Parameters:
      area - Area to extract attributes from
    • addTraitAttributes

      protected void addTraitAttributes(Area area)
      Adds attributes from traits of an Area.
      Parameters:
      area - Area to extract traits from
    • processOffDocumentItem

      public void processOffDocumentItem(OffDocumentItem oDI)
      Tells the renderer to process an item not explicitly placed on the document (e.g., PDF bookmarks). Note - not all renderers will process all off-document items.
      Specified by:
      processOffDocumentItem in interface Renderer
      Overrides:
      processOffDocumentItem in class AbstractXMLRenderer
      Parameters:
      oDI - The off-document item to be rendered
    • renderBookmarkTree

      protected void renderBookmarkTree(BookmarkData bookmarkRoot)
      Renders a BookmarkTree object
      Specified by:
      renderBookmarkTree in class AbstractXMLRenderer
      Parameters:
      bookmarkRoot - the BookmarkData object representing the top of the tree
    • renderDestination

      protected void renderDestination(DestinationData destination)
      Renders a DestinationData object (named destination)
      Parameters:
      destination - the destination object
    • startRenderer

      public void startRenderer(OutputStream outputStream) throws IOException
      Initiates the rendering phase. This must only be called once for a rendering. If stopRenderer is called then this may be called again for a new document rendering.
      Specified by:
      startRenderer in interface Renderer
      Overrides:
      startRenderer in class AbstractXMLRenderer
      Parameters:
      outputStream - The OutputStream to use for output
      Throws:
      IOException - If an I/O error occurs
    • stopRenderer

      public void stopRenderer() throws IOException
      Signals the end of the rendering phase. The renderer should reset to an initial state and dispose of any resources for the completed rendering.
      Specified by:
      stopRenderer in interface Renderer
      Overrides:
      stopRenderer in class AbstractXMLRenderer
      Throws:
      IOException - If an I/O error occurs
    • renderPage

      public void renderPage(PageViewport page) throws IOException, FOPException
      Tells the renderer to render a particular page. A renderer typically responds by packing up the current page and writing it immediately to the output device.
      Specified by:
      renderPage in interface Renderer
      Overrides:
      renderPage in class AbstractRenderer
      Parameters:
      page - The page to be rendered
      Throws:
      IOException - if an I/O error occurs
      FOPException - if a FOP interal error occurs.
    • handleExtensionAttachments

      protected void handleExtensionAttachments(List attachments)
      Handles a list of extension attachments
      Specified by:
      handleExtensionAttachments in class AbstractXMLRenderer
      Parameters:
      attachments - a list of extension attachments
    • startPageSequence

      public void startPageSequence(PageSequence pageSequence)
      Tells the renderer that a new page sequence starts.
      Specified by:
      startPageSequence in interface Renderer
      Overrides:
      startPageSequence in class AbstractRenderer
      Parameters:
      pageSequence - the page sequence
    • endPageSequence

      public void endPageSequence()
      Tells the renderer to finish the current PageSequence
    • renderRegionViewport

      protected void renderRegionViewport(RegionViewport port)
      Renders a region viewport.

      The region may clip the area and it establishes a position from where the region is placed.

      Overrides:
      renderRegionViewport in class AbstractRenderer
      Parameters:
      port - The region viewport to be rendered
    • startVParea

      protected void startVParea(CTM ctm, Rectangle clippingRect)
      Description copied from class: AbstractRenderer
      Establishes a new viewport area.
      Specified by:
      startVParea in class AbstractRenderer
      Parameters:
      ctm - the coordinate transformation matrix to use
      clippingRect - the clipping rectangle if the viewport should be clipping, null if no clipping is performed.
    • endVParea

      protected void endVParea()
      Signals exit from a viewport area. Subclasses can restore transformation matrices valid before the viewport area was started.
      Specified by:
      endVParea in class AbstractRenderer
    • startLayer

      protected void startLayer(String layer)
      Establish new optional content group layer.
      Specified by:
      startLayer in class AbstractRenderer
      Parameters:
      layer - name of layer
    • endLayer

      protected void endLayer()
      Finish current optional content group layer.
      Specified by:
      endLayer in class AbstractRenderer
    • renderInlineAreaBackAndBorders

      protected void renderInlineAreaBackAndBorders(InlineArea area)
      Common method to render the background and borders for any inline area. The all borders and padding are drawn outside the specified area. org.apache.fop.area.inline.InlineArea)
      Specified by:
      renderInlineAreaBackAndBorders in class AbstractRenderer
      Parameters:
      area - the inline area for which the background, border and padding is to be rendered
    • renderBeforeFloat

      protected void renderBeforeFloat(BeforeFloat bf)
      Renders a before float area.
      Overrides:
      renderBeforeFloat in class AbstractRenderer
      Parameters:
      bf - The before float area
    • renderFootnote

      protected void renderFootnote(Footnote footnote)
      Renders a footnote
      Overrides:
      renderFootnote in class AbstractRenderer
      Parameters:
      footnote - The footnote
    • renderMainReference

      protected void renderMainReference(MainReference mr)
      Renders the main reference area.

      The main reference area contains a list of spans that are stacked on the page. The spans contain a list of normal flow reference areas that are positioned into columns.

      Overrides:
      renderMainReference in class AbstractRenderer
      Parameters:
      mr - The main reference area
    • renderFlow

      protected void renderFlow(NormalFlow flow)
      Renders a flow reference area.
      Overrides:
      renderFlow in class AbstractRenderer
      Parameters:
      flow - The flow reference area
    • renderReferenceArea

      protected void renderReferenceArea(Block block)
      Renders a block area that represents a reference area. The reference area establishes a new coordinate system.
      Specified by:
      renderReferenceArea in class AbstractRenderer
      Parameters:
      block - the block area
    • renderBlock

      protected void renderBlock(Block block)
      Renders a block area.
      Overrides:
      renderBlock in class AbstractRenderer
      Parameters:
      block - The block area
    • renderInlineBlock

      protected void renderInlineBlock(InlineBlock inlineBlock)
      Renders an inline block area.
      Overrides:
      renderInlineBlock in class AbstractRenderer
      Parameters:
      inlineBlock - The inline block area
    • renderLineArea

      protected void renderLineArea(LineArea line)
      Renders a line area.

      A line area may have grouped styling for its children such as underline, background.

      Overrides:
      renderLineArea in class AbstractRenderer
      Parameters:
      line - The line area
    • renderInlineArea

      protected void renderInlineArea(InlineArea inlineArea)
      Render the given InlineArea.
      Overrides:
      renderInlineArea in class AbstractRenderer
      Parameters:
      inlineArea - inline area text to render
    • renderInlineViewport

      protected void renderInlineViewport(InlineViewport viewport)
      Render the given Viewport.
      Overrides:
      renderInlineViewport in class AbstractRenderer
      Parameters:
      viewport - the viewport to render
    • renderImage

      public void renderImage(Image image, Rectangle2D pos)
      Renders an image area.
      Overrides:
      renderImage in class AbstractRenderer
      Parameters:
      image - The image
      pos - The target position of the image (todo) Make renderImage() protected
    • renderContainer

      public void renderContainer(Container cont)
      Tells the renderer to render an inline container.
      Overrides:
      renderContainer in class AbstractRenderer
      Parameters:
      cont - The inline container area
    • renderForeignObject

      public void renderForeignObject(ForeignObject fo, Rectangle2D pos)
      Renders an fo:foreing-object.
      Overrides:
      renderForeignObject in class AbstractRenderer
      Parameters:
      fo - the foreign object
      pos - the position of the foreign object
      See Also:
    • renderInlineSpace

      protected void renderInlineSpace(Space space)
      Render the given Space.
      Overrides:
      renderInlineSpace in class AbstractRenderer
      Parameters:
      space - the space to render
    • renderText

      protected void renderText(TextArea text)
      Render the given TextArea.
      Overrides:
      renderText in class AbstractRenderer
      Parameters:
      text - the text to render
    • renderWord

      protected void renderWord(WordArea word)
      Render the given WordArea.
      Overrides:
      renderWord in class AbstractRenderer
      Parameters:
      word - the word to render
    • renderSpace

      protected void renderSpace(SpaceArea space)
      Render the given SpaceArea.
      Overrides:
      renderSpace in class AbstractRenderer
      Parameters:
      space - the space to render
    • renderInlineParent

      protected void renderInlineParent(InlineParent ip)
      Render the given InlineParent.
      Overrides:
      renderInlineParent in class AbstractRenderer
      Parameters:
      ip - the inline parent to render
    • renderInlineBlockParent

      protected void renderInlineBlockParent(InlineBlockParent ibp)
      Render the given InlineBlockParent.
      Overrides:
      renderInlineBlockParent in class AbstractRenderer
      Parameters:
      ibp - the inline block parent to render
    • renderLeader

      protected void renderLeader(Leader area)
      Render the given Leader.
      Overrides:
      renderLeader in class AbstractRenderer
      Parameters:
      area - the leader to render
    • getMimeType

      public String getMimeType()
      Get the MIME type of the renderer.
      Returns:
      The MIME type of the renderer, may return null if not applicable.