|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.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.
In 2.3.5, the class was refactored to be consistent with
the new Paintable interface and
the new AbstractPaintable class.
In 2.4.0, the class was updated to be consistent with refinements to
the Paintable interface.
Also, in 2.4.0, the default paint mode was changed from FILL to DRAW and the thickness for the stroke was changed to 2. The reason for this is aesthetic: when a shape is made up of disconnected sections, doing a FILL operation can produce bizarre results; therefore it seems more natural to make DRAW the default.
Finally, in 2.4.0, constructors were added to use a PathList
to make a ShapePaintable.
| Field Summary | |
static Paint |
DEFAULT_DRAWPAINT
Default draw paint: Color.black. |
static Stroke |
DEFAULT_DRAWSTROKE
Default draw stroke: BasicStroke(2). |
static Paint |
DEFAULT_FILLPAINT
Default fill paint: Color.black. |
static PaintMode |
DEFAULT_PAINTMODE
Default paint mode: PaintMode.DRAW. |
private Paint |
drawpaint
The draw paint. |
private Stroke |
drawstroke
The draw stroke. |
private Paint |
fillpaint
The fill paint. |
private PaintMode |
paintmode
The paint mode. |
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. |
private Shape |
shape
The shape. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_BACKGROUND_PAINT, SET_BACKGROUND_TILE |
| Fields inherited from interface edu.neu.ccs.gui.Paintable |
REMOVE_PAINTABLE, SET_CLIPPING_SHAPE, SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_DEFAULT_ORIGINAL_BOUNDS2D, SET_DEFAULT_ORIGINAL_CENTER, SET_MUTATOR, SET_OPACITY, SET_PAINTABLE, SET_VISIBLE, SHIFT_PAINTABLE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Constructor Summary | |
ShapePaintable()
The default constructor. |
|
ShapePaintable(PathList pathlist)
The constructor to specify the shape via a path list. |
|
ShapePaintable(PathList pathlist,
PaintMode paintmode)
The constructor to specify the shape via a path list and the paint mode. |
|
ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint)
The constructor to specify the shape via a path list, the paint mode, and the fill paint. |
|
ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint)
The constructor to specify the shape via a path list, the paint mode, the fill paint, and the draw paint. |
|
ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint,
Stroke drawstroke)
The constructor to specify the shape via a path list, the paint mode, the fill paint, the draw paint, and the drawstroke. |
|
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 | |
XRect |
getActualBounds2D()
Returns the actual bounds of the original paintable or null if the paintable is effectively empty. |
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. |
boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation. |
void |
originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform. |
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 PaintMode DEFAULT_PAINTMODE
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
private Shape shape
private PaintMode paintmode
private Paint fillpaint
private Paint drawpaint
private Stroke drawstroke
| Constructor Detail |
public ShapePaintable()
The default constructor.
Default settings:
Shape: null
Paint Mode: DRAW
Fill Color: Color.black
Draw Color: Color.black
Draw Stroke: BasicStroke(2)
Other constructors using Shape:
ShapePaintable(Shape)ShapePaintable(Shape, PaintMode)ShapePaintable(Shape, PaintMode, Paint)ShapePaintable(Shape, PaintMode, Paint, Paint)ShapePaintable(Shape, PaintMode, Paint, Paint, Stroke)There are a similar set of constructors using PathList.
public ShapePaintable(Shape shape)
The constructor to specify the shape.
shape - the shape to paint
public ShapePaintable(Shape shape,
PaintMode paintmode)
The constructor to specify the shape and the paint mode.
Any null parameters are ignored.
shape - the shape to paintpaintmode - the paint mode
public ShapePaintable(Shape shape,
PaintMode paintmode,
Paint fillpaint)
The constructor to specify the shape, the paint mode, and the fill paint.
Any null parameters are ignored.
shape - the shape to paintpaintmode - the paint modefillpaint - the paint to use for filling
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 are ignored.
shape - the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingdrawpaint - the paint to use for drawing
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 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 drawingpublic ShapePaintable(PathList pathlist)
The constructor to specify the shape via a path list.
pathlist - the pathlist to make the shape to paint
public ShapePaintable(PathList pathlist,
PaintMode paintmode)
The constructor to specify the shape via a path list and the paint mode.
Any null parameters are ignored.
pathlist - the pathlist to make the shape to paintpaintmode - the paint mode
public ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint)
The constructor to specify the shape via a path list, the paint mode, and the fill paint.
Any null parameters are ignored.
pathlist - the pathlist to make the shape to paintpaintmode - the paint modefillpaint - the paint to use for filling
public ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint)
The constructor to specify the shape via a path list, the paint mode, the fill paint, and the draw paint.
Any null parameters are ignored.
pathlist - the pathlist to make the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingdrawpaint - the paint to use for drawing
public ShapePaintable(PathList pathlist,
PaintMode paintmode,
Paint fillpaint,
Paint drawpaint,
Stroke drawstroke)
The constructor to specify the shape via a path list, the paint mode, the fill paint, the draw paint, and the drawstroke.
Any null parameters are ignored.
pathlist - the pathlist to make the shape to paintpaintmode - the paint modefillpaint - the paint to use for fillingdrawpaint - the paint to use for drawingdrawstroke - the stroke to use for drawing| Method Detail |
public final void originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform.
If the current shape or the graphics context is null,
this method will not paint.
originalPaint in interface PaintableoriginalPaint in class AbstractPaintableg - the graphics context on which to paintpublic final XRect getActualBounds2D()
Returns the actual bounds of the original paintable or
null if the paintable is effectively empty.
getActualBounds2D in interface PaintablegetActualBounds2D in class AbstractPaintable
public final boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation.
originalContains in interface PaintableoriginalContains in class AbstractPaintablex - 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 paintpublic final Shape getShape()
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.
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.
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 fillingpublic final Paint getFillPaint()
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 drawingpublic final Paint getDrawPaint()
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 drawingpublic final Stroke getDrawStroke()
public final void setPaintMode(PaintMode paintmode)
Sets the paint mode.
A null parameter is ignored.
Fires property change: SET_PAINT_MODE.
paintmode - the paint modepublic final PaintMode getPaintMode()
public final void setFillMode()
Sets the paint mode to fill the shape.
Fires property change: SET_PAINT_MODE.
public final void setDrawMode()
Sets the paint mode to draw the shape.
Fires property change: SET_PAINT_MODE.
public final void setFillDrawMode()
Sets the paint mode to fill and draw the shape.
Fires property change: SET_PAINT_MODE.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||