diva.util.java2d
Class PaintedShape

java.lang.Object
  extended by diva.util.java2d.AbstractPaintedGraphic
      extended by diva.util.java2d.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: PaintedShape.java 44140 2006-10-26 21:45:01Z cxh $
Author:
John Reekie, Nick Zamora

Field Summary
 java.awt.Paint fillPaint
          The paint for the fill.
 
Fields inherited from class diva.util.java2d.AbstractPaintedGraphic
shape, stroke, strokePaint
 
Constructor Summary
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
 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 diva.util.java2d.AbstractPaintedGraphic
getBounds, getStroke, getStroke, getStroke
 
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

getLineWidth

public float getLineWidth()
Get the line width

Specified by:
getLineWidth in interface PaintedGraphic
Specified by:
getLineWidth in class AbstractPaintedGraphic

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.


setLineWidth

public void setLineWidth(float lineWidth)
Set the line width. If the line width is less than or equal to zero, the stroke will be removed.

Specified by:
setLineWidth in interface PaintedGraphic
Specified by:
setLineWidth in class AbstractPaintedGraphic

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).