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 Detail

      • VERSION

        public static final java.lang.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:
        Constant Field Values
      • XML_MIME_TYPE

        public static final java.lang.String XML_MIME_TYPE
        XML MIME type
        See Also:
        Constant Field Values
      • mimic

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

      • XMLRenderer

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

      • 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
      • 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
      • 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​(java.io.OutputStream outputStream)
                           throws java.io.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:
        java.io.IOException - If an I/O error occurs
      • stopRenderer

        public void stopRenderer()
                          throws java.io.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:
        java.io.IOException - If an I/O error occurs
      • renderPage

        public void renderPage​(PageViewport page)
                        throws java.io.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:
        java.io.IOException - if an I/O error occurs
        FOPException - if a FOP interal error occurs.
      • handleExtensionAttachments

        protected void handleExtensionAttachments​(java.util.List attachments)
        Handles a list of extension attachments
        Specified by:
        handleExtensionAttachments in class AbstractXMLRenderer
        Parameters:
        attachments - a list of extension attachments
      • 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,
                                   java.awt.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​(java.lang.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
      • 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
      • 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
      • renderImage

        public void renderImage​(Image image,
                                java.awt.geom.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
      • 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
      • renderLeader

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

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