Class PaintedShape

  • All Implemented Interfaces:
    PaintedGraphic, PaintedObject

    public class PaintedShape
    extends AbstractPaintedGraphic
    A utility class that paints a shape with an stroke and/or fill. 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 painted, such as the fill paint, stroke stroke or line width, and stroke paint.
    Version:
    $Id$
    Author:
    John Reekie, Nick Zamora
    • Constructor Summary

      Constructors 
      Constructor Description
      PaintedShape​(java.awt.Shape shape)
      Create a painted shape on the given Shape.
      PaintedShape​(java.awt.Shape shape, float lineWidth)
      Create a painted shape on the given Shape.
      PaintedShape​(java.awt.Shape shape, float lineWidth, java.awt.Paint strokePaint)
      Create a painted shape on the given Shape.
      PaintedShape​(java.awt.Shape shape, java.awt.Paint fillPaint)
      Create a painted shape on the given Shape.
      PaintedShape​(java.awt.Shape shape, java.awt.Paint fillPaint, float lineWidth)
      Create a painted shape on the given Shape.
      PaintedShape​(java.awt.Shape shape, java.awt.Paint fillPaint, float lineWidth, java.awt.Paint strokePaint)
      Create a painted shape on the given Shape.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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 setFillPaint​(java.awt.Paint fillPaint)
      Set the fill paint for this shape (its fill if it is closed).
      void setLineWidth​(float lineWidth)
      Set the line width.
      void setStrokePaint​(java.awt.Paint strokePaint)
      Set the stroke paint for this shape (its outline if it is closed).
      • Methods inherited from class java.lang.Object

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

      • fillPaint

        public java.awt.Paint fillPaint
        The paint for the fill.
    • Constructor Detail

      • PaintedShape

        public PaintedShape​(java.awt.Shape shape)
        Create a painted shape on the given Shape. The shape will be painted as a black outline only.
      • PaintedShape

        public PaintedShape​(java.awt.Shape shape,
                            java.awt.Paint fillPaint)
        Create a painted shape on the given Shape. The shape will be filled with the given paint, but not painted with an outline.
      • PaintedShape

        public PaintedShape​(java.awt.Shape shape,
                            float lineWidth)
        Create a painted shape on the given Shape. The shape will be outlined in black with the given width but not filled.
      • PaintedShape

        public PaintedShape​(java.awt.Shape shape,
                            java.awt.Paint fillPaint,
                            float lineWidth)
        Create a painted shape on the given Shape. The shape will be filled with the given paint and outlined with a black outline of the given width.
      • PaintedShape

        public PaintedShape​(java.awt.Shape shape,
                            float lineWidth,
                            java.awt.Paint strokePaint)
        Create a painted shape on the given Shape. The shape will be outlined with an outline of the given color and given width and not filled.
      • PaintedShape

        public PaintedShape​(java.awt.Shape shape,
                            java.awt.Paint fillPaint,
                            float lineWidth,
                            java.awt.Paint strokePaint)
        Create a painted shape on the given Shape. The shape will be filled with the given paint and outlined with an outline of the given color and given width.
    • Method Detail

      • 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, fill, and stroke.
      • setStrokePaint

        public void setStrokePaint​(java.awt.Paint strokePaint)
        Set the stroke paint for this shape (its outline if it is closed).
      • setFillPaint

        public void setFillPaint​(java.awt.Paint fillPaint)
        Set the fill paint for this shape (its fill if it is closed).