|
||||||||||
| 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.PointPaintable
A PointPaintable creates a Paintable
using a point, a PlotMark, and a Paint.
Intuitively, the effect of painting the plotmark at the origin using the paint is translated from the origin to the point.
More precisely, the idea is that the point defines the mutator
for the object as a translation whose whose x,y coefficients are
those of the point. In fact, in this class, the mutator must be
a translation. When the method setPoint is called,
the mutator is set at the same time to be the corresponding
translation.
In addition, when the method setMutator is called,
the linear part of the given mutator is ignored and the object
mutator is set to be the translation portion of the given mutator.
At the same time, the point associated with this object is set.
The behaviors of the methods setPreMutation and
setPostMutation are then determined by the above rules.
setPreMutation, the translation component
of the given mutator is composed with the translation
corresponding to the current point.setPostMutation, the given mutator is
applied as an affine transform to the current point to
obtain the new point. In particular, a succession of
post mutation operations is equivalent to applying a
succession of affine transforms to the current point.
From a mathematical standpoint, this behavior is quite
natural.Note that, if the plotmark is defined by a paintable, then the property changes of the internal paintable will be sent to the forwarding listener of the point paintable.
| Field Summary | |
private static XPoint2D |
ORIGIN
The origin for use in originalPaint. |
private Paint |
paint
The internal paint for this PointPaintable. |
private PlotMark |
plotmark
The internal plotmark for this PointPaintable. |
private XPoint2D |
point
The internal point for this PointPaintable. |
static String |
SET_PAINT
Bound property name for set paint. |
static String |
SET_PLOTMARK
Bound property name for set plotmark. |
| 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 | |
PointPaintable()
The default constructor. |
|
PointPaintable(double[] data,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint. |
|
PointPaintable(double x,
double y,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint. |
|
PointPaintable(float[] data,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint. |
|
PointPaintable(Point2D p,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint. |
|
| Method Summary | |
XRect |
getActualBounds2D()
Returns the actual bounds of the original paintable or null if the paintable is effectively empty. |
XPoint2D |
getOriginalCenter()
Returns a copy of the original center of the paint region. |
Paint |
getPaint()
Returns the current paint of this object. |
PlotMark |
getPlotMark()
Returns the current plotmark of this object. |
XPoint2D |
getPoint()
Returns a copy of the current point of this object. |
static PaintableSequence |
makePaintableSequence(double[][] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint. |
static PaintableSequence |
makePaintableSequence(float[][] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint. |
static PaintableSequence |
makePaintableSequence(Point2D[] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint. |
static PointPaintable[] |
makePointPaintableArray(double[][] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint. |
static PointPaintable[] |
makePointPaintableArray(float[][] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint. |
static PointPaintable[] |
makePointPaintableArray(Point2D[] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint. |
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. |
void |
setMutator(AffineTransform M)
The linear part of the given mutator is ignored and the object mutator is set to the translation portion of the given mutator. |
void |
setMutator(Mutator.Strategy strategy)
Calls the super method. |
void |
setPaint(Paint paint)
Sets the paint to the given paint. |
void |
setPlotMark(Paintable paintable)
Sets the internal plotmark using the given data to call the corresponding PlotMark constructor. |
void |
setPlotMark(PlotMark pm)
Sets the internal plotmark using the given data. |
void |
setPlotMark(PlotMarkAlgorithm algorithm,
int size,
boolean fill)
Sets the internal plotmark using the given data to call the corresponding PlotMark constructor. |
void |
setPoint(double[] data)
Sets the internal point using the given data. |
void |
setPoint(double x,
double y)
Sets the internal point using the given data. |
void |
setPoint(float[] data)
Sets the internal point using the given data. |
void |
setPoint(Point2D p)
Sets the internal point using the given data. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final XPoint2D ORIGIN
public static final String SET_PLOTMARK
public static final String SET_PAINT
private XPoint2D point
PointPaintable.
private PlotMark plotmark
PointPaintable.
private Paint paint
PointPaintable.
| Constructor Detail |
public PointPaintable()
The default constructor.
Sets the following defaults:
Point2D The origin (0,0)
Plotmark The default plotmark
Paint Color.black
public PointPaintable(double x,
double y,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint.
Parameters that are null revert to the defaults
listed in the default constructor.
x - the x-coordinate of the pointy - the y-coordinate of the pointpm - the plotmark to setpaint - the paint to set
public PointPaintable(Point2D p,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint.
Parameters that are null revert to the defaults
listed in the default constructor.
p - the point whose data will set the internal pointpm - the plotmark to setpaint - the paint to set
public PointPaintable(double[] data,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint.
Parameters that are null revert to the defaults
listed in the default constructor.
data - the array of size 2 with the x,y datapm - the plotmark to setpaint - the paint to set
public PointPaintable(float[] data,
PlotMark pm,
Paint paint)
Constructor that sets the point from the given data and sets the plotmark and the paint.
Parameters that are null revert to the defaults
listed in the default constructor.
data - the array of size 2 with the x,y datapm - the plotmark to setpaint - the paint to set| Method Detail |
public void originalPaint(Graphics g)
Paints onto a Graphics context.
Sets the paint of the graphics context to the internal paint and then uses the plotmark to place a mark at the origin, that is, at (0,0).
When the method call is complete, the internal state of g is unchanged.
originalPaint in interface PaintableoriginalPaint in class AbstractPaintableg - the graphics context on which to paintpublic XRect getActualBounds2D()
Returns the actual bounds of the original paintable or
null if the paintable is effectively empty.
If the plotmark is defined by a paintable, then the actual bounds of that paintable is returned.
Otherwise, if the plotmark is defined by an algorithm
and a size, then the actual bounds is computed as follows.
The shape algorithm.makeShape(0, 0, size) is constructed.
If this is null then null is
returned. Otherwise, the bounds of the shape is computed.
The width and the height of this rectangle is increased
by 1 to account for the decision to always stroke the
boundary of an algorithmic plotmark with a stroke of
thickness 1.
getActualBounds2D in interface PaintablegetActualBounds2D in class AbstractPaintablepublic XPoint2D getOriginalCenter()
Returns a copy of the original center of the paint region.
The method is implemented as follows.
If the value of getDefaultOriginalCenter
is non-null, then this center is returned.
Otherwise, if the plotmark is defined by a paintable, then the original center of that paintable is returned.
Otherwise, a copy of the origin is returned, that is,
new XPoint2D().
getOriginalCenter in interface PaintablegetOriginalCenter in class AbstractPaintable
public 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 void setPoint(double x,
double y)
Sets the internal point using the given data.
Fires property change: SET_MUTATOR.
x - the x-coordinate of the pointy - the y-coordinate of the pointpublic void setPoint(Point2D p)
Sets the internal point using the given data.
Does nothing if the given point data is null.
Fires property change: SET_MUTATOR.
p - the point whose data will set the internal pointpublic void setPoint(double[] data)
Sets the internal point using the given data.
Does nothing if the given array data is null.
Fires property change: SET_MUTATOR.
data - the array of size 2 with the x,y datapublic void setPoint(float[] data)
Sets the internal point using the given data.
Does nothing if the given array data is null.
Fires property change: SET_MUTATOR.
data - the array of size 2 with the x,y datapublic void setPlotMark(PlotMark pm)
Sets the internal plotmark using the given data.
Does nothing if the given data is null.
Fires property change: SET_PLOTMARK.
For convenience, if the plotmark happens to be defined by a paintable, then property changes from that internal paintable will be sent to the forwarding listener of the point paintable.
pm - the plotmark to set
public void setPlotMark(PlotMarkAlgorithm algorithm,
int size,
boolean fill)
Sets the internal plotmark using the given data to call
the corresponding PlotMark constructor.
Does nothing if the given algorithm data is
null.
Fires property change: SET_PLOTMARK.
algorithm - the plot mark algorithmsize - the plot mark size settingfill - the plot mark fill settingpublic void setPlotMark(Paintable paintable)
Sets the internal plotmark using the given data to call
the corresponding PlotMark constructor.
Does nothing if the given paintable data is
null.
Fires property change: SET_PLOTMARK.
For convenience, if the plotmark happens to be defined by a paintable, then property changes from that internal paintable will be sent to the forwarding listener of the point paintable.
paintable - the paintable to define the internal plotmarkpublic void setPaint(Paint paint)
Sets the paint to the given paint.
Does nothing if the given paint is null.
Fires property change: SET_PAINT.
paint - the paint to setpublic XPoint2D getPoint()
public PlotMark getPlotMark()
public Paint getPaint()
public void setMutator(AffineTransform M)
The linear part of the given mutator is ignored and the object mutator is set to the translation portion of the given mutator. At the same time, the point associated with this object is set.
setMutator in interface PaintablesetMutator in class AbstractPaintableM - the transform whose translation will set the mutatorpublic void setMutator(Mutator.Strategy strategy)
setMutator in interface PaintablesetMutator in class AbstractPaintablestrategy - the mutator strategy to apply
public static PointPaintable[] makePointPaintableArray(Point2D[] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint.
Returns null
if the given array of points is null or
if any point in the array is null.
points - the point array datapm - the plotmark to setpaint - the paint to set
public static PointPaintable[] makePointPaintableArray(double[][] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint.
Precondition:
null entries.Returns null if the precondition fails.
points - the point array datapm - the plotmark to setpaint - the paint to set
public static PointPaintable[] makePointPaintableArray(float[][] points,
PlotMark pm,
Paint paint)
Factory to make an array of point paintable objects from the given point array data and from the given plotmark and paint.
Precondition:
null entries.Returns null if the precondition fails.
points - the point array datapm - the plotmark to setpaint - the paint to set
public static PaintableSequence makePaintableSequence(Point2D[] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint.
Returns null
if the given array of points is null or
if any point in the array is null.
points - the point array datapm - the plotmark to setpaint - the paint to set
public static PaintableSequence makePaintableSequence(double[][] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint.
Precondition:
null entries.Returns null if the precondition fails.
points - the point array datapm - the plotmark to setpaint - the paint to set
public static PaintableSequence makePaintableSequence(float[][] points,
PlotMark pm,
Paint paint)
Factory to make a PaintableSequence from the
given point array data and from the given plotmark and paint.
Precondition:
null entries.Returns null if the precondition fails.
points - the point array datapm - the plotmark to setpaint - the paint to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||