Class AbstractPSDocumentGraphics2D

    • Field Detail

      • ZERO

        protected static final java.lang.Integer ZERO
      • width

        protected int width
      • height

        protected int height
      • viewportWidth

        protected float viewportWidth
      • viewportHeight

        protected float viewportHeight
      • pagecount

        protected int pagecount
      • pagePending

        protected boolean pagePending
      • initialClip

        protected java.awt.Shape initialClip
      • initialTransform

        protected java.awt.geom.AffineTransform initialTransform
    • Constructor Detail

      • AbstractPSDocumentGraphics2D

        AbstractPSDocumentGraphics2D​(boolean textAsShapes)
        Create a new AbstractPSDocumentGraphics2D. This is used to create a new PostScript document, the height, width and output stream can be setup later. For use by the transcoder which needs font information for the bridge before the document size is known. The resulting document is written to the stream after rendering.
        Parameters:
        textAsShapes - set this to true so that text will be rendered using curves and not the font.
      • AbstractPSDocumentGraphics2D

        public AbstractPSDocumentGraphics2D​(boolean textAsShapes,
                                            java.io.OutputStream stream,
                                            int width,
                                            int height)
                                     throws java.io.IOException
        Create a new AbstractPSDocumentGraphics2D. This is used to create a new PostScript document of the given height and width. The resulting document is written to the stream after rendering.
        Parameters:
        textAsShapes - set this to true so that text will be rendered using curves and not the font.
        stream - the stream that the final document should be written to.
        width - the width of the document
        height - the height of the document
        Throws:
        java.io.IOException - an io exception if there is a problem writing to the output stream
      • AbstractPSDocumentGraphics2D

        public AbstractPSDocumentGraphics2D​(AbstractPSDocumentGraphics2D g)
        This constructor supports the create method
        Parameters:
        g - the PostScript document graphics to make a copy of
    • Method Detail

      • setupDocument

        public void setupDocument​(java.io.OutputStream stream,
                                  int width,
                                  int height)
                           throws java.io.IOException
        Setup the document.
        Parameters:
        stream - the output stream to write the document
        width - the width of the page
        height - the height of the page
        Throws:
        java.io.IOException - an io exception if there is a problem writing to the output stream
      • writeFileHeader

        protected abstract void writeFileHeader()
                                         throws java.io.IOException
        Writes the file header.
        Throws:
        java.io.IOException - if an I/O error occurs
      • setViewportDimension

        public void setViewportDimension​(float w,
                                         float h)
                                  throws java.io.IOException
        Set the dimensions of the document that will be drawn. This is useful if the dimensions of the document are different from the PostScript document that is to be created. The result is scaled so that the document fits correctly inside the PostScript document.
        Parameters:
        w - the width of the page
        h - the height of the page
        Throws:
        java.io.IOException - in case of an I/O problem
      • setBackgroundColor

        public void setBackgroundColor​(java.awt.Color col)
        Set the background of the PostScript document. This is used to set the background for the PostScript document Rather than leaving it as the default white.
        Parameters:
        col - the background colour to fill
      • getPageCount

        public int getPageCount()
        Returns the number of pages generated so far.
        Returns:
        the number of pages
      • nextPage

        public void nextPage()
                      throws java.io.IOException
        Closes the current page and prepares to start a new one.
        Throws:
        java.io.IOException - if an I/O error occurs
      • closePage

        protected void closePage()
                          throws java.io.IOException
        Closes the current page.
        Throws:
        java.io.IOException - if an I/O error occurs
      • writePageHeader

        protected abstract void writePageHeader()
                                         throws java.io.IOException
        Writes the page header for a page.
        Throws:
        java.io.IOException - In case an I/O error occurs
      • writePageTrailer

        protected abstract void writePageTrailer()
                                          throws java.io.IOException
        Writes the page trailer for a page.
        Throws:
        java.io.IOException - In case an I/O error occurs
      • writeProcSets

        protected void writeProcSets()
                              throws java.io.IOException
        Writes the ProcSets ending up in the prolog to the PostScript file. Override to add your own ProcSets if so desired.
        Throws:
        java.io.IOException - In case an I/O error occurs
      • preparePainting

        public void preparePainting()
        This method is used by AbstractPSDocumentGraphics2D to prepare a new page if necessary.
        Overrides:
        preparePainting in class PSGraphics2D
      • startPage

        protected void startPage()
                          throws java.io.IOException
        Starts a new page.
        Throws:
        java.io.IOException - if an I/O error occurs
      • finish

        public void finish()
                    throws java.io.IOException
        The rendering process has finished. This should be called after the rendering has completed as there is no other indication it is complete. This will then write the results to the output stream.
        Throws:
        java.io.IOException - an io exception if there is a problem writing to the output stream