Package diva.util.java2d
Class PaintedShape
- java.lang.Object
-
- diva.util.java2d.AbstractPaintedGraphic
-
- 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$
- Author:
- John Reekie, Nick Zamora
-
-
Field Summary
Fields Modifier and Type Field Description java.awt.Paint
fillPaint
The paint for the fill.-
Fields inherited from class diva.util.java2d.AbstractPaintedGraphic
shape, stroke, strokePaint
-
-
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 widthboolean
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
-
-
-
-
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 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, 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 interfacePaintedGraphic
- Specified by:
setLineWidth
in classAbstractPaintedGraphic
-
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).
-
-