org.jfree.graphics2d.canvas

## Class CanvasGraphics2D

- java.lang.Object
- - java.awt.Graphics
  - - java.awt.Graphics2D
    - - org.jfree.graphics2d.canvas.CanvasGraphics2D

-     public final class CanvasGraphics2D
      extends java.awt.Graphics2D

  A `Graphics2D` implementation that writes out JavaScript code that will draw to an HTML5 Canvas.

  Implementation notes:

  - all rendering hints are ignored;
  - images are not yet supported;
  - the `drawString()` methods that work with an `AttributedCharacterIterator` currently ignore the formatting information.

  For some demos of the use of this class, please look in the `org.jfree.graphics2d.demo` package in the `src` directory.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CanvasGraphics2D(java.lang.String canvasID)` Creates a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRenderingHints(java.util.Map<?,?> hints)` Adds all the supplied rendering hints.
    `void` | `clearRect(int x, int y, int width, int height)` Clears the specified rectangle by filling it with the current background color.
    `void` | `clip(java.awt.Shape s)` Clips to the intersection of the current clipping region and the specified shape.
    `void` | `clipRect(int x, int y, int width, int height)` Clips to the intersection of the current clipping region and the specified rectangle.
    `void` | `copyArea(int x, int y, int width, int height, int dx, int dy)` Not yet implemented.
    `java.awt.Graphics` | `create()` Creates a new graphics object that is a copy of this graphics object.
    `void` | `dispose()` Does nothing.
    `void` | `draw(java.awt.Shape s)` Draws the specified shape with the current `paint` and `stroke`.
    `void` | `drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)` Draws an arc contained within the rectangle `(x, y, width, height)`, starting at `startAngle` and continuing through `arcAngle` degrees using the current `paint` and `stroke`.
    `void` | `drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)` Draws the specified glyph vector at the location (x, y).
    `void` | `drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)` Draws the image resulting from applying the `BufferedImageOp` to the specified image at the location `(x, y)`.
    `boolean` | `drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)` Draws an image with the specified transform.
    `boolean` | `drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)` Draws an image at the location `(x, y)`.
    `boolean` | `drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)` Draws an image at the location `(x, y)`.
    `boolean` | `drawImage(java.awt.Image img, int x, int y, int w, int h, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)` Draws an image to the rectangle `(x, y, w, h)` (scaling it if required), first filling the background with the specified color.
    `boolean` | `drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)` Not yet supported (but no exception is thrown).
    `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 observer)` Draws part of an image (defined by the source rectangle `(sx1, sy1, sx2, sy2)`) into the destination rectangle `(dx1, dy1, dx2, dy2)`.
    `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 observer)` Draws part of an image (defined by the source rectangle `(sx1, sy1, sx2, sy2)`) into the destination rectangle `(dx1, dy1, dx2, dy2)`.
    `void` | `drawLine(int x1, int y1, int x2, int y2)` Draws a line from `(x1, y1)` to `(x2, y2)` using the current `paint` and `stroke`.
    `void` | `drawOval(int x, int y, int width, int height)` Draws an oval framed by the rectangle `(x, y, width, height)` using the current `paint` and `stroke`.
    `void` | `drawPolygon(int[] xPoints, int[] yPoints, int nPoints)` Draws the specified polygon using the current `paint` and `stroke`.
    `void` | `drawPolyline(int[] xPoints, int[] yPoints, int nPoints)` Draws the specified multi-segment line using the current `paint` and `stroke`.
    `void` | `drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)` Draws the renderable image.
    `void` | `drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)` Draws the rendered image.
    `void` | `drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)` Draws a rectangle with rounded corners using the current `paint` and `stroke`.
    `void` | `drawString(java.text.AttributedCharacterIterator iterator, float x, float y)` Draws a string of attributed characters at `(x, y)`.
    `void` | `drawString(java.text.AttributedCharacterIterator iterator, int x, int y)` Draws a string of attributed characters at `(x, y)`.
    `void` | `drawString(java.lang.String str, float x, float y)` Draws a string at `(x, y)`.
    `void` | `drawString(java.lang.String str, int x, int y)` Draws a string at `(x, y)`.
    `void` | `fill(java.awt.Shape s)` Fills the specified shape with the current `paint`.
    `void` | `fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)` Fills an arc contained within the rectangle `(x, y, width, height)`, starting at `startAngle` and continuing through `arcAngle` degrees, using the current `paint`
    `void` | `fillOval(int x, int y, int width, int height)` Fills an oval framed by the rectangle `(x, y, width, height)`.
    `void` | `fillPolygon(int[] xPoints, int[] yPoints, int nPoints)` Fills the specified polygon using the current `paint`.
    `void` | `fillRect(int x, int y, int width, int height)` Fills the specified rectangle with the current `paint`.
    `void` | `fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)` Fills a rectangle with rounded corners using the current `paint`.
    `java.awt.Color` | `getBackground()` Returns the background color.
    `java.lang.String` | `getCanvasID()` Returns the canvas ID that was passed to the constructor.
    `java.awt.Shape` | `getClip()` Returns the user clipping region.
    `java.awt.Rectangle` | `getClipBounds()` Returns the clip bounds.
    `java.awt.Color` | `getColor()` Returns the foreground color.
    `java.awt.Composite` | `getComposite()` Returns the current composite.
    `java.awt.GraphicsConfiguration` | `getDeviceConfiguration()` Not yet implemented.
    `java.awt.Font` | `getFont()` Returns the current font used for drawing text.
    `java.awt.FontMetrics` | `getFontMetrics(java.awt.Font f)` Returns the font metrics for the specified font.
    `java.awt.font.FontRenderContext` | `getFontRenderContext()` Returns the font render context.
    `int` | `getGeometryDP()` Returns the number of decimal places used to write the coordinates of geometrical shapes.
    `java.awt.Paint` | `getPaint()` Returns the paint used to draw or fill shapes (or text).
    `java.lang.Object` | `getRenderingHint(java.awt.RenderingHints.Key hintKey)` Returns the current value for the specified hint.
    `java.awt.RenderingHints` | `getRenderingHints()` Returns a copy of the rendering hints.
    `java.lang.String` | `getScript()` Returns the script that has been generated by calls to this `Graphics2D` implementation.
    `java.awt.Stroke` | `getStroke()` Returns the current stroke (used when drawing shapes).
    `java.awt.geom.AffineTransform` | `getTransform()` Returns a copy of the current transform.
    `int` | `getTransformDP()` Returns the number of decimal places used to write the transformation matrices in the Javascript output.
    `boolean` | `hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)` Returns `true` if the rectangle (in device space) intersects with the shape (the interior, if `onStroke` is false, otherwise the stroked outline of the shape).
    `void` | `rotate(double theta)` Applies a rotation (anti-clockwise) about `(0, 0)`.
    `void` | `rotate(double theta, double x, double y)` Applies a rotation (anti-clockwise) about `(x, y)`.
    `void` | `scale(double sx, double sy)` Applies a scale transformation.
    `void` | `setBackground(java.awt.Color color)` Sets the background color.
    `void` | `setClip(int x, int y, int width, int height)` Sets the user clipping region to the specified rectangle.
    `void` | `setClip(java.awt.Shape shape)` Sets the user clipping region.
    `void` | `setColor(java.awt.Color c)` Sets the foreground color.
    `void` | `setComposite(java.awt.Composite comp)` Sets the composite (only `AlphaComposite` is handled).
    `void` | `setFont(java.awt.Font font)` Sets the font to be used for drawing text.
    `void` | `setGeometryDP(int dp)` Sets the number of decimal places used to write the coordinates of geometrical shapes in the Javascript output.
    `void` | `setPaint(java.awt.Paint paint)` Sets the paint used to draw or fill shapes (or text).
    `void` | `setPaintMode()` Not yet implemented.
    `void` | `setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)` Sets the value for a hint.
    `void` | `setRenderingHints(java.util.Map<?,?> hints)` Sets the rendering hints to the specified collection.
    `void` | `setStroke(java.awt.Stroke s)` Sets the stroke that will be used to draw shapes.
    `void` | `setTransform(java.awt.geom.AffineTransform t)` Sets the transform.
    `void` | `setTransformDP(int dp)` Sets the number of decimal places used to write the transformation matrices in the Javascript output.
    `void` | `setXORMode(java.awt.Color c1)` Not yet implemented.
    `void` | `shear(double shx, double shy)` Applies a shear transformation.
    `void` | `transform(java.awt.geom.AffineTransform t)` Applies this transform to the existing transform by concatenating it.
    `void` | `translate(double tx, double ty)` Applies the translation (tx, ty).
    `void` | `translate(int tx, int ty)` Translates the origin to `(tx, ty)`.

    - ### Methods inherited from class java.awt.Graphics2D

      `draw3DRect, fill3DRect`

    - ### Methods inherited from class java.awt.Graphics

      `create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CanvasGraphics2D

          public CanvasGraphics2D(java.lang.String canvasID)

      Creates a new instance. The canvas ID is stored but not used in the current implementation.
      Parameters:
        `canvasID` - the canvas ID.

  - ### Method Detail

    - #### getCanvasID

          public java.lang.String getCanvasID()

      Returns the canvas ID that was passed to the constructor.
      Returns:
        The canvas ID.

    - #### getTransformDP

          public int getTransformDP()

      Returns the number of decimal places used to write the transformation matrices in the Javascript output. The default value is 6.

      Note that there is a separate attribute to control the number of decimal places for geometrical elements in the output (see `getGeometryDP()`).

      Returns:
        The number of decimal places.
      See Also:
        `setTransformDP(int)`

    - #### setTransformDP

          public void setTransformDP(int dp)

      Sets the number of decimal places used to write the transformation matrices in the Javascript output. Values in the range 1 to 10 will be used to configure a formatter to that number of decimal places, for all other values we revert to the normal `String` conversion of `double` primitives (approximately 16 decimals places).

      Note that there is a separate attribute to control the number of decimal places for geometrical elements in the output (see `setGeometryDP(int)`).

      Parameters:
        `dp` - the number of decimal places (normally 1 to 10).
      See Also:
        `getTransformDP()`

    - #### getGeometryDP

          public int getGeometryDP()

      Returns the number of decimal places used to write the coordinates of geometrical shapes. The default value is 2.

      Note that there is a separate attribute to control the number of decimal places for transform matrices in the output (see `getTransformDP()`).

      Returns:
        The number of decimal places.

    - #### setGeometryDP

          public void setGeometryDP(int dp)

      Sets the number of decimal places used to write the coordinates of geometrical shapes in the Javascript output. Values in the range 1 to 10 will be used to configure a formatter to that number of decimal places, for all other values we revert to the normal String conversion of double primitives (approximately 16 decimals places).

      Note that there is a separate attribute to control the number of decimal places for transform matrices in the output (see `setTransformDP(int)`).

      Parameters:
        `dp` - the number of decimal places (normally 1 to 10).

    - #### getDeviceConfiguration

          public java.awt.GraphicsConfiguration getDeviceConfiguration()

      Not yet implemented.
      Specified by:
        `getDeviceConfiguration` in class `java.awt.Graphics2D`
      Returns:
        The graphics configuration.

    - #### create

          public java.awt.Graphics create()

      Creates a new graphics object that is a copy of this graphics object.
      Specified by:
        `create` in class `java.awt.Graphics`
      Returns:
        A new graphics object.

    - #### getPaint

          public java.awt.Paint getPaint()

      Returns the paint used to draw or fill shapes (or text). The default value is `Color.BLACK`.
      Specified by:
        `getPaint` in class `java.awt.Graphics2D`
      Returns:
        The paint (never `null`).
      See Also:
        `setPaint(java.awt.Paint)`

    - #### setPaint

          public void setPaint(java.awt.Paint paint)

      Sets the paint used to draw or fill shapes (or text). If `paint` is an instance of `Color`, this method will also update the current color attribute (see `getColor()`). If you pass `null` to this method, it does nothing (in accordance with the JDK specification).
      Specified by:
        `setPaint` in class `java.awt.Graphics2D`
      Parameters:
        `paint` - the paint (`null` is permitted but ignored).
      See Also:
        `getPaint()`

    - #### getColor

          public java.awt.Color getColor()

      Returns the foreground color. This method exists for backwards compatibility in AWT, you should use the `getPaint()` method.
      Specified by:
        `getColor` in class `java.awt.Graphics`
      Returns:
        The foreground color (never `null`).
      See Also:
        `getPaint()`

    - #### setColor

          public void setColor(java.awt.Color c)

      Sets the foreground color. This method exists for backwards compatibility in AWT, you should use the `setPaint(java.awt.Paint)` method.
      Specified by:
        `setColor` in class `java.awt.Graphics`
      Parameters:
        `c` - the color (`null` permitted but ignored).
      See Also:
        `setPaint(java.awt.Paint)`

    - #### getBackground

          public java.awt.Color getBackground()

      Returns the background color. The default value is `Color.BLACK`. This is used by the `clearRect(int, int, int, int)` method.
      Specified by:
        `getBackground` in class `java.awt.Graphics2D`
      Returns:
        The background color (possibly `null`).
      See Also:
        `setBackground(java.awt.Color)`

    - #### setBackground

          public void setBackground(java.awt.Color color)

      Sets the background color. This is used by the `clearRect(int, int, int, int)` method. The reference implementation allows `null` for the background color so we allow that too (but for that case, the clearRect method will do nothing).
      Specified by:
        `setBackground` in class `java.awt.Graphics2D`
      Parameters:
        `color` - the color (`null` permitted).
      See Also:
        `getBackground()`

    - #### getComposite

          public java.awt.Composite getComposite()

      Returns the current composite.
      Specified by:
        `getComposite` in class `java.awt.Graphics2D`
      Returns:
        The current composite (never `null`).
      See Also:
        `setComposite(java.awt.Composite)`

    - #### setComposite

          public void setComposite(java.awt.Composite comp)

      Sets the composite (only `AlphaComposite` is handled).
      Specified by:
        `setComposite` in class `java.awt.Graphics2D`
      Parameters:
        `comp` - the composite (`null` not permitted).
      See Also:
        `getComposite()`

    - #### getStroke

          public java.awt.Stroke getStroke()

      Returns the current stroke (used when drawing shapes).
      Specified by:
        `getStroke` in class `java.awt.Graphics2D`
      Returns:
        The current stroke (never `null`).
      See Also:
        `setStroke(java.awt.Stroke)`

    - #### setStroke

          public void setStroke(java.awt.Stroke s)

      Sets the stroke that will be used to draw shapes. Only `BasicStroke` is supported.
      Specified by:
        `setStroke` in class `java.awt.Graphics2D`
      Parameters:
        `s` - the stroke (`null` not permitted).
      See Also:
        `getStroke()`

    - #### getRenderingHint

          public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)

      Returns the current value for the specified hint. Note that all hints are currently ignored in this implementation.
      Specified by:
        `getRenderingHint` in class `java.awt.Graphics2D`
      Parameters:
        `hintKey` - the hint key (`null` permitted, but the result will be `null` also).
      Returns:
        The current value for the specified hint (possibly `null`).
      See Also:
        `setRenderingHint(java.awt.RenderingHints.Key, java.lang.Object)`

    - #### setRenderingHint

          public void setRenderingHint(java.awt.RenderingHints.Key hintKey,
                                       java.lang.Object hintValue)

      Sets the value for a hint. Note that all hints are currently ignored in this implementation.
      Specified by:
        `setRenderingHint` in class `java.awt.Graphics2D`
      Parameters:
        `hintKey` - the hint key (`null` not permitted).
        `hintValue` - the hint value.
      See Also:
        `getRenderingHint(java.awt.RenderingHints.Key)`

    - #### getRenderingHints

          public java.awt.RenderingHints getRenderingHints()

      Returns a copy of the rendering hints. Modifying the returned copy will have no impact on the state of this Graphics2D instance.
      Specified by:
        `getRenderingHints` in class `java.awt.Graphics2D`
      Returns:
        The rendering hints (never `null`).
      See Also:
        `setRenderingHints(java.util.Map)`

    - #### setRenderingHints

          public void setRenderingHints(java.util.Map<?,?> hints)

      Sets the rendering hints to the specified collection.
      Specified by:
        `setRenderingHints` in class `java.awt.Graphics2D`
      Parameters:
        `hints` - the new set of hints (`null` not permitted).
      See Also:
        `getRenderingHints()`

    - #### addRenderingHints

          public void addRenderingHints(java.util.Map<?,?> hints)

      Adds all the supplied rendering hints.
      Specified by:
        `addRenderingHints` in class `java.awt.Graphics2D`
      Parameters:
        `hints` - the hints (`null` not permitted).

    - #### draw

          public void draw(java.awt.Shape s)

      Draws the specified shape with the current `paint` and `stroke`. There is direct handling for `Line2D`, `Rectangle2D` and `Path2D`. All other shapes are mapped to a `GeneralPath` and then drawn (effectively as `Path2D` objects).
      Specified by:
        `draw` in class `java.awt.Graphics2D`
      Parameters:
        `s` - the shape (`null` not permitted).
      See Also:
        `fill(java.awt.Shape)`

    - #### fill

          public void fill(java.awt.Shape s)

      Fills the specified shape with the current `paint`. There is direct handling for `Rectangle2D` and `Path2D`. All other shapes are mapped to a `GeneralPath` and then filled.
      Specified by:
        `fill` in class `java.awt.Graphics2D`
      Parameters:
        `s` - the shape (`null` not permitted).
      See Also:
        `draw(java.awt.Shape)`

    - #### getFont

          public java.awt.Font getFont()

      Returns the current font used for drawing text.
      Specified by:
        `getFont` in class `java.awt.Graphics`
      Returns:
        The current font (never `null`).
      See Also:
        `setFont(java.awt.Font)`

    - #### setFont

          public void setFont(java.awt.Font font)

      Sets the font to be used for drawing text.
      Specified by:
        `setFont` in class `java.awt.Graphics`
      Parameters:
        `font` - the font (`null` is permitted but ignored).
      See Also:
        `getFont()`

    - #### getFontMetrics

          public java.awt.FontMetrics getFontMetrics(java.awt.Font f)

      Returns the font metrics for the specified font.
      Specified by:
        `getFontMetrics` in class `java.awt.Graphics`
      Parameters:
        `f` - the font.
      Returns:
        The font metrics.

    - #### getFontRenderContext

          public java.awt.font.FontRenderContext getFontRenderContext()

      Returns the font render context. The implementation here returns the `FontRenderContext` for an image that is maintained internally (as for `getFontMetrics(java.awt.Font)`).
      Specified by:
        `getFontRenderContext` in class `java.awt.Graphics2D`
      Returns:
        The font render context.

    - #### drawString

          public void drawString(java.lang.String str,
                                 int x,
                                 int y)

      Draws a string at `(x, y)`. The start of the text at the baseline level will be aligned with the `(x, y)` point.
      Specified by:
        `drawString` in class `java.awt.Graphics2D`
      Parameters:
        `str` - the string (`null` not permitted).
        `x` - the x-coordinate.
        `y` - the y-coordinate.
      See Also:
        `drawString(java.lang.String, float, float)`

    - #### drawString

          public void drawString(java.lang.String str,
                                 float x,
                                 float y)

      Draws a string at `(x, y)`. The start of the text at the baseline level will be aligned with the `(x, y)` point.
      Specified by:
        `drawString` in class `java.awt.Graphics2D`
      Parameters:
        `str` - the string (`null` not permitted).
        `x` - the x-coordinate.
        `y` - the y-coordinate.

    - #### drawString

          public void drawString(java.text.AttributedCharacterIterator iterator,
                                 int x,
                                 int y)

      Draws a string of attributed characters at `(x, y)`. The call is delegated to `drawString(java.text.AttributedCharacterIterator, float, float)`.
      Specified by:
        `drawString` in class `java.awt.Graphics2D`
      Parameters:
        `iterator` - an iterator for the characters.
        `x` - the x-coordinate.
        `y` - the x-coordinate.

    - #### drawString

          public void drawString(java.text.AttributedCharacterIterator iterator,
                                 float x,
                                 float y)

      Draws a string of attributed characters at `(x, y)`.
      Specified by:
        `drawString` in class `java.awt.Graphics2D`
      Parameters:
        `iterator` - an iterator over the characters (`null` not permitted).
        `x` - the x-coordinate.
        `y` - the y-coordinate.

    - #### drawGlyphVector

          public void drawGlyphVector(java.awt.font.GlyphVector g,
                                      float x,
                                      float y)

      Draws the specified glyph vector at the location (x, y).
      Specified by:
        `drawGlyphVector` in class `java.awt.Graphics2D`
      Parameters:
        `g` - the glyph vector.
        `x` - the x-coordinate.
        `y` - the y-coordinate.

    - #### translate

          public void translate(int tx,
                                int ty)

      Translates the origin to `(tx, ty)`. This call is delegated to `translate(double, double)`.
      Specified by:
        `translate` in class `java.awt.Graphics2D`
      Parameters:
        `tx` - the x-translation.
        `ty` - the y-translation.

    - #### translate

          public void translate(double tx,
                                double ty)

      Applies the translation (tx, ty).
      Specified by:
        `translate` in class `java.awt.Graphics2D`
      Parameters:
        `tx` - the x-translation.
        `ty` - the y-translation.

    - #### rotate

          public void rotate(double theta)

      Applies a rotation (anti-clockwise) about `(0, 0)`.
      Specified by:
        `rotate` in class `java.awt.Graphics2D`
      Parameters:
        `theta` - the rotation angle (in radians).

    - #### rotate

          public void rotate(double theta,
                             double x,
                             double y)

      Applies a rotation (anti-clockwise) about `(x, y)`.
      Specified by:
        `rotate` in class `java.awt.Graphics2D`
      Parameters:
        `theta` - the rotation angle (in radians).
        `x` - the x-coordinate.
        `y` - the y-coordinate.

    - #### scale

          public void scale(double sx,
                            double sy)

      Applies a scale transformation.
      Specified by:
        `scale` in class `java.awt.Graphics2D`
      Parameters:
        `sx` - the x-scaling factor.
        `sy` - the y-scaling factor.

    - #### shear

          public void shear(double shx,
                            double shy)

      Applies a shear transformation. This is equivalent to the following call to the `transform` method:
      - `transform(AffineTransform.getShearInstance(shx, shy));`
      Specified by:
        `shear` in class `java.awt.Graphics2D`
      Parameters:
        `shx` - the x-shear factor.
        `shy` - the y-shear factor.

    - #### transform

          public void transform(java.awt.geom.AffineTransform t)

      Applies this transform to the existing transform by concatenating it.
      Specified by:
        `transform` in class `java.awt.Graphics2D`
      Parameters:
        `t` - the transform (`null` not permitted).

    - #### getTransform

          public java.awt.geom.AffineTransform getTransform()

      Returns a copy of the current transform.
      Specified by:
        `getTransform` in class `java.awt.Graphics2D`
      Returns:
        A copy of the current transform (never `null`).
      See Also:
        `setTransform(java.awt.geom.AffineTransform)`

    - #### setTransform

          public void setTransform(java.awt.geom.AffineTransform t)

      Sets the transform.
      Specified by:
        `setTransform` in class `java.awt.Graphics2D`
      Parameters:
        `t` - the new transform (`null` permitted, resets to the identity transform).

    - #### hit

          public boolean hit(java.awt.Rectangle rect,
                             java.awt.Shape s,
                             boolean onStroke)

      Returns `true` if the rectangle (in device space) intersects with the shape (the interior, if `onStroke` is false, otherwise the stroked outline of the shape).
      Specified by:
        `hit` in class `java.awt.Graphics2D`
      Parameters:
        `rect` - a rectangle (in device space).
        `s` - the shape.
        `onStroke` - test the stroked outline only?
      Returns:
        A boolean.

    - #### setPaintMode

          public void setPaintMode()

      Not yet implemented.
      Specified by:
        `setPaintMode` in class `java.awt.Graphics`

    - #### setXORMode

          public void setXORMode(java.awt.Color c1)

      Not yet implemented.
      Specified by:
        `setXORMode` in class `java.awt.Graphics`
      Parameters:
        `c1` - the color.

    - #### getClipBounds

          public java.awt.Rectangle getClipBounds()

      Returns the clip bounds.
      Specified by:
        `getClipBounds` in class `java.awt.Graphics`
      Returns:
        The clip bounds (possibly `null`).

    - #### getClip

          public java.awt.Shape getClip()

      Returns the user clipping region. The initial default value is `null`.
      Specified by:
        `getClip` in class `java.awt.Graphics`
      Returns:
        The user clipping region (possibly `null`).
      See Also:
        `setClip(java.awt.Shape)`

    - #### setClip

          public void setClip(java.awt.Shape shape)

      Sets the user clipping region.
      Specified by:
        `setClip` in class `java.awt.Graphics`
      Parameters:
        `shape` - the new user clipping region (`null` permitted).
      See Also:
        `getClip()`

    - #### clip

          public void clip(java.awt.Shape s)

      Clips to the intersection of the current clipping region and the specified shape. According to the Oracle API specification, this method will accept a `null` argument, but there is an open bug report (since 2004) that suggests this is wrong: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206189
      Specified by:
        `clip` in class `java.awt.Graphics2D`
      Parameters:
        `s` - the clip shape (`null` not permitted).

    - #### clipRect

          public void clipRect(int x,
                               int y,
                               int width,
                               int height)

      Clips to the intersection of the current clipping region and the specified rectangle.
      Specified by:
        `clipRect` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.

    - #### setClip

          public void setClip(int x,
                              int y,
                              int width,
                              int height)

      Sets the user clipping region to the specified rectangle.
      Specified by:
        `setClip` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
      See Also:
        `getClip()`

    - #### copyArea

          public void copyArea(int x,
                               int y,
                               int width,
                               int height,
                               int dx,
                               int dy)

      Not yet implemented.
      Specified by:
        `copyArea` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `dx` - the destination x-offset.
        `dy` - the destination y-offset.

    - #### drawLine

          public void drawLine(int x1,
                               int y1,
                               int x2,
                               int y2)

      Draws a line from `(x1, y1)` to `(x2, y2)` using the current `paint` and `stroke`.
      Specified by:
        `drawLine` in class `java.awt.Graphics`
      Parameters:
        `x1` - the x-coordinate of the start point.
        `y1` - the y-coordinate of the start point.
        `x2` - the x-coordinate of the end point.
        `y2` - the x-coordinate of the end point.

    - #### fillRect

          public void fillRect(int x,
                               int y,
                               int width,
                               int height)

      Fills the specified rectangle with the current `paint`.
      Specified by:
        `fillRect` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the rectangle width.
        `height` - the rectangle height.

    - #### clearRect

          public void clearRect(int x,
                                int y,
                                int width,
                                int height)

      Clears the specified rectangle by filling it with the current background color. If the background color is `null`, this method will do nothing.
      Specified by:
        `clearRect` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
      See Also:
        `getBackground()`

    - #### drawRoundRect

          public void drawRoundRect(int x,
                                    int y,
                                    int width,
                                    int height,
                                    int arcWidth,
                                    int arcHeight)

      Draws a rectangle with rounded corners using the current `paint` and `stroke`.
      Specified by:
        `drawRoundRect` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `arcWidth` - the arc-width.
        `arcHeight` - the arc-height.
      See Also:
        `fillRoundRect(int, int, int, int, int, int)`

    - #### fillRoundRect

          public void fillRoundRect(int x,
                                    int y,
                                    int width,
                                    int height,
                                    int arcWidth,
                                    int arcHeight)

      Fills a rectangle with rounded corners using the current `paint`.
      Specified by:
        `fillRoundRect` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `arcWidth` - the arc-width.
        `arcHeight` - the arc-height.
      See Also:
        `drawRoundRect(int, int, int, int, int, int)`

    - #### drawOval

          public void drawOval(int x,
                               int y,
                               int width,
                               int height)

      Draws an oval framed by the rectangle `(x, y, width, height)` using the current `paint` and `stroke`.
      Specified by:
        `drawOval` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
      See Also:
        `fillOval(int, int, int, int)`

    - #### fillOval

          public void fillOval(int x,
                               int y,
                               int width,
                               int height)

      Fills an oval framed by the rectangle `(x, y, width, height)`.
      Specified by:
        `fillOval` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
      See Also:
        `drawOval(int, int, int, int)`

    - #### drawArc

          public void drawArc(int x,
                              int y,
                              int width,
                              int height,
                              int startAngle,
                              int arcAngle)

      Draws an arc contained within the rectangle `(x, y, width, height)`, starting at `startAngle` and continuing through `arcAngle` degrees using the current `paint` and `stroke`.
      Specified by:
        `drawArc` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `startAngle` - the start angle in degrees, 0 = 3 o'clock.
        `arcAngle` - the angle (anticlockwise) in degrees.
      See Also:
        `fillArc(int, int, int, int, int, int)`

    - #### fillArc

          public void fillArc(int x,
                              int y,
                              int width,
                              int height,
                              int startAngle,
                              int arcAngle)

      Fills an arc contained within the rectangle `(x, y, width, height)`, starting at `startAngle` and continuing through `arcAngle` degrees, using the current `paint`
      Specified by:
        `fillArc` in class `java.awt.Graphics`
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `startAngle` - the start angle in degrees, 0 = 3 o'clock.
        `arcAngle` - the angle (anticlockwise) in degrees.
      See Also:
        `drawArc(int, int, int, int, int, int)`

    - #### drawPolyline

          public void drawPolyline(int[] xPoints,
                                   int[] yPoints,
                                   int nPoints)

      Draws the specified multi-segment line using the current `paint` and `stroke`.
      Specified by:
        `drawPolyline` in class `java.awt.Graphics`
      Parameters:
        `xPoints` - the x-points.
        `yPoints` - the y-points.
        `nPoints` - the number of points to use for the polyline.

    - #### drawPolygon

          public void drawPolygon(int[] xPoints,
                                  int[] yPoints,
                                  int nPoints)

      Draws the specified polygon using the current `paint` and `stroke`.
      Specified by:
        `drawPolygon` in class `java.awt.Graphics`
      Parameters:
        `xPoints` - the x-points.
        `yPoints` - the y-points.
        `nPoints` - the number of points to use for the polygon.
      See Also:
        `fillPolygon(int[], int[], int)`

    - #### fillPolygon

          public void fillPolygon(int[] xPoints,
                                  int[] yPoints,
                                  int nPoints)

      Fills the specified polygon using the current `paint`.
      Specified by:
        `fillPolygon` in class `java.awt.Graphics`
      Parameters:
        `xPoints` - the x-points.
        `yPoints` - the y-points.
        `nPoints` - the number of points to use for the polygon.
      See Also:
        `drawPolygon(int[], int[], int)`

    - #### drawImage

          public boolean drawImage(java.awt.Image img,
                                   java.awt.geom.AffineTransform xform,
                                   java.awt.image.ImageObserver obs)

      Draws an image with the specified transform. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics2D`
      Parameters:
        `img` - the image.
        `xform` - the transform.
        `obs` - the image observer (ignored).
      Returns:
        `true` if the image is drawn.

    - #### drawImage

          public void drawImage(java.awt.image.BufferedImage img,
                                java.awt.image.BufferedImageOp op,
                                int x,
                                int y)

      Draws the image resulting from applying the `BufferedImageOp` to the specified image at the location `(x, y)`.
      Specified by:
        `drawImage` in class `java.awt.Graphics2D`
      Parameters:
        `img` - the image.
        `op` - the operation.
        `x` - the x-coordinate.
        `y` - the y-coordinate.

    - #### drawRenderedImage

          public void drawRenderedImage(java.awt.image.RenderedImage img,
                                        java.awt.geom.AffineTransform xform)

      Draws the rendered image.
      Specified by:
        `drawRenderedImage` in class `java.awt.Graphics2D`
      Parameters:
        `img` - the image.
        `xform` - the transform.

    - #### drawRenderableImage

          public void drawRenderableImage(java.awt.image.renderable.RenderableImage img,
                                          java.awt.geom.AffineTransform xform)

      Draws the renderable image.
      Specified by:
        `drawRenderableImage` in class `java.awt.Graphics2D`
      Parameters:
        `img` - the renderable image.
        `xform` - the transform.

    - #### drawImage

          public boolean drawImage(java.awt.Image img,
                                   int x,
                                   int y,
                                   java.awt.image.ImageObserver observer)

      Draws an image at the location `(x, y)`. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `observer` - ignored.
      Returns:
        `true` if the image is drawn.

    - #### drawImage

          public boolean drawImage(java.awt.Image img,
                                   int x,
                                   int y,
                                   int width,
                                   int height,
                                   java.awt.image.ImageObserver observer)

      Not yet supported (but no exception is thrown).
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `width` - the width.
        `height` - the height.
        `observer` - the observer (`null` permitted).
      Returns:
        A boolean.

    - #### drawImage

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

      Draws an image at the location `(x, y)`. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `bgcolor` - the background color (`null` permitted).
        `observer` - ignored.
      Returns:
        `true` if the image is 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 observer)

      Draws an image to the rectangle `(x, y, w, h)` (scaling it if required), first filling the background with the specified color. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `w` - the width.
        `h` - the height.
        `bgcolor` - the background color (`null` permitted).
        `observer` - ignored.
      Returns:
        `true` if the image is 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 observer)

      Draws part of an image (defined by the source rectangle `(sx1, sy1, sx2, sy2)`) into the destination rectangle `(dx1, dy1, dx2, dy2)`. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `dx1` - the x-coordinate for the top left of the destination.
        `dy1` - the y-coordinate for the top left of the destination.
        `dx2` - the x-coordinate for the bottom right of the destination.
        `dy2` - the y-coordinate for the bottom right of the destination.
        `sx1` - the x-coordinate for the top left of the source.
        `sy1` - the y-coordinate for the top left of the source.
        `sx2` - the x-coordinate for the bottom right of the source.
        `sy2` - the y-coordinate for the bottom right of the source.
      Returns:
        `true` if the image is 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 observer)

      Draws part of an image (defined by the source rectangle `(sx1, sy1, sx2, sy2)`) into the destination rectangle `(dx1, dy1, dx2, dy2)`. The destination rectangle is first cleared by filling it with the specified `bgcolor`. Note that the `observer` is ignored.
      Specified by:
        `drawImage` in class `java.awt.Graphics`
      Parameters:
        `img` - the image.
        `dx1` - the x-coordinate for the top left of the destination.
        `dy1` - the y-coordinate for the top left of the destination.
        `dx2` - the x-coordinate for the bottom right of the destination.
        `dy2` - the y-coordinate for the bottom right of the destination.
        `sx1` - the x-coordinate for the top left of the source.
        `sy1` - the y-coordinate for the top left of the source.
        `sx2` - the x-coordinate for the bottom right of the source.
        `sy2` - the y-coordinate for the bottom right of the source.
        `bgcolor` - the background color (`null` permitted).
        `observer` - ignored.
      Returns:
        `true` if the image is drawn.

    - #### dispose

          public void dispose()

      Does nothing.
      Specified by:
        `dispose` in class `java.awt.Graphics`

    - #### getScript

          public java.lang.String getScript()

      Returns the script that has been generated by calls to this `Graphics2D` implementation.
      Returns:
        The script.