|
||||||||||
| 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.PaintableSequenceComposite
edu.neu.ccs.gui.PaintBar
Class PaintBar implements a Paintable
that paints a one or two dimensional array of disks.
The constructor supplies an array of Paint objects,
one for each disk. The user can choose the diameter of the disks
and the gap between the disks.
As an application, an object of this class may be embedded in
a PaintableComponent and used to implement a custom
paint selector control.
| Field Summary | |
private int |
base
The x and y coordinate of the corner of disk (0, 0). |
private Rectangle2D.Double |
bounds
The bounds of the paint bar. |
private int |
center
The x and y coordinate of the center of disk (0, 0). |
private int |
diameter
The diameter of the disks. |
private int |
gap
The gap between the disks. |
private int |
number
The number of distinct paint disks. |
private int |
skip
The skip between the disk centers. |
| Fields inherited from class edu.neu.ccs.gui.PaintableSequenceComposite |
|
| 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 | |
PaintBar(Paint[][] paints,
int diameter,
int gap)
This contructor builds a Paintable that will paint
an array of disks using the given two dimensional Paint
array, the given disk diameter, and the given gap between disks. |
|
PaintBar(Paint[] paints,
int diameter,
int gap,
int orientation)
This contructor builds a Paintable that will paint
a sequence of disks using the given one dimensional Paint
array, the given disk diameter, the given gap between disks, and the
given orientation for the bar (HORIZONTAL or VERTICAL). |
|
| Method Summary | |
int |
diameter()
Returns the diameter. |
int |
gap()
Returns the gap. |
Paint |
getPaint(int row,
int col)
Returns the paint of the disk at the given row and col. |
int |
getPaintCount()
Returns the number of paint disks. |
protected ShapePaintable |
getShapePaintable(int index)
This protected method returns the ShapePaintable
that implements the paint disk at the given index. |
Paint |
hitsPaint(double x,
double y)
If the given position is within one of the paint disks, then returns the paint of that disk, otherwise returns null. |
Paint |
hitsPaint(Point2D p)
If the given position is within one of the paint disks, then returns the paint of that disk, otherwise returns null. |
private void |
installPaint(Paint paint,
int x,
int y,
int diameter)
Installs the given paint at the given position with the given diameter. |
void |
setPaint(int row,
int col,
Paint paint)
Sets the paint of the disk at the given row and col. |
int |
xCenter(int col)
Returns the x-center of a disk in the given col. |
int |
xCorner(int col)
Returns the x-corner of a disk in the given col. |
int |
yCenter(int row)
Returns the y-center of a disk in the given row. |
int |
yCorner(int row)
Returns the y-corner of a disk in the given row. |
| Methods inherited from class edu.neu.ccs.gui.PaintableSequenceComposite |
clearBothInnerBackgrounds, clearInnerBackgroundPaint, clearInnerBackgroundTile, getActualBounds2D, getInnerBackgroundPaint, getInnerBackgroundTile, getPaintableSequence, originalContains, originalPaint, setInnerBackgroundPaint, setInnerBackgroundTile |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private int number
private int diameter
private int gap
private int base
private int center
private int skip
private Rectangle2D.Double bounds
| Constructor Detail |
public PaintBar(Paint[] paints,
int diameter,
int gap,
int orientation)
This contructor builds a Paintable that will paint
a sequence of disks using the given one dimensional Paint
array, the given disk diameter, the given gap between disks, and the
given orientation for the bar (HORIZONTAL or VERTICAL).
Throws NullPointerException if the array of paints
is null or if all entries in the array of paints are
null. On the other hand, if an individual paint item
is null, then its position is simply skipped.
If the diameter is less than 5, it is set to 5.
If the gap is less than 0, it is set to 0.
If the orientation is not equal to HORIZONAL, it is set to VERTICAL.
paints - the set of paints for the disks in the paint bardiameter - the diameter of each diskgap - the gap between disksorientation - the orientation of the paint bar
public PaintBar(Paint[][] paints,
int diameter,
int gap)
This contructor builds a Paintable that will paint
an array of disks using the given two dimensional Paint
array, the given disk diameter, and the given gap between disks.
Throws NullPointerException if the array of paints
is null or if all entries in the array of paints are
null. On the other hand, if an individual paint item
is null, then its position is simply skipped.
If the diameter is less than 5, it is set to 5.
If the gap is less than 0, it is set to 0.
paints - the set of paints for the disks in the paint bardiameter - the diameter of each diskgap - the gap between disks| Method Detail |
public int getPaintCount()
Returns the number of paint disks.
public Paint getPaint(int row,
int col)
Returns the paint of the disk at the given row and col.
If the paint bar is HORIZONTAL, row should be 0.
If the paint bar is VERTICAL, col should be 0.
Returns null if no paint disk was installed
at the given row and col.
row - the row of a paint diskcol - the col of a paint disk
public void setPaint(int row,
int col,
Paint paint)
Sets the paint of the disk at the given row and col.
Does nothing if the row and col are out of bounds or the
paint is null.
This method will install a paint disk at a valid row and col if none was installed at construction.
row - the row of a paint diskcol - the col of a paint diskpaint - the new paint for the disk at the given index
public Paint hitsPaint(double x,
double y)
If the given position is within one of the paint disks,
then returns the paint of that disk,
otherwise returns null.
This method may be used to implement a control.
x - the x-coordinate of the positiony - the y-coordinate of the position
nullpublic Paint hitsPaint(Point2D p)
If the given position is within one of the paint disks,
then returns the paint of that disk,
otherwise returns null.
This method may be used to implement a control.
p - the position
nullpublic int diameter()
public int gap()
public int xCorner(int col)
public int yCorner(int row)
public int xCenter(int col)
public int yCenter(int row)
protected ShapePaintable getShapePaintable(int index)
This protected method returns the ShapePaintable
that implements the paint disk at the given index.
If the index is out of bounds, returns null.
index - the index of a paint disk
private void installPaint(Paint paint,
int x,
int y,
int diameter)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||