diva.util.java2d
Class PaintedPath

java.lang.Object
  extended by diva.util.java2d.AbstractPaintedGraphic
      extended by diva.util.java2d.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: PaintedPath.java 38835 2005-07-11 17:23:39Z cxh $
Author:
John Reekie, Nick Zamora

Field Summary
 
Fields inherited from class diva.util.java2d.AbstractPaintedGraphic
shape, stroke, strokePaint
 
Constructor Summary
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
 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 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
 

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.


getLineWidth

public float getLineWidth()
Get the line width. If the stroke is not a BasicStroke then 1.0 will always be returned.

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


setLineWidth

public void setLineWidth(float lineWidth)
Set the line width. The existing stroke will be removed, but the dash array will be preserved if possible.

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

setStroke

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