Package diva.util.java2d
Class PaintedPath
- java.lang.Object
-
- diva.util.java2d.AbstractPaintedGraphic
-
- 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$
- Author:
- John Reekie, Nick Zamora
-
-
Field Summary
-
Fields inherited from class diva.util.java2d.AbstractPaintedGraphic
shape, stroke, strokePaint
-
-
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 diva.util.java2d.AbstractPaintedGraphic
getBounds, getStroke, getStroke, getStroke
-
-
-
-
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 interfacePaintedGraphic
- Specified by:
getLineWidth
in classAbstractPaintedGraphic
-
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 interfacePaintedGraphic
- Specified by:
hit
in classAbstractPaintedGraphic
-
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 interfacePaintedGraphic
- Specified by:
setLineWidth
in classAbstractPaintedGraphic
-
setStroke
public void setStroke(java.awt.Stroke s)
Set the stroke
-
-