|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--edu.neu.ccs.gui.AbstractPaintable
|
+--edu.neu.ccs.gui.ShapePaintable
A ShapePaintable creates an AbstractPaintable
using a Shape object and other related data.
In 2.3.2, the method getBounds2D was modified to use the
default Bounds2D rectangle if that rectangle is non-null
before making any other tests or computations.
| Field Summary | |
static Paint |
DEFAULT_DRAWPAINT
Default draw paint: Color.black. |
static Stroke |
DEFAULT_DRAWSTROKE
Default draw stroke: BasicStroke(1). |
static Paint |
DEFAULT_FILLPAINT
Default fill paint: Color.black. |
static String |
SET_DRAW_PAINT
Bound property name for set draw paint. |
static String |
SET_DRAW_STROKE
Bound property name for set draw stroke. |
static String |
SET_FILL_PAINT
Bound property name for set fill paint. |
static String |
SET_PAINT_MODE
Bound property name for set paint mode. |
static String |
SET_SHAPE
Bound property name for set shape. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_OPACITY, SET_VISIBLE |
| Constructor Summary | |
ShapePaintable()
The default constructor. |
|
ShapePaintable(Shape shape)
The constructor to specify the shape. |
|
ShapePaintable(Shape shape,
PaintMode paintmode)
The constructor to specify the shape and the paint mode. |
|
ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint)
The constructor to specify the shape, the paint mode, and the fill paint. |
|
ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint)
The constructor to specify the shape, the paint mode, the fill paint, and the draw paint. |
|
ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint,
Stroke drawstroke)
The constructor to specify the shape, the paint mode, the fill paint, the draw paint, and the drawstroke. |
|
| Method Summary | |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable. |
Rectangle2D |
getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations. |
Point2D |
getCenter()
If the current shape is null, this method returns
new Point2D.Double(). |
Paint |
getDrawPaint()
Returns the draw paint. |
Stroke |
getDrawStroke()
Return the draw stroke. |
Paint |
getFillPaint()
Returns the fill paint. |
Shape |
getOutline()
Returns the Shape that represents the outline of
the rendered paint region taking into account the
PaintMode. |
PaintMode |
getPaintMode()
Returns the paint mode. |
Shape |
getShape()
Returns the shape of the paintable. |
Shape |
getStrokedShape()
Returns the shape of the stroked boundary taking into account the shape of the paintable and the draw stroke. |
void |
paint(Graphics g)
Paints onto a Graphics context using information from
this object. |
void |
setDrawMode()
Sets the paint mode to draw the shape. |
void |
setDrawPaint(Paint drawpaint)
Sets the draw paint. |
void |
setDrawStroke(Stroke drawstroke)
Sets the draw stroke. |
void |
setFillDrawMode()
Sets the paint mode to fill and draw the shape. |
void |
setFillMode()
Sets the paint mode to fill the shape. |
void |
setFillPaint(Paint fillpaint)
Sets the fill paint. |
void |
setPaintMode(PaintMode paintmode)
Sets the paint mode. |
void |
setShape(Shape shape)
Sets the shape of the paintable. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final Paint DEFAULT_FILLPAINT
public static final Paint DEFAULT_DRAWPAINT
public static final Stroke DEFAULT_DRAWSTROKE
public static final String SET_SHAPE
public static final String SET_PAINT_MODE
public static final String SET_FILL_PAINT
public static final String SET_DRAW_PAINT
public static final String SET_DRAW_STROKE
| Constructor Detail |
public ShapePaintable()
The default constructor.
Default settings:
- Shape: null
- Paint Mode: FILL
- Fill Color: Color.black
- Draw Color: Color.black
- Draw Stroke: BasicStroke(1)
ShapePaintable(Shape),
ShapePaintable(Shape, PaintMode),
ShapePaintable(Shape, PaintMode, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)public ShapePaintable(Shape shape)
The constructor to specify the shape.
shape - the shape to paintShapePaintable(),
ShapePaintable(Shape, PaintMode),
ShapePaintable(Shape, PaintMode, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)
public ShapePaintable(Shape shape,
PaintMode paintmode)
The constructor to specify the shape and the paint mode.
Any null parameters other than shape are ignored.
shape - the shape to paintpaintmode - the paint modeShapePaintable(),
ShapePaintable(Shape),
ShapePaintable(Shape, PaintMode, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)
public ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint)
The constructor to specify the shape, the paint mode, and the fill paint.
Any null parameters other than shape are ignored.
shape - the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingShapePaintable(),
ShapePaintable(Shape),
ShapePaintable(Shape, PaintMode),
ShapePaintable(Shape, PaintMode, Paint, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)
public ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint)
The constructor to specify the shape, the paint mode, the fill paint, and the draw paint.
Any null parameters other than shape are ignored.
shape - the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingdrawpaint - the paint to use for drawingShapePaintable(),
ShapePaintable(Shape),
ShapePaintable(Shape, PaintMode),
ShapePaintable(Shape, PaintMode, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)
public ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint,
Stroke drawstroke)
The constructor to specify the shape, the paint mode, the fill paint, the draw paint, and the drawstroke.
Any null parameters other than shape are ignored.
shape - the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingdrawpaint - the paint to use for drawingdrawstroke - the stroke to use for drawingShapePaintable(),
ShapePaintable(Shape),
ShapePaintable(Shape, PaintMode),
ShapePaintable(Shape, PaintMode, Paint),
ShapePaintable(Shape, PaintMode, Paint, Paint)| Method Detail |
public final void paint(Graphics g)
Paints onto a Graphics context using information from
this object.
If the current shape or the graphics context is null,
this method will not paint.
paint in interface Paintablepaint in class AbstractPaintableg - the graphics context on which to paintAbstractPaintable.getPreparedGraphics2D(Graphics)public final Rectangle2D getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations.
If the value of getDefaultBounds2D is non-null,
then this value is returned.
Otherwise, if the current shape is null or has zero width or
height, this method returns new Rectangle2D.Double().
Otherwise, this method computes the 2-dimensional bounds of the paint
region affected by the paint method and returns this rectangle.
getBounds2D in interface PaintablegetBounds2D in class AbstractPaintableAbstractPaintable.getBounds2D(),
AbstractPaintable.setDefaultBounds2D(Rectangle2D),
AbstractPaintable.getDefaultBounds2D()public final Point2D getCenter()
If the current shape is null, this method returns
new Point2D.Double().
If the value of getDefaultCenter is non-null,
then this value is returned.
Otherwise, this method returns the value computed by the method inherited from its superclass.
getCenter in interface PaintablegetCenter in class AbstractPaintableAbstractPaintable.getCenter(),
AbstractPaintable.setDefaultCenter(Point2D),
AbstractPaintable.getDefaultCenter()
public final boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable.
This method returns false if one or more of the following
conditions occurs:
getBounds2D.isVisible returns false.
x - the x-coordinate of the pointy - the y-coordinate of the point
public final void setShape(Shape shape)
Sets the shape of the paintable.
The shape may be set to null to eliminate the shape.
The paintable will then paint nothing.
Fires property change: SET_SHAPE.
shape - the shape to paintgetShape(),
getStrokedShape(),
getOutline()public final Shape getShape()
setShape(Shape),
getStrokedShape(),
getOutline()public final Shape getStrokedShape()
Returns the shape of the stroked boundary taking into account the shape of the paintable and the draw stroke.
If getShape returns null, then this
method returns null also.
setShape(Shape),
getShape(),
getOutline()public Shape getOutline()
Returns the Shape that represents the outline of
the rendered paint region taking into account the
PaintMode.
The following notes describe the behavior of this method in the
case of the paint modes defined in class PaintMode.
If the PaintMode is FILL then returns
the same shape as getShape.
If the PaintMode is DRAW then returns
the same shape as getStrokedShape.
If the PaintMode is FILL_DRAW then
returns the union of the shapes returned by getShape
and getStrokedShape.
setShape(Shape),
getShape(),
getStrokedShape()public final void setFillPaint(Paint fillpaint)
Sets the fill paint.
A null parameter is ignored.
Fires property change: SET_FILL_PAINT.
fillpaint - the paint to use for fillinggetFillPaint()public final Paint getFillPaint()
setFillPaint(Paint)public final void setDrawPaint(Paint drawpaint)
Sets the draw paint.
A null parameter is ignored.
Fires property change: SET_DRAW_PAINT.
drawpaint - the paint to use for drawinggetDrawPaint()public final Paint getDrawPaint()
setDrawPaint(Paint)public final void setDrawStroke(Stroke drawstroke)
Sets the draw stroke.
A null parameter is ignored.
Fires property change: SET_DRAW_STROKE.
drawstroke - the stroke to use for drawinggetDrawStroke()public final Stroke getDrawStroke()
setDrawStroke(Stroke)public final void setPaintMode(PaintMode paintmode)
Sets the paint mode.
A null parameter is ignored.
Fires property change: SET_PAINT_MODE.
paintmode - the paint modegetPaintMode(),
setFillMode(),
setDrawMode(),
setFillDrawMode()public final PaintMode getPaintMode()
setPaintMode(PaintMode),
setFillMode(),
setDrawMode(),
setFillDrawMode()public final void setFillMode()
Sets the paint mode to fill the shape.
Fires property change: SET_PAINT_MODE.
setPaintMode(PaintMode),
getPaintMode(),
setDrawMode(),
setFillDrawMode()public final void setDrawMode()
Sets the paint mode to draw the shape.
Fires property change: SET_PAINT_MODE.
setPaintMode(PaintMode),
getPaintMode(),
setFillMode(),
setFillDrawMode()public final void setFillDrawMode()
Sets the paint mode to fill and draw the shape.
Fires property change: SET_PAINT_MODE.
setPaintMode(PaintMode),
getPaintMode(),
setFillMode(),
setDrawMode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||