Class PaintedPath

  • All Implemented Interfaces:
    PaintedGraphic, PaintedObject

    public class PaintedPath
    extends AbstractPaintedGraphic
    A utility class that strokes a shape. This class is intended for use as a low-level class to simplify construction of drawn graphics. It contains a number of fields that govern how the shape is stroked, such as the line width, dashing, and paint.
    Version:
    $Id$
    Author:
    John Reekie, Nick Zamora
    • Constructor Summary

      Constructors 
      Constructor Description
      PaintedPath​(java.awt.Shape s)
      Create a painted path on the given Shape.
      PaintedPath​(java.awt.Shape s, float lineWidth)
      Create a painted path on the given Shape with a given line width.
      PaintedPath​(java.awt.Shape s, float lineWidth, java.awt.Paint paint)
      Create a painted path on the given Shape with a given line width and stroke color.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float[] getDashArray()
      Get the dash array.
      float getLineWidth()
      Get the line width.
      boolean hit​(java.awt.geom.Rectangle2D r)
      Test if this shape is hit by the given rectangle.
      boolean intersects​(java.awt.geom.Rectangle2D r)
      Test if this shape intersects the given rectangle.
      void paint​(java.awt.Graphics2D g)
      Paint the shape.
      void setDashArray​(float[] dashArray)
      Set the dash array of the stroke.
      void setLineWidth​(float lineWidth)
      Set the line width.
      void setStroke​(java.awt.Stroke s)
      Set the stroke
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PaintedPath

        public PaintedPath​(java.awt.Shape s)
        Create a painted path on the given Shape. The stroke will be in black with a line width of one.
      • PaintedPath

        public PaintedPath​(java.awt.Shape s,
                           float lineWidth)
        Create a painted path on the given Shape with a given line width. The stroke will be painted in black.
      • PaintedPath

        public PaintedPath​(java.awt.Shape s,
                           float lineWidth,
                           java.awt.Paint paint)
        Create a painted path on the given Shape with a given line width and stroke color.
    • Method Detail

      • getDashArray

        public float[] getDashArray()
        Get the dash array. If the stroke is not a BasicStroke then null will always be returned.
      • hit

        public boolean hit​(java.awt.geom.Rectangle2D r)
        Test if this shape is hit by the given rectangle. Currently this does not take into account the width of the stroke or other things such as dashes, because of problems with geometry testing with GeneralPath in the first version of JDK1.2.
        Specified by:
        hit in interface PaintedGraphic
        Specified by:
        hit in class AbstractPaintedGraphic
      • intersects

        public boolean intersects​(java.awt.geom.Rectangle2D r)
        Test if this shape intersects the given rectangle. Currently this does not take into account the width of the stroke or other things such as dashes, because of problems with geometry testing with GeneralPath in the first version of JDK1.2.
      • paint

        public void paint​(java.awt.Graphics2D g)
        Paint the shape. The shape is redrawn with the current shape, paint, and stroke.
      • setDashArray

        public void setDashArray​(float[] dashArray)
        Set the dash array of the stroke. The existing stroke will be removed, but the line width will be preserved if possible.
      • setStroke

        public void setStroke​(java.awt.Stroke s)
        Set the stroke