Class AWTRenderer

All Implemented Interfaces:
Pageable, Printable, Constants, Renderer

public class AWTRenderer extends Java2DRenderer implements Pageable
The AWTRender outputs the pages generated by the layout engine to a Swing window. This Swing window serves as default viewer for the -awt switch and as an example of how to embed the AWTRenderer into an AWT/Swing application.
  • Field Details

    • MIME_TYPE

      public static final String MIME_TYPE
      The MIME type for AWT-Rendering
      See Also:
    • debug

      public boolean debug
      flag for debugging
    • statusListener

      protected StatusListener statusListener
      Will be notified when rendering progresses
  • Constructor Details

    • AWTRenderer

      public AWTRenderer(FOUserAgent userAgent)
      Creates a new AWTRenderer instance.
      Parameters:
      userAgent - the user agent that contains configuration data
    • AWTRenderer

      public AWTRenderer(FOUserAgent userAgent, Renderable renderable, boolean previewAsMainWindow, boolean show)
      Creates a new AWTRenderer instance.
      Parameters:
      userAgent - the user agent that contains configuration data
      renderable - a Renderable instance can be set so the Preview Dialog can enable the "Reload" button which causes the current document to be reprocessed and redisplayed.
      previewAsMainWindow - true if the preview dialog created by the renderer should be the main window of the application.
      show - sets whether the preview dialog should be created and displayed when the rendering has finished.
  • Method Details

    • renderPage

      public void renderPage(PageViewport pageViewport) throws IOException, FOPException
      This method override only stores the PageViewport in a List. No actual rendering is performed here. A renderer override renderPage() to get the freshly produced PageViewport, and render them on the fly (producing the desired BufferedImages by calling getPageImage(), which lazily starts the rendering process).
      Specified by:
      renderPage in interface Renderer
      Overrides:
      renderPage in class Java2DRenderer
      Parameters:
      pageViewport - the PageViewport object supplied by the Area Tree
      Throws:
      FOPException - thrown by java2DRenderer
      IOException - In case of an I/O error
      See Also:
    • 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 Java2DRenderer
      Throws:
      IOException - If an I/O error occurs
    • getPageImageSize

      public Dimension getPageImageSize(int pageNum) throws FOPException
      Parameters:
      pageNum - the page number
      Returns:
      the dimensions of the specified page
      Throws:
      FOPException - If the page is out of range or has not been rendered.
    • getPageFormat

      public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException
      Specified by:
      getPageFormat in interface Pageable
      Throws:
      IndexOutOfBoundsException
    • getPrintable

      public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException
      Specified by:
      getPrintable in interface Pageable
      Throws:
      IndexOutOfBoundsException
    • supportsOutOfOrder

      public boolean supportsOutOfOrder()
      Check if this renderer supports out of order rendering. If this renderer supports out of order rendering then it means that the pages that are not ready will be prepared and a future page will be rendered.
      Specified by:
      supportsOutOfOrder in interface Renderer
      Overrides:
      supportsOutOfOrder in class AbstractRenderer
      Returns:
      True if the renderer supports out of order rendering
    • getMimeType

      public String getMimeType()
      Get the MIME type of the renderer.
      Specified by:
      getMimeType in interface Renderer
      Returns:
      The MIME type of the renderer, may return null if not applicable.
    • drawBackAndBorders

      protected void drawBackAndBorders(Area area, float startx, float starty, float width, float height)
      Draws the background and borders and adds a basic debug view // TODO implement visual-debugging as standalone Draw the background and borders. This draws the background and border traits for an area given the position. float, float, float, float)
      Overrides:
      drawBackAndBorders in class AbstractPathOrientedRenderer
      Parameters:
      area - the area to get the traits from
      startx - the start x position
      starty - the start y position
      width - the width of the area
      height - the height of the area
    • getStatusListener

      public StatusListener getStatusListener()
      Returns:
      the StatusListener.
    • setStatusListener

      public void setStatusListener(StatusListener statusListener)
      Sets a StatusListener this renderer uses to notify about events.
      Parameters:
      statusListener - The StatusListener to set.