Package pdf

Class PDFGraphics

  • All Implemented Interfaces:
    java.io.Serializable

    public class PDFGraphics
    extends java.awt.Graphics2D
    implements java.io.Serializable
    This class is our implementation of AWT's Graphics class. It provides a Java standard way of rendering into a PDF Document's Page.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Rectangle clipRectangle
      This holds the current clipRectangle
      protected float trax
      This is used to translate coordinates
      protected float tray
      This is used to translate coordinates
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFGraphics()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRenderingHints​(java.util.Map<?,​?> hints)  
      void arc​(double axc, double ayc, double width, double height, double ang1, double ang2, boolean clockwise)
      This produces an arc by breaking it down into one or more Bezier curves.
      void clearRect​(int x, int y, int w, int h)
      This simply draws a White Rectangle to clear the area
      void clip​(java.awt.Shape s)  
      void clipPolygon​(java.awt.Polygon p)
      This extra method allows PDF users to clip to a Polygon.
      void clipRect​(int x, int y, int w, int h)
      Clips to a set of coordinates
      void copyArea​(int x, int y, int w, int h, int dx, int dy)
      This is unsupported - how do you do this with Vector graphics?
      java.awt.Graphics create()
      This returns a child instance of this Graphics object.
      protected PDFGraphics createGraphic​(PDFPage page, java.io.PrintWriter pw)
      This method creates a new instance of the class based on the page and a print writer.
      void curveto​(double x1, double y1, double x2, double y2)
      This extension appends a Bezier curve to the path.
      void curveto​(double x1, double y1, double x2, double y2, double x3, double y3)
      This extension appends a Bezier curve to the path.
      void curveto​(int x1, int y1, int x2, int y2)
      This extension appends a Bezier curve to the path.
      void curveto​(int x1, int y1, int x2, int y2, int x3, int y3)
      This extension appends a Bezier curve to the path.
      void curveto2​(double x1, double y1, double x2, double y2)
      This extension appends a Bezier curve to the path.
      void curveto2​(int x1, int y1, int x2, int y2)
      This extension appends a Bezier curve to the path.
      void dispose()
      This releases any resources used by this Graphics object.
      void draw​(java.awt.Shape s)  
      void draw3DRect​(int x, int y, int width, int height, boolean raised)
      Not implemented
      void drawArc​(int x, int y, int w, int h, int sa, int aa)
      Draws an arc
      void drawBytes​(byte[] data, int offset, int length, int x, int y)
      Not implemented
      void drawGlyphVector​(java.awt.font.GlyphVector g, float x, float y)  
      void drawImage​(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)  
      boolean drawImage​(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)
      Draw's an image onto the page, with scaling
      boolean drawImage​(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver obs)
      Draw's an image onto the page, with scaling
      boolean drawImage​(java.awt.Image img, int x, int y, int w, int h, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)
      Draw's an image onto the page, with a backing colour.
      boolean drawImage​(java.awt.Image img, int x, int y, int w, int h, java.awt.image.ImageObserver obs)
      Draws an image onto the page.
      boolean drawImage​(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)
      Draw's an image onto the page, with a backing colour.
      boolean drawImage​(java.awt.Image img, int x, int y, java.awt.image.ImageObserver obs)
      Draw's an image onto the page
      boolean drawImage​(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)  
      void drawLine​(int x1, int y1, int x2, int y2)
      Draws a line between two coordinates.
      void drawOval​(int x, int y, int w, int h)
      Draws an oval
      void drawPolygon​(int[] xp, int[] yp, int np)
      Draws a polygon, linking the first and last coordinates.
      void drawPolyline​(int[] xp, int[] yp, int np)
      Draws a polyline.
      void drawRect​(int x, int y, int w, int h)
      We override Graphics.drawRect as it doesn't join the 4 lines.
      void drawRenderableImage​(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)  
      void drawRenderedImage​(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)  
      void drawRoundRect​(int x, int y, int w, int h, int aw, int ah)
      This is not yet implemented
      void drawString​(java.lang.String s, float x, float y)  
      void drawString​(java.lang.String s, int x, int y)
      This draws a string.
      void drawString​(java.text.AttributedCharacterIterator aci, float x, float y)
      Draws a string using a AttributedCharacterIterator.
      void drawString​(java.text.AttributedCharacterIterator aci, int x, int y)
      Draws a string using a AttributedCharacterIterator.
      void fill​(java.awt.Shape s)  
      void fill3DRect​(int x, int y, int width, int height, boolean raised)
      Not implemented
      void fillArc​(int x, int y, int w, int h, int sa, int aa)
      Fills an arc, joining the start and end coordinates
      void fillOval​(int x, int y, int w, int h)
      Draws a filled oval
      void fillPolygon​(int[] xp, int[] yp, int np)
      Fills a polygon.
      void fillRect​(int x, int y, int w, int h)
      Fills a rectangle with the current colour
      void fillRoundRect​(int x, int y, int w, int h, int aw, int ah)
      This is not yet implemented
      java.awt.Color getBackground()  
      java.awt.Shape getClip()
      Returns the Shape of the clipping region As my JDK docs say, this may break with Java 2D.
      java.awt.Rectangle getClipBounds()
      Returns the Rectangle that fits the current clipping region
      java.awt.Color getColor()
      Returns the current pen Colour
      java.awt.Composite getComposite()  
      java.awt.GraphicsConfiguration getDeviceConfiguration()  
      java.awt.Font getFont()
      Return's the current font.
      java.awt.FontMetrics getFontMetrics​(java.awt.Font font)
      Returns the FontMetrics for a font.
      java.awt.font.FontRenderContext getFontRenderContext()  
      PDFPage getPage()
      Returns the associated PDFPage for this graphic
      java.awt.Paint getPaint()
      Returns the current pen Colour
      java.lang.Object getRenderingHint​(java.awt.RenderingHints.Key arg0)  
      java.awt.RenderingHints getRenderingHints()  
      java.awt.Stroke getStroke()  
      java.awt.geom.AffineTransform getTransform()  
      java.io.PrintWriter getWriter()
      Returns the PrintWriter handling the underlying stream
      boolean hit​(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)  
      protected void init​(PDFPage page)
      This is called by PDFPage when creating a Graphcis instance.
      protected void init​(PDFPage page, java.io.PrintWriter pw)
      This method is used internally by create() and by the PDFJob class
      void lineto​(double x, double y)
      This adds a line segment to the current path
      void lineto​(int x, int y)
      This adds a line segment to the current path
      void moveto​(double x, double y)
      This moves the current drawing point.
      void moveto​(int x, int y)
      This moves the current drawing point.
      void polygon​(int[] xp, int[] yp, int np)
      This is used to add a polygon to the current path.
      void rotate​(double theta)  
      void rotate​(double theta, double x, double y)  
      void scale​(double sx, double sy)  
      void setBackground​(java.awt.Color color)  
      void setClip​(int x, int y, int w, int h)
      Clips to a set of coordinates
      void setClip​(java.awt.Shape s)
      As my JDK docs say, this may break with Java 2D.
      void setColor​(java.awt.Color c)
      Sets the color for drawing
      void setComposite​(java.awt.Composite comp)  
      void setDefaultLineWidth()
      This extension sets the line width to the default of 1mm which is what Java uses when drawing to a PrintJob.
      void setFont​(java.awt.Font f)
      This sets the font.
      void setLineWidth​(float width)
      This extension allows the width of the drawn line to be set
      void setPaint​(java.awt.Paint paint)
      Sets the paint for drawing
      void setPaintMode()
      Not implemented, as this is not supported in the PDF specification.
      void setRenderingHint​(java.awt.RenderingHints.Key arg0, java.lang.Object arg1)
      Sets a rendering hint
      void setRenderingHints​(java.util.Map<?,​?> hints)  
      void setStroke​(java.awt.Stroke s)  
      void setTransform​(java.awt.geom.AffineTransform t)  
      void setXORMode​(java.awt.Color c1)
      Not implemented, as this is not supported in the PDF specification.
      void shear​(double shx, double shy)  
      void transform​(java.awt.geom.AffineTransform tx)  
      void translate​(double tx, double ty)  
      void translate​(int x, int y)  
      • Methods inherited from class java.awt.Graphics

        create, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • clipRectangle

        protected java.awt.Rectangle clipRectangle
        This holds the current clipRectangle
      • trax

        protected float trax
        This is used to translate coordinates
      • tray

        protected float tray
        This is used to translate coordinates
    • Constructor Detail

      • PDFGraphics

        public PDFGraphics()
    • Method Detail

      • addRenderingHints

        public void addRenderingHints​(java.util.Map<?,​?> hints)
        Specified by:
        addRenderingHints in class java.awt.Graphics2D
        See Also:
        Graphics2D.addRenderingHints(Map)
      • arc

        public void arc​(double axc,
                        double ayc,
                        double width,
                        double height,
                        double ang1,
                        double ang2,
                        boolean clockwise)
        This produces an arc by breaking it down into one or more Bezier curves. It is used internally to implement the drawArc and fillArc methods.
        Parameters:
        axc - X coordinate of arc centre
        ayc - Y coordinate of arc centre
        width - of bounding rectangle
        height - of bounding rectangle
        ang1 - Start angle
        ang2 - End angle
        clockwise - true to draw clockwise, false anti-clockwise
      • clearRect

        public void clearRect​(int x,
                              int y,
                              int w,
                              int h)
        This simply draws a White Rectangle to clear the area
        Specified by:
        clearRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • clip

        public void clip​(java.awt.Shape s)
        Specified by:
        clip in class java.awt.Graphics2D
        See Also:
        Graphics2D.clip(Shape)
      • clipPolygon

        public void clipPolygon​(java.awt.Polygon p)
        This extra method allows PDF users to clip to a Polygon.

        In theory you could use setClip(), except that java.awt.Graphics only supports Rectangle with that method, so we will have an extra method.

        Parameters:
        p - Polygon to clip to
      • clipRect

        public void clipRect​(int x,
                             int y,
                             int w,
                             int h)
        Clips to a set of coordinates
        Specified by:
        clipRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • copyArea

        public void copyArea​(int x,
                             int y,
                             int w,
                             int h,
                             int dx,
                             int dy)
        This is unsupported - how do you do this with Vector graphics?
        Specified by:
        copyArea in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
        dx - coordinate
        dy - coordinate
      • create

        public java.awt.Graphics create()

        This returns a child instance of this Graphics object. As with AWT, the affects of using the parent instance while the child exists, is not determined.

        Once complete, the child should be released with it's dispose() method which will restore the graphics state to it's parent.

        Specified by:
        create in class java.awt.Graphics
        Returns:
        Graphics object to render onto the page
      • createGraphic

        protected PDFGraphics createGraphic​(PDFPage page,
                                            java.io.PrintWriter pw)
        This method creates a new instance of the class based on the page and a print writer.
        Parameters:
        page - the page to attach to
        pw - the PrintWriter to attach to.
      • curveto

        public void curveto​(double x1,
                            double y1,
                            double x2,
                            double y2)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using the current point and (x1,y1) as the Bezier control points.

        The new current point is (x2,y2)

        Parameters:
        x1 - Second control point
        y1 - Second control point
        x2 - Destination point
        y2 - Destination point
      • curveto

        public void curveto​(double x1,
                            double y1,
                            double x2,
                            double y2,
                            double x3,
                            double y3)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x3,y3) using (x1,y1) and (x2,y2) as the Bezier control points.

        The new current point is (x3,y3)

        Parameters:
        x1 - First control point
        y1 - First control point
        x2 - Second control point
        y2 - Second control point
        x3 - Destination point
        y3 - Destination point
      • curveto

        public void curveto​(int x1,
                            int y1,
                            int x2,
                            int y2)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using the current point and (x1,y1) as the Bezier control points.

        The new current point is (x2,y2)

        Parameters:
        x1 - Second control point
        y1 - Second control point
        x2 - Destination point
        y2 - Destination point
      • curveto

        public void curveto​(int x1,
                            int y1,
                            int x2,
                            int y2,
                            int x3,
                            int y3)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x3,y3) using (x1,y1) and (x2,y2) as the Bezier control points.

        The new current point is (x3,y3)

        Parameters:
        x1 - First control point
        y1 - First control point
        x2 - Second control point
        y2 - Second control point
        x3 - Destination point
        y3 - Destination point
      • curveto2

        public void curveto2​(double x1,
                             double y1,
                             double x2,
                             double y2)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using (x1,y1) and the end point as the Bezier control points.

        The new current point is (x2,y2)

        Parameters:
        x1 - Second control point
        y1 - Second control point
        x2 - Destination point
        y2 - Destination point
      • curveto2

        public void curveto2​(int x1,
                             int y1,
                             int x2,
                             int y2)
        This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using (x1,y1) and the end point as the Bezier control points.

        The new current point is (x2,y2)

        Parameters:
        x1 - Second control point
        y1 - Second control point
        x2 - Destination point
        y2 - Destination point
      • dispose

        public void dispose()

        This releases any resources used by this Graphics object. You must use this method once finished with it. Leaving it open will leave the PDF stream in an inconsistent state, and will produce errors.

        If this was created with Graphics.create() then the parent instance can be used again. If not, then this closes the graphics operations for this page when used with PDFJob.

        When using PDFPage, you can create another fresh Graphics instance, which will draw over this one.

        Specified by:
        dispose in class java.awt.Graphics
      • draw

        public void draw​(java.awt.Shape s)
        Specified by:
        draw in class java.awt.Graphics2D
        See Also:
        Graphics2D.draw(Shape)
      • draw3DRect

        public void draw3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)

        Not implemented

        Draws a 3-D highlighted outline of the specified rectangle. The edges of the rectangle are highlighted so that they appear to be beveled and lit from the upper left corner. The colors used for the highlighting effect are determined based on the current color. The resulting rectangle covers an area that is width + 1 pixels wide by height + 1 pixels tall.

        Overrides:
        draw3DRect in class java.awt.Graphics2D
        Parameters:
        x - an int value
        y - an int value
        width - an int value
        height - an int value
        raised - a boolean value
      • drawArc

        public void drawArc​(int x,
                            int y,
                            int w,
                            int h,
                            int sa,
                            int aa)
        Draws an arc
        Specified by:
        drawArc in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
        sa - Start angle
        aa - End angle
      • drawBytes

        public void drawBytes​(byte[] data,
                              int offset,
                              int length,
                              int x,
                              int y)

        Not implemented

        Overrides:
        drawBytes in class java.awt.Graphics
        Parameters:
        data - a byte[] value
        offset - an int value
        length - an int value
        x - an int value
        y - an int value
      • drawGlyphVector

        public void drawGlyphVector​(java.awt.font.GlyphVector g,
                                    float x,
                                    float y)
        Specified by:
        drawGlyphVector in class java.awt.Graphics2D
        See Also:
        Graphics2D.drawGlyphVector(GlyphVector, float, float)
      • drawImage

        public void drawImage​(java.awt.image.BufferedImage img,
                              java.awt.image.BufferedImageOp op,
                              int x,
                              int y)
        Specified by:
        drawImage in class java.awt.Graphics2D
        See Also:
        Graphics2D.drawImage(BufferedImage, BufferedImageOp, int, int)
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 java.awt.geom.AffineTransform xform,
                                 java.awt.image.ImageObserver obs)
        Specified by:
        drawImage in class java.awt.Graphics2D
        See Also:
        Graphics2D.drawImage(Image, AffineTransform, ImageObserver)
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver obs)

        Draw's an image onto the page, with a backing colour.

        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        x - coordinate on page
        y - coordinate on page
        bgcolor - Background colour
        obs - ImageObserver
        Returns:
        true if drawn
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 java.awt.image.ImageObserver obs)
        Draw's an image onto the page
        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        x - coordinate on page
        y - coordinate on page
        obs - ImageObserver
        Returns:
        true if drawn
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver obs)

        Draw's an image onto the page, with a backing colour.

        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        x - coordinate on page
        y - coordinate on page
        w - Width on page
        h - height on page
        bgcolor - Background colour
        obs - ImageObserver
        Returns:
        true if drawn
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.image.ImageObserver obs)

        Draws an image onto the page.

        This method is implemented with ASCIIbase85 encoding and the zip stream deflater. It results in a stream that is anywhere from 3 to 10 times as big as the image. This obviously needs some improvement, but it works well for small images

        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        x - coordinate on page
        y - coordinate on page
        w - Width on page
        h - height on page
        obs - ImageObserver
        Returns:
        true if drawn
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver obs)
        Draw's an image onto the page, with scaling

        This is not yet supported.

        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        dx1 - coordinate on page
        dy1 - coordinate on page
        dx2 - coordinate on page
        dy2 - coordinate on page
        sx1 - coordinate on image
        sy1 - coordinate on image
        sx2 - coordinate on image
        sy2 - coordinate on image
        bgcolor - Background colour
        obs - ImageObserver
        Returns:
        true if drawn
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 java.awt.image.ImageObserver obs)
        Draw's an image onto the page, with scaling

        This is not yet supported.

        Specified by:
        drawImage in class java.awt.Graphics
        Parameters:
        img - The java.awt.Image
        dx1 - coordinate on page
        dy1 - coordinate on page
        dx2 - coordinate on page
        dy2 - coordinate on page
        sx1 - coordinate on image
        sy1 - coordinate on image
        sx2 - coordinate on image
        sy2 - coordinate on image
        obs - ImageObserver
        Returns:
        true if drawn
      • drawLine

        public void drawLine​(int x1,
                             int y1,
                             int x2,
                             int y2)
        Draws a line between two coordinates. If the first coordinate is the same as the last one drawn (i.e. a previous drawLine, moveto, etc) it is ignored.
        Specified by:
        drawLine in class java.awt.Graphics
        Parameters:
        x1 - coordinate
        y1 - coordinate
        x2 - coordinate
        y2 - coordinate
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int w,
                             int h)

        Draws an oval

        Specified by:
        drawOval in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • drawPolygon

        public void drawPolygon​(int[] xp,
                                int[] yp,
                                int np)
        Draws a polygon, linking the first and last coordinates.
        Specified by:
        drawPolygon in class java.awt.Graphics
        Parameters:
        xp - Array of x coordinates
        yp - Array of y coordinates
        np - number of points in polygon
      • drawPolyline

        public void drawPolyline​(int[] xp,
                                 int[] yp,
                                 int np)
        Draws a polyline. The first and last coordinates are not linked.
        Specified by:
        drawPolyline in class java.awt.Graphics
        Parameters:
        xp - Array of x coordinates
        yp - Array of y coordinates
        np - number of points in polyline
      • drawRect

        public void drawRect​(int x,
                             int y,
                             int w,
                             int h)
        We override Graphics.drawRect as it doesn't join the 4 lines. Also, PDF provides us with a Rectangle operator, so we will use that.
        Overrides:
        drawRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • drawRenderableImage

        public void drawRenderableImage​(java.awt.image.renderable.RenderableImage img,
                                        java.awt.geom.AffineTransform xform)
        Specified by:
        drawRenderableImage in class java.awt.Graphics2D
        See Also:
        Graphics2D.drawRenderableImage(RenderableImage, AffineTransform)
      • drawRenderedImage

        public void drawRenderedImage​(java.awt.image.RenderedImage img,
                                      java.awt.geom.AffineTransform xform)
        Specified by:
        drawRenderedImage in class java.awt.Graphics2D
        See Also:
        Graphics2D.drawRenderedImage(RenderedImage, AffineTransform)
      • drawRoundRect

        public void drawRoundRect​(int x,
                                  int y,
                                  int w,
                                  int h,
                                  int aw,
                                  int ah)
        This is not yet implemented
        Specified by:
        drawRoundRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
        aw - a-width
        ah - a-height
      • drawString

        public void drawString​(java.text.AttributedCharacterIterator aci,
                               float x,
                               float y)
        Draws a string using a AttributedCharacterIterator.

        This is not supported yet, as I have no idea what an AttributedCharacterIterator is.

        This method is new to the Java2 API.

        Specified by:
        drawString in class java.awt.Graphics2D
      • drawString

        public void drawString​(java.text.AttributedCharacterIterator aci,
                               int x,
                               int y)
        Draws a string using a AttributedCharacterIterator.

        This is not supported yet, as I have no idea what an AttributedCharacterIterator is.

        This method is new to the Java2 API.

        Specified by:
        drawString in class java.awt.Graphics2D
      • drawString

        public void drawString​(java.lang.String s,
                               float x,
                               float y)
        Specified by:
        drawString in class java.awt.Graphics2D
      • drawString

        public void drawString​(java.lang.String s,
                               int x,
                               int y)
        This draws a string.
        Specified by:
        drawString in class java.awt.Graphics2D
        Parameters:
        s - String to draw
        x - coordinate
        y - coordinate
      • fill

        public void fill​(java.awt.Shape s)
        Specified by:
        fill in class java.awt.Graphics2D
        See Also:
        Graphics2D.fill(Shape)
      • fill3DRect

        public void fill3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)

        Not implemented

        Overrides:
        fill3DRect in class java.awt.Graphics2D
        Parameters:
        x - an int value
        y - an int value
        width - an int value
        height - an int value
        raised - a boolean value
      • fillArc

        public void fillArc​(int x,
                            int y,
                            int w,
                            int h,
                            int sa,
                            int aa)
        Fills an arc, joining the start and end coordinates
        Specified by:
        fillArc in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
        sa - Start angle
        aa - End angle
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int w,
                             int h)

        Draws a filled oval

        Specified by:
        fillOval in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • fillPolygon

        public void fillPolygon​(int[] xp,
                                int[] yp,
                                int np)
        Fills a polygon.
        Specified by:
        fillPolygon in class java.awt.Graphics
        Parameters:
        xp - Array of x coordinates
        yp - Array of y coordinates
        np - number of points in polygon
      • fillRect

        public void fillRect​(int x,
                             int y,
                             int w,
                             int h)
        Fills a rectangle with the current colour
        Specified by:
        fillRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • fillRoundRect

        public void fillRoundRect​(int x,
                                  int y,
                                  int w,
                                  int h,
                                  int aw,
                                  int ah)
        This is not yet implemented
        Specified by:
        fillRoundRect in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
        aw - a-width
        ah - a-height
      • getBackground

        public java.awt.Color getBackground()
        Specified by:
        getBackground in class java.awt.Graphics2D
        See Also:
        Graphics2D.getBackground()
      • getClip

        public java.awt.Shape getClip()
        Returns the Shape of the clipping region As my JDK docs say, this may break with Java 2D.
        Specified by:
        getClip in class java.awt.Graphics
        Returns:
        Shape of the clipping region
      • getClipBounds

        public java.awt.Rectangle getClipBounds()
        Returns the Rectangle that fits the current clipping region
        Specified by:
        getClipBounds in class java.awt.Graphics
        Returns:
        the Rectangle that fits the current clipping region
      • getColor

        public java.awt.Color getColor()
        Returns the current pen Colour
        Specified by:
        getColor in class java.awt.Graphics
        Returns:
        the current pen Colour
      • getComposite

        public java.awt.Composite getComposite()
        Specified by:
        getComposite in class java.awt.Graphics2D
        See Also:
        Graphics2D.getComposite()
      • getDeviceConfiguration

        public java.awt.GraphicsConfiguration getDeviceConfiguration()
        Specified by:
        getDeviceConfiguration in class java.awt.Graphics2D
        See Also:
        Graphics2D.getDeviceConfiguration()
      • getFont

        public java.awt.Font getFont()
        Return's the current font.
        Specified by:
        getFont in class java.awt.Graphics
        Returns:
        the current font.
      • getFontMetrics

        public java.awt.FontMetrics getFontMetrics​(java.awt.Font font)
        Returns the FontMetrics for a font.

        This doesn't work correctly. Perhaps having some way of mapping the base 14 fonts to our own FontMetrics implementation?

        Specified by:
        getFontMetrics in class java.awt.Graphics
        Parameters:
        font - The java.awt.Font to return the metrics for
        Returns:
        FontMetrics for a font
      • getFontRenderContext

        public java.awt.font.FontRenderContext getFontRenderContext()
        Specified by:
        getFontRenderContext in class java.awt.Graphics2D
        See Also:
        Graphics2D.getFontRenderContext()
      • getPage

        public PDFPage getPage()
        Returns the associated PDFPage for this graphic
        Returns:
        the associated PDFPage for this graphic
      • getPaint

        public java.awt.Paint getPaint()
        Returns the current pen Colour
        Specified by:
        getPaint in class java.awt.Graphics2D
        Returns:
        the current pen Colour
      • getRenderingHint

        public java.lang.Object getRenderingHint​(java.awt.RenderingHints.Key arg0)
        Specified by:
        getRenderingHint in class java.awt.Graphics2D
        Parameters:
        arg0 - a key
        Returns:
        the rendering hint
      • getRenderingHints

        public java.awt.RenderingHints getRenderingHints()
        Specified by:
        getRenderingHints in class java.awt.Graphics2D
        See Also:
        Graphics2D.getRenderingHints()
      • getStroke

        public java.awt.Stroke getStroke()
        Specified by:
        getStroke in class java.awt.Graphics2D
        See Also:
        Graphics2D.getStroke()
      • getTransform

        public java.awt.geom.AffineTransform getTransform()
        Specified by:
        getTransform in class java.awt.Graphics2D
        See Also:
        Graphics2D.getTransform()
      • getWriter

        public java.io.PrintWriter getWriter()
        Returns the PrintWriter handling the underlying stream
        Returns:
        the PrintWriter handling the underlying stream
      • hit

        public boolean hit​(java.awt.Rectangle rect,
                           java.awt.Shape s,
                           boolean onStroke)
        Specified by:
        hit in class java.awt.Graphics2D
        See Also:
        Graphics2D.hit(Rectangle, Shape, boolean)
      • init

        protected void init​(PDFPage page)
        This is called by PDFPage when creating a Graphcis instance.
        Parameters:
        page - The PDFPage to draw onto.
      • init

        protected void init​(PDFPage page,
                            java.io.PrintWriter pw)
        This method is used internally by create() and by the PDFJob class
        Parameters:
        page - PDFPage to draw into
        pw - PrintWriter to use
      • lineto

        public void lineto​(double x,
                           double y)
        This adds a line segment to the current path
        Parameters:
        x - coordinate
        y - coordinate
      • lineto

        public void lineto​(int x,
                           int y)
        This adds a line segment to the current path
        Parameters:
        x - coordinate
        y - coordinate
      • moveto

        public void moveto​(double x,
                           double y)
        This moves the current drawing point.
        Parameters:
        x - coordinate
        y - coordinate
      • moveto

        public void moveto​(int x,
                           int y)
        This moves the current drawing point.
        Parameters:
        x - coordinate
        y - coordinate
      • rotate

        public void rotate​(double theta)
        Specified by:
        rotate in class java.awt.Graphics2D
        See Also:
        Graphics2D.rotate(double)
      • rotate

        public void rotate​(double theta,
                           double x,
                           double y)
        Specified by:
        rotate in class java.awt.Graphics2D
        See Also:
        Graphics2D.rotate(double, double, double)
      • scale

        public void scale​(double sx,
                          double sy)
        Specified by:
        scale in class java.awt.Graphics2D
        See Also:
        Graphics2D.scale(double, double)
      • setBackground

        public void setBackground​(java.awt.Color color)
        Specified by:
        setBackground in class java.awt.Graphics2D
        See Also:
        Graphics2D.setBackground(Color)
      • setClip

        public void setClip​(int x,
                            int y,
                            int w,
                            int h)
        Clips to a set of coordinates
        Specified by:
        setClip in class java.awt.Graphics
        Parameters:
        x - coordinate
        y - coordinate
        w - width
        h - height
      • setClip

        public void setClip​(java.awt.Shape s)
        As my JDK docs say, this may break with Java 2D.

        Sets the clipping region to that of a Shape.

        Specified by:
        setClip in class java.awt.Graphics
        Parameters:
        s - Shape to clip to.
      • setColor

        public void setColor​(java.awt.Color c)
        Sets the color for drawing
        Specified by:
        setColor in class java.awt.Graphics
        Parameters:
        c - Color to use
      • setComposite

        public void setComposite​(java.awt.Composite comp)
        Specified by:
        setComposite in class java.awt.Graphics2D
        See Also:
        Graphics2D.setComposite(Composite)
      • setDefaultLineWidth

        public void setDefaultLineWidth()
        This extension sets the line width to the default of 1mm which is what Java uses when drawing to a PrintJob.
      • setFont

        public void setFont​(java.awt.Font f)
        This sets the font.
        Specified by:
        setFont in class java.awt.Graphics
        Parameters:
        f - java.awt.Font to set to.
      • setLineWidth

        public void setLineWidth​(float width)
        This extension allows the width of the drawn line to be set
        Parameters:
        width - Line width in pdf graphic units (points)
      • setPaint

        public void setPaint​(java.awt.Paint paint)
        Sets the paint for drawing
        Specified by:
        setPaint in class java.awt.Graphics2D
        Parameters:
        paint - Paint to use
      • setPaintMode

        public void setPaintMode()
        Not implemented, as this is not supported in the PDF specification.
        Specified by:
        setPaintMode in class java.awt.Graphics
      • setRenderingHint

        public void setRenderingHint​(java.awt.RenderingHints.Key arg0,
                                     java.lang.Object arg1)
        Sets a rendering hint
        Specified by:
        setRenderingHint in class java.awt.Graphics2D
        Parameters:
        arg0 -
        arg1 -
      • setRenderingHints

        public void setRenderingHints​(java.util.Map<?,​?> hints)
        Specified by:
        setRenderingHints in class java.awt.Graphics2D
        See Also:
        Graphics2D.setRenderingHints(Map)
      • setStroke

        public void setStroke​(java.awt.Stroke s)
        Specified by:
        setStroke in class java.awt.Graphics2D
        See Also:
        Graphics2D.setStroke(Stroke)
      • setTransform

        public void setTransform​(java.awt.geom.AffineTransform t)
        Specified by:
        setTransform in class java.awt.Graphics2D
        See Also:
        Graphics2D.setTransform(AffineTransform)
      • setXORMode

        public void setXORMode​(java.awt.Color c1)
        Not implemented, as this is not supported in the PDF specification.
        Specified by:
        setXORMode in class java.awt.Graphics
        Parameters:
        c1 - Color to xor with
      • shear

        public void shear​(double shx,
                          double shy)
        Specified by:
        shear in class java.awt.Graphics2D
        See Also:
        Graphics2D.shear(double, double)
      • transform

        public void transform​(java.awt.geom.AffineTransform tx)
        Specified by:
        transform in class java.awt.Graphics2D
        See Also:
        Graphics2D.transform(AffineTransform)
      • translate

        public void translate​(double tx,
                              double ty)
        Specified by:
        translate in class java.awt.Graphics2D
        See Also:
        Graphics2D.translate(double, double)
      • translate

        public void translate​(int x,
                              int y)
        Specified by:
        translate in class java.awt.Graphics2D
        See Also:
        Graphics.translate(int, int)