|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.AbstractPaintable
The abstract class AbstractPaintable defines objects that
implement Paintable.
A derived class must implement the following three methods:
public void originalPaint(Graphics g)public XRect getActualBounds2D()public boolean originalContains(double x, double y)As of 2.4.0, the former interface MutatablePaintable has
been merged into Paintable. Furthermore, the interface
MutatablePaintable has been removed from the Java Power
Tools as has the class AbstractMutatablePaintable.
Much programming experience proved that splitting the design into two interfaces and two abstract classes was more hassle than it was worth. Although splittling the design into two classes was conceptually simple, it made programming much more difficult since the necessary facilities were not all available everywhere.
In 2.6.0, the notion of a background paint was refactored from
Tile into required “set” and “get”
methods in the Paintable interface with corresponding
implementation in this class. See the comments on the paint
method for further details on how the background paint is applied.
Also, in 2.6.0, support was added to use a paintable as a tile for a rectangle. Once this facility was in place, we added the option for one paintable to use another paintable as a background tile that will paint the bounding box of the primary paintable before that paintable itself paints.
The order of painting is now:
Of course, no painting takes place if the paintable is set to be invisible.
In 2.6.0c, added the method makeSnapshot. This method
is implemented via:
PaintableTools.makeBufferedImage(this)
In 2.7.0, fixed a few tiny matters.
| Field Summary | |
private Paint |
background
The background paint if any. |
private Paintable |
backgroundTile
The background tile if any. |
private PropertyChangeSupport |
changeAdapter
The main listener for this AbstractPaintable object to implement the interface SupportsPropertyChange. |
private XRect |
defaultBounds2D
The default Bounds2D rectangle. |
private XPoint2D |
defaultCenter
The default center. |
private XRect |
defaultOriginalBounds2D
The default original Bounds2D rectangle. |
private XPoint2D |
defaultOriginalCenter
The default original center. |
private PropertyChangeForwardingListener |
forwardingListener
The forwarding listener for this AbstractPaintable object to implement the interface SupportsPropertyChange. |
private AffineTransform |
inverse
The mutator inverse transform. |
private AffineTransform |
mutator
The mutator transform. |
private float |
opacity
The opacity for paintables that are partially transparent. |
static String |
SET_BACKGROUND_PAINT
Bound property name for set background paint. |
static String |
SET_BACKGROUND_TILE
Bound property name for set background tile. |
private boolean |
visible
The visibility property of the paintable. |
| 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 | |
AbstractPaintable()
|
|
| Method Summary | |
void |
addForwardingListener(Object object)
Add the forwarding listener as a property change listener for the given object if the object supports property change. |
void |
addPostMutation(AffineTransform M)
Composes the current mutator on the left with the given transform provided that the given transform is invertible. |
void |
addPostMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the mutated center
of the paintable
and then calling addPostMutation with this transform as the
argument. |
void |
addPreMutation(AffineTransform M)
Composes the current mutator on the right with the given transform provided that the given transform is invertible and the paintable object supports this operation. |
void |
addPreMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling addPreMutation with this transform as the
argument. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list for a
specific property. |
void |
addPropertyChangeListeners(PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list. |
void |
addPropertyChangeListeners(String propertyName,
PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list for a specific property. |
void |
affinetransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Apply the affine transform given by the matrix coefficients m00, m10, m01, m11, m02, m12 as if the transform were centered at the center of the paintable. |
void |
applyOpacity(Graphics2D h)
Applies the current opacity to calculate and set a net opacity. |
void |
clearBackgroundPaint()
Clear the background paint. |
void |
clearBackgroundTile()
Clear the background tile. |
void |
clearBothBackgrounds()
Clear the both the background paint and the background tile. |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable. |
boolean |
contains(Point2D p)
Tests if a specified point is inside the paintable. |
void |
firePropertyChange(PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered
listeners. |
void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
byte oldValue,
byte newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
char oldValue,
char newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
double oldValue,
double newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
float oldValue,
float newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
int oldValue,
int newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
long oldValue,
long newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
short oldValue,
short newValue)
Report a bound property update to any registered listeners. |
abstract XRect |
getActualBounds2D()
Returns the actual bounds of the original paintable or null if the paintable is effectively empty. |
Paint |
getBackgroundPaint()
Returns the background paint. |
Paintable |
getBackgroundTile()
Returns the background tile. |
XRect |
getBounds2D()
Returns a copy of the 2-dimensional bounds of the paintable. |
XPoint2D |
getCenter()
Returns a copy the center of the paintable. |
XPoint2D |
getCorner()
Returns a copy the corner of the paintable. |
XRect |
getDefaultBounds2D()
Returns a copy of the default Bounds2D rectangle, that is, the default for computation of getBounds2D. |
XPoint2D |
getDefaultCenter()
Returns a copy of the default center, that is, the default for computation of getCenter. |
XRect |
getDefaultOriginalBounds2D()
Returns a copy of the default original Bounds2D rectangle, that is, the default for computation of getOriginalBounds2D. |
XPoint2D |
getDefaultOriginalCenter()
Returns a copy of the default original center, that is, the default for computation of getOriginalCenter. |
PropertyChangeForwardingListener |
getForwardingListener()
Returns the PropertyChangeForwardingListener that
will forward the property change events it receives to this object. |
AffineTransform |
getMutator()
Returns a copy of the existing mutator transform. |
AffineTransform |
getMutatorInverse()
Returns a copy of the existing mutator inverse transform. |
float |
getOpacity()
Returns the opacity value of this paintable between 0 and 1. |
XRect |
getOriginalBounds2D()
Returns a copy of the 2-dimensional bounds of the original paintable prior to any mutation. |
XPoint2D |
getOriginalCenter()
Returns a copy of the original center of the paint region. |
Graphics2D |
getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to clip to within the bounds region, to set anti-aliasing on, and to apply the opacity of this paintable if needed. |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all listeners that were added to this object. |
PropertyChangeListener[] |
getPropertyChangeListeners(String propertyName)
Returns an array of all listeners that were added to this object and associated with the named property. |
void |
glide(double degrees,
double distance)
Glides (translates) the paintable along a glide line at the given angle in degrees and the given glide distance. |
void |
glidereflect(double degrees,
double distance)
Glide reflects the paintable along the line through its center at the given angle in degrees and the given glide distance. |
boolean |
hasListeners(String propertyName)
Check if there are any listeners for a specific property. |
void |
hreflect()
Reflects the paintable along a horizontal axis through its center. |
boolean |
isVisible()
Returns the current visibility property of this paintable. |
void |
lineartransform(double m00,
double m10,
double m01,
double m11)
Apply the linear transform given by the matrix coefficients m00, m10, m01, m11 as if the transform were centered at the center of the paintable. |
BufferedImage |
makeSnapshot()
Constructs a BufferedImage object that is
the same size as the bounding box of this paintable and
then paints this paintable onto the buffered image with a
suitable translation back to the origin. |
void |
move(double dx,
double dy)
Moves the paintable by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the paintable by a translation using the data in the point. |
void |
moveCenterTo(double x,
double y)
Moves the paintable by a translation in such a way that the paintable center specified by getCenter
will move to the given point specified in coordinates. |
void |
moveCenterTo(Point2D p)
Moves the paintable by a translation in such a way that the paintable center specified by getCenter
will move to the given point. |
void |
moveCornerTo(double x,
double y)
Moves the paintable by a translation in such a way that the paintable corner specified by getCorner
will move to the given point specified in coordinates. |
void |
moveCornerTo(Point2D p)
Moves the paintable by a translation in such a way that the paintable corner specified by getCorner
will move to the given point. |
void |
mutate(AffineTransform M)
This method is implemented to do exactly the same operation as the corresponding method addPostMutation. |
void |
mutate(Mutator.Strategy strategy)
This method is implemented to do exactly the same operation as the corresponding method addPostMutation. |
abstract boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation. |
boolean |
originalContains(Point2D p)
Tests if a specified point is inside the original paintable without mutation. |
abstract void |
originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform. |
void |
paint(Graphics g)
Paints onto a graphics context g using information
from this object. |
void |
paintAsTiles(Graphics g,
double w,
double h)
Repeatedly paints this object as a tile that covers the rectangle (0,0,w,h) in the graphics context
g. |
void |
paintAsTiles(Graphics g,
double x,
double y,
double w,
double h)
Repeatedly paints this object as a tile that covers the rectangle (x,y,w,h) in the graphics context
g. |
void |
paintAsTiles(Graphics g,
Rectangle2D rect)
Repeatedly paints this object as a tile that covers the given rectangle in the graphics context g. |
void |
paintAt(Graphics g,
AffineTransform T,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point. |
void |
paintAt(Graphics g,
AffineTransform T,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point. |
void |
paintAt(Graphics g,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates. |
void |
paintAt(Graphics g,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point. |
protected boolean |
possiblyContains(double x,
double y)
Tests if a point specified by coordinates is possibly inside the original paintable. |
void |
reflect(double degrees)
Reflects the paintable along the line through its center at the given angle in degrees. |
void |
removeAndAddForwardingListener(Object oldobject,
Object newobject)
Remove the forwarding listener as a property change listener for the old object if the old object supports property change and add the forwarding listener as a property change listener for the new object if the new object supports property change. |
void |
removeForwardingListener(Object object)
Remove the forwarding listener as a property change listener for the given object if the object supports property change. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. |
void |
rotate(double degrees)
Rotates the paintable about its center by the given angle in degrees. |
void |
scale(double s)
Scales the paintable about its center by the given factor s uniformly in all directions. |
void |
scale(double degrees,
double s,
double t)
Scales the paintable about its center by the given factor s along the main axis at the given angle in degrees and the given factor t along the perpendicular axis. |
void |
setBackgroundPaint(Paint background)
Sets the background paint. |
void |
setBackgroundTile(Object object)
Sets the background tile paintable. |
void |
setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle, that is, the default for computation of getBounds2D. |
void |
setDefaultCenter(Point2D center)
Sets the default center, that is, the default for computation of getCenter. |
void |
setDefaultOriginalBounds2D(Rectangle2D rectangle)
Sets the default original Bounds2D rectangle, that is, the default for computation of getOriginalBounds2D. |
void |
setDefaultOriginalCenter(Point2D center)
Sets the default original center, that is, the default for computation of getOriginalCenter. |
void |
setMutator(AffineTransform M)
Sets the mutator transform to the given transform provided that the given transform is invertible and the paintable object supports this operation. |
void |
setMutator(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling setMutator with this transform as the
argument. |
void |
setOpacity(float opacity)
Sets the opacity of this paintable to a value between 0 and 1. |
void |
setVisible(boolean visible)
Sets the visibility property of this paintable. |
void |
shear(double degrees,
double s)
Shears the paintable about its center and with shear factor s along the line at the given angle in degrees. |
void |
vreflect()
Reflects the paintable along a vertical axis through its center. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String SET_BACKGROUND_PAINT
public static final String SET_BACKGROUND_TILE
private XRect defaultBounds2D
private XPoint2D defaultCenter
private XRect defaultOriginalBounds2D
private XPoint2D defaultOriginalCenter
private boolean visible
private float opacity
private Paint background
private Paintable backgroundTile
private AffineTransform mutator
private AffineTransform inverse
private final PropertyChangeSupport changeAdapter
The main listener for this AbstractPaintable object to implement
the interface SupportsPropertyChange.
Note: In this implementation, PropertyChangeSupport
is used rather than SwingPropertyChangeSupport to
ensure thread safety.
private final PropertyChangeForwardingListener forwardingListener
The forwarding listener for this AbstractPaintable object to implement
the interface SupportsPropertyChange.
| Constructor Detail |
public AbstractPaintable()
| Method Detail |
public void paint(Graphics g)
Paints onto a graphics context g using information
from this object.
In this default implementation, the following policies apply.
Note the that bounds region refers to the rectangle returned by
getBounds2D.
g is
null or this paintable is set to be invisible.getPreparedGraphics2D to obtain
a copy h of the graphics context g
that will be used for all painting. h has the
following settings:null, then the
bounds region is painted with this background paint.
null, then the
bounds region is tiled with this background tile.
h.originalPaint is called on the now
transformed graphics context h.When this method call is complete, the internal state of
g should be unchanged. This is the case in this
implementation. Any method that overrides this method must
ensure the same invariant regarding g.
paint in interface Paintableg - the graphics context on which to paint
public final void paintAt(Graphics g,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates.
In particular, paintAt(g,0,0) is equivalent to
paint(g).
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
paintAt in interface Paintableg - the graphics context on which to paintx - the x-translationy - the y-translation
public final void paintAt(Graphics g,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
paintAt in interface Paintableg - the graphics context on which to paintp - the translation vector
public final void paintAt(Graphics g,
AffineTransform T,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point.
The application of this facility is to apply a transform to the position of painting that should be applied to the position alone and NOT to the paintable or to the graphics context.
For example, if T is a reflection through a horizontal axis that places the origin (0,0) at the lower left of a panel, then it would probably be a very bad idea to apply the reflection to the graphics context (which turns every object upside down) or to the paintable (which turns the paintable upside down). The transform should be applied to the position alone.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
paintAt in interface Paintableg - the graphics context on which to paintT - the affine transform to apply to the translation pointx - the original x-translation before transformationy - the original y-translation before transformation
public final void paintAt(Graphics g,
AffineTransform T,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point.
The application of this facility is to apply a transform to the position of painting that should be applied to the position alone and NOT to the paintable or to the graphics context.
For example, if T is a reflection through a horizontal axis that places the origin (0,0) at the lower left of a panel, then it would probably be a very bad idea to apply the reflection to the graphics context (which turns every object upside down) or to the paintable (which turns the paintable upside down). The transform should be applied to the position alone.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
paintAt in interface Paintableg - the graphics context on which to paintT - the affine transform to apply to the translation pointp - the original translation point before transformation
public final void paintAsTiles(Graphics g,
double x,
double y,
double w,
double h)
Repeatedly paints this object as a tile that covers the
rectangle (x,y,w,h) in the graphics context
g. The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
This method works appropriately if the width or height is negative.
However, the method does nothing if:
null.
paintAsTiles in interface Paintableg - the graphics contextx - the x-corner of the rectangle to tiley - the y-corner of the rectangle to tilew - the width of the rectangle to tileh - the height of the rectangle to tile
public final void paintAsTiles(Graphics g,
double w,
double h)
Repeatedly paints this object as a tile that covers the
rectangle (0,0,w,h) in the graphics context
g. The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
This method works appropriately if the width or height is negative.
However, the method does nothing if:
null.
paintAsTiles in interface Paintableg - the graphics contextw - the width of the rectangle to tileh - the height of the rectangle to tile
public final void paintAsTiles(Graphics g,
Rectangle2D rect)
Repeatedly paints this object as a tile that covers the
given rectangle in the graphics context g.
The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
The method does nothing if:
null.null.
paintAsTiles in interface Paintableg - the graphics contextrect - the rectangle to tilepublic final Graphics2D getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to clip to within the bounds region, to set anti-aliasing on, and to apply the opacity of this paintable if needed.
For convenience, the graphics context is returned as a
Graphics2D object.
getPreparedGraphics2D in interface Paintableg - the given graphics context to copy
public final BufferedImage makeSnapshot()
Constructs a BufferedImage object that is
the same size as the bounding box of this paintable and
then paints this paintable onto the buffered image with a
suitable translation back to the origin.
This method creates a snapshot of the current visual state of the paintable.
The BufferedImage returned will have size at
least 1-by-1 even if this paintable has 0 width or height.
Implemented via:
PaintableTools.makeBufferedImage(this)
makeSnapshot in interface Paintablepublic XRect getBounds2D()
Returns a copy of the 2-dimensional bounds of the paintable.
If the value of getDefaultBounds2D is
non-null, then returns this value.
Otherwise, returns the the bounds rectangle of the image under
the mutator transform of the original bounds rectangle as computed
by getOriginalBounds2D. In particular, if the current
mutator is the identity transform, then returns
getOriginalBounds2D.
This method may be overridden in a derived class if a more exact bounds rectangle may be calculated.
This method must not return null.
getBounds2D in interface Paintablepublic XPoint2D getCenter()
Returns a copy the center of the paintable.
If the value of getDefaultCenter is
non-null, then return this value.
Otherwise, returns the image under the mutator transform of
getOriginalCenter. In particular, if the current mutator
is the identity transform, then returns getOriginalCenter.
This method may be overridden in a derived class if a more exact center may be calculated.
This method must not return null.
getCenter in interface Paintablepublic final XPoint2D getCorner()
Returns a copy the corner of the paintable.
The corner is the top-left corner of the bounds
rectangle returned by getBounds2D.
getCorner in interface Paintable
public boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable.
contains in interface Paintablex - the x-coordinate of the pointy - the y-coordinate of the point
public final boolean contains(Point2D p)
Tests if a specified point is inside the paintable.
contains in interface Paintablep - a specified point
public final void setVisible(boolean visible)
Sets the visibility property of this paintable.
The default for the visibility property should be true
Fires property change: SET_VISIBLE.
setVisible in interface Paintablevisible - the visibility settingpublic final boolean isVisible()
isVisible in interface Paintablepublic final void setOpacity(float opacity)
Sets the opacity of this paintable to a value between 0 and 1.
Note that an opacity of 0 will make the paintable invisible. This
is not recommended. Instead use setVisible(false).
Fires property change: SET_OPACITY.
setOpacity in interface Paintableopacity - the opacity of this paintablepublic final float getOpacity()
getOpacity in interface Paintablepublic final void setBackgroundPaint(Paint background)
Sets the background paint.
The paint may be set to null to
eliminate background painting.
Fires property change: SET_BACKGROUND_PAINT.
setBackgroundPaint in interface Paintablebackground - the background paintpublic final Paint getBackgroundPaint()
getBackgroundPaint in interface Paintablepublic final void clearBackgroundPaint()
Clear the background paint.
Equivalent to:
setBackgroundPaint(null);
Fires property change: SET_BACKGROUND_PAINT.
clearBackgroundPaint in interface Paintablepublic final void setBackgroundTile(Object object)
Sets the background tile paintable. The object passed
should be a paintable or be convertible to a paintable
via the method ComponentFactory.makePaintable.
The object may be set to null to
eliminate background tiling.
Fires property change: SET_BACKGROUND_TILE.
setBackgroundTile in interface Paintableobject - the background tile objectpublic final Paintable getBackgroundTile()
getBackgroundTile in interface Paintablepublic final void clearBackgroundTile()
Clear the background tile.
Equivalent to:
setBackgroundTile(null);
Fires property change: SET_BACKGROUND_TILE.
clearBackgroundTile in interface Paintablepublic final void clearBothBackgrounds()
Clear the both the background paint and the background tile.
Equivalent to:
setBackgroundPaint(null);
setBackgroundTile(null);
Fires property change: SET_BACKGROUND_PAINT.
Fires property change: SET_BACKGROUND_TILE.
clearBothBackgrounds in interface Paintablepublic void setMutator(AffineTransform M)
Sets the mutator transform to the given transform provided that the given transform is invertible and the paintable object supports this operation.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
If the paintable object maintains a mutator object that transforms
the paintable, then this method should set that mutator. Moreover,
in this case, the method getMutator should return a copy
of that mutator.
If the paintable object distributes mutation to internal data then
this method may or may not make sense. The documentation of the
implementation should state what, if anything, is done by this method.
In particular, it is valid for the method getMutator to
return an identity transform if no mutator is maintained explicitly.
setMutator in interface PaintableM - the invertible affine transform to set as the mutatorpublic void addPreMutation(AffineTransform M)
Composes the current mutator on the right with the given transform provided that the given transform is invertible and the paintable object supports this operation.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
Normally, the action of the new mutator will be to apply the given transform and then to apply the old mutator.
If the paintable object distributes mutation to internal data then this method may or may not make sense. The documentation of the implementation should state what, if anything, is done by this method.
addPreMutation in interface PaintableM - the invertible affine transform to composepublic void addPostMutation(AffineTransform M)
Composes the current mutator on the left with the given transform provided that the given transform is invertible.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
Normally, the action of the new mutator will be to apply the old mutator and then to apply the given transform.
This method should always have a meaningful interpretation for a paintable, that is, it should always be possible to apply a mutation that follows earlier mutations. If this method is implemented in a non-standard fashion, the documentation should state what is done.
addPostMutation in interface PaintableM - the invertible affine transform to composepublic void setMutator(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling setMutator with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
setMutator in interface Paintablestrategy - the mutator strategy to applypublic void addPreMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling addPreMutation with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
addPreMutation in interface Paintablestrategy - the mutator strategy to applypublic void addPostMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the mutated center
of the paintable
and then calling addPostMutation with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
addPostMutation in interface Paintablestrategy - the mutator strategy to applypublic final AffineTransform getMutator()
Returns a copy of the existing mutator transform.
If the implementation other methods are overridden to distribute transforms to sub-objects, then this method may validly always return the identity transform. This method is final.
getMutator in interface Paintablepublic final AffineTransform getMutatorInverse()
Returns a copy of the existing mutator inverse transform.
If the implementation other methods are overridden to distribute transforms to sub-objects, then this method may validly always return the identity transform. This method is final.
getMutatorInverse in interface Paintablepublic final void mutate(AffineTransform M)
This method is implemented to do exactly the same
operation as the corresponding method addPostMutation.
In other words, this is simply a convenience method with a
short name. This method is final.
mutate in interface PaintableM - the invertible affine transform to composeaddPostMutation(AffineTransform)public final void mutate(Mutator.Strategy strategy)
This method is implemented to do exactly the same
operation as the corresponding method addPostMutation.
In other words, this is simply a convenience method with a
short name. This method is final.
mutate in interface Paintablestrategy - the mutator strategy to applyaddPostMutation(Mutator.Strategy)
public final void move(double dx,
double dy)
Moves the paintable by a translation using the data in the point specified by coordinates.
move in interface Paintabledx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic final void move(Point2D p)
Moves the paintable by a translation using the data in the point.
move in interface Paintablep - the translation vector
public final void moveCenterTo(double x,
double y)
Moves the paintable by a translation in such a way that the
paintable center specified by getCenter
will move to the given point specified in coordinates.
moveCenterTo in interface Paintablex - the x-coordinate of the desired centery - the y-coordinate of the desired centerpublic final void moveCenterTo(Point2D p)
Moves the paintable by a translation in such a way that the
paintable center specified by getCenter
will move to the given point.
moveCenterTo in interface Paintablep - the desired center
public final void moveCornerTo(double x,
double y)
Moves the paintable by a translation in such a way that the
paintable corner specified by getCorner
will move to the given point specified in coordinates.
moveCornerTo in interface Paintablex - the x-coordinate of the desired cornery - the y-coordinate of the desired cornerpublic final void moveCornerTo(Point2D p)
Moves the paintable by a translation in such a way that the
paintable corner specified by getCorner
will move to the given point.
moveCornerTo in interface Paintablep - the desired cornerpublic final void rotate(double degrees)
Rotates the paintable about its center by the given angle in degrees.
rotate in interface Paintabledegrees - the rotation angle in degreespublic final void reflect(double degrees)
reflect in interface Paintabledegrees - the angle in degrees of the line of reflectionpublic final void hreflect()
hreflect in interface Paintablepublic final void vreflect()
vreflect in interface Paintablepublic final void scale(double s)
Scales the paintable about its center by the given factor s uniformly in all directions.
scale in interface Paintables - the scale in all directions
public final void scale(double degrees,
double s,
double t)
Scales the paintable about its center by the given factor s along the main axis at the given angle in degrees and the given factor t along the perpendicular axis.
scale in interface Paintabledegrees - the angle in degrees of the main scaling axiss - the scale factor along the axis at angle degreest - the scale factor along the axis at angle degrees+90
public final void shear(double degrees,
double s)
Shears the paintable about its center and with shear factor s along the line at the given angle in degrees.
In the special case when the center is at (0,0) and the angle in degrees is 0, this corresponds to the transform: (u,v) maps to (u+s*v,v), which fixes the x-axis and shears parallel to that axis.
In the general case, the fixed axis for the shear is the line at the given angle degrees through the center.
shear in interface Paintabledegrees - the angle in degrees of the fixed axis for shears - determines the amount of shear along lines parallel to
the fixed axis for shear
public final void glide(double degrees,
double distance)
Glides (translates) the paintable along a glide line at the given angle in degrees and the given glide distance.
Equivalent to specifing a translation via polar coordinates with the angle in degrees specified first and the distance specified second. The reason for specifying degrees first here is to be consistent with the usage of all other methods that have degrees as a parameter.
glide in interface Paintabledegrees - the angle in degrees of the line of glidedistance - the translation distance along the line of glide
public final void glidereflect(double degrees,
double distance)
glidereflect in interface Paintabledegrees - the angle in degrees of the line of glide reflectiondistance - the translation distance along the line of glide reflection
public final void lineartransform(double m00,
double m10,
double m01,
double m11)
Apply the linear transform given by the matrix coefficients m00, m10, m01, m11 as if the transform were centered at the center of the paintable. In other words, before applying the given transform, adjust it so that the center of the paintable remains fixed.
Note that the two coefficients of column 0 are given first and the two coefficients of column 1 are given next.
lineartransform in interface Paintablem00 - the matrix coefficient in row 0 column 0m10 - the matrix coefficient in row 1 column 0m01 - the matrix coefficient in row 0 column 1m11 - the matrix coefficient in row 1 column 1
public final void affinetransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Apply the affine transform given by the matrix coefficients m00, m10, m01, m11, m02, m12 as if the transform were centered at the center of the paintable.
Note that the two coefficients of column 0 are given first, the two coefficients of column 1 are given next, and the two coefficients of column 2 are given last.
affinetransform in interface Paintablem00 - the matrix coefficient in row 0 column 0m10 - the matrix coefficient in row 1 column 0m01 - the matrix coefficient in row 0 column 1m11 - the matrix coefficient in row 1 column 1m02 - the matrix coefficient in row 0 column 2m12 - the matrix coefficient in row 1 column 2public abstract void originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform.
A derived class must supply this method which is the foundation
for the paint methods that use the mutator.
Normally this method will be called by the paint
methods. Hence the designer of this method may assume that issues
such as visibility, opacity, clipping, antialiasing, and mutation
will be taken care of by the paint methods. Therefore,
this method need only paint what must be painted with no adjustments.
When this method call is complete, the internal state of g should be unchanged. The override method must ensure this invariant.
originalPaint in interface Paintableg - the graphics context on which to paintpublic final XRect getOriginalBounds2D()
Returns a copy of the 2-dimensional bounds of the original paintable prior to any mutation.
If the value of getDefaultOriginalBounds2D
is non-null, then returns this value.
If the value of getActualBounds2D
is non-null, then returns this value.
Otherwise, returns new XRect().
getOriginalBounds2D in interface Paintablepublic abstract XRect getActualBounds2D()
Returns the actual bounds of the original paintable or
null if the paintable is effectively empty.
A derived class must supply this method.
getActualBounds2D in interface Paintablepublic XPoint2D getOriginalCenter()
Returns a copy of the original center of the paint region.
In this class, the method is implemented as follows.
If the value of getDefaultOriginalCenter
is non-null, then returns this value.
Otherwise, returns the center of the rectangle returned
by the method getOriginalBounds2D.
A derived class may override this method if the object geometry suggests that a different center is more appropriate. However, if the user has set a default original center, this center must be returned by an override method.
This method must not return null.
getOriginalCenter in interface Paintable
public abstract boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation.
A derived class must supply this method.
originalContains in interface Paintablex - the x-coordinate of the pointy - the y-coordinate of the point
public final boolean originalContains(Point2D p)
Tests if a specified point is inside the original paintable without mutation.
originalContains in interface Paintablep - a specified Point2D
protected final boolean possiblyContains(double x,
double y)
Tests if a point specified by coordinates is possibly inside the original paintable.
This method returns true if and only if:
isVisible returns true.getOriginalBounds2D.This is a possible helper method for implementing the method
originalContains. Its use is up to the designer
of a derived class.
x - the x-coordinate of the pointy - the y-coordinate of the point
public final void applyOpacity(Graphics2D h)
Applies the current opacity to calculate and set a net opacity.
The following conditions must hold:
Composite set
or has a Composite of type AlphaComposite
whose rule is SRC_OVER.
In the case that the graphics context has a Composite set
of type AlphaComposite with rule SRC_OVER, then
the net opacity is the product of the current opacity of this object and
the alpha value of the AlphaComposite.
Otherwise the net opacity equals the current opacity of this object.
applyOpacity in interface Paintableh - the graphics context whose opacity will be changedpublic final void setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle, that is,
the default for computation of getBounds2D.
It is valid to set the default Bounds2D rectangle to
null to force a computation of the bounds.
Setting the default Bounds2D rectangle to a rectangle
with zero width or height is equivalent to setting it
to null.
Fires property change: SET_DEFAULT_BOUNDS2D.
setDefaultBounds2D in interface Paintablerectangle - the default Bounds2D rectanglepublic final XRect getDefaultBounds2D()
Returns a copy of the default Bounds2D rectangle, that is,
the default for computation of getBounds2D.
Returns null to signal no setting.
getDefaultBounds2D in interface Paintablepublic final void setDefaultCenter(Point2D center)
Sets the default center, that is,
the default for computation of getCenter.
It is valid to set the default center to
null to force a computation of the center.
Fires property change: SET_DEFAULT_CENTER.
setDefaultCenter in interface Paintablecenter - the default centerpublic final XPoint2D getDefaultCenter()
Returns a copy of the default center, that is,
the default for computation of getCenter.
Returns null to signal no setting.
getDefaultCenter in interface Paintablepublic final void setDefaultOriginalBounds2D(Rectangle2D rectangle)
Sets the default original Bounds2D rectangle, that is,
the default for computation of getOriginalBounds2D.
It is valid to set the default original Bounds2D rectangle
to null to force a computation of the bounds.
Setting the default original Bounds2D rectangle to a rectangle
with zero width or height is equivalent to setting it
to null.
Fires property change: SET_DEFAULT_ORIGINAL_BOUNDS2D.
setDefaultOriginalBounds2D in interface Paintablerectangle - the default original Bounds2D rectanglepublic final XRect getDefaultOriginalBounds2D()
Returns a copy of the default original Bounds2D rectangle, that is,
the default for computation of getOriginalBounds2D.
Returns null to signal no setting.
getDefaultOriginalBounds2D in interface Paintablepublic final void setDefaultOriginalCenter(Point2D center)
Sets the default original center, that is,
the default for computation of getOriginalCenter.
It is valid to set the default original center to
null to force a computation of the center.
Fires property change: SET_DEFAULT_ORIGINAL_CENTER.
setDefaultOriginalCenter in interface Paintablecenter - the default original centerpublic final XPoint2D getDefaultOriginalCenter()
Returns a copy of the default original center, that is,
the default for computation of getOriginalCenter.
Returns null to signal no setting.
getDefaultOriginalCenter in interface Paintablepublic final void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
The listener is registered for all properties.
addPropertyChangeListener in interface SupportsPropertyChangelistener - the PropertyChangeListener to be added
public final void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list for a
specific property. The listener will be invoked only when a call on
firePropertyChange names that specific property.
addPropertyChangeListener in interface SupportsPropertyChangepropertyName - the name of the property to listen onlistener - the PropertyChangeListener to be addedpublic final void addPropertyChangeListeners(PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list. These items are registered for all properties.
addPropertyChangeListeners in interface SupportsPropertyChangelisteners - the PropertyChangeListener array to be added
public final void addPropertyChangeListeners(String propertyName,
PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list for a specific property. These items will be invoked
only when a call on firePropertyChange names that specific
property.
addPropertyChangeListeners in interface SupportsPropertyChangelisteners - the PropertyChangeListener array to be addedpublic final void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.
removePropertyChangeListener in interface SupportsPropertyChangelistener - the PropertyChangeListener to be removed
public final void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.
removePropertyChangeListener in interface SupportsPropertyChangepropertyName - the name of the property that was listened onlistener - the PropertyChangeListener to be removedpublic final PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all listeners that were added to this object.
getPropertyChangeListeners in interface SupportsPropertyChangepublic final PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all listeners that were added to this object and associated with the named property.
getPropertyChangeListeners in interface SupportsPropertyChangepropertyName - the name of the property to seek
public final boolean hasListeners(String propertyName)
Check if there are any listeners for a specific property.
hasListeners in interface SupportsPropertyChangepropertyName - the name of the property to check
public final void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal and non-null.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
char oldValue,
char newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
byte oldValue,
byte newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
short oldValue,
short newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
int oldValue,
int newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
long oldValue,
long newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
float oldValue,
float newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
double oldValue,
double newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the propertypublic final void firePropertyChange(PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered
listeners. No event is fired if the given event's old and new values
are equal and non-null.
firePropertyChange in interface SupportsPropertyChangeevt - the PropertyChangeEvent objectpublic final PropertyChangeForwardingListener getForwardingListener()
Returns the PropertyChangeForwardingListener that
will forward the property change events it receives to this object.
getForwardingListener in interface SupportsPropertyChangepublic final void addForwardingListener(Object object)
addForwardingListener in interface SupportsPropertyChangeobject - the object that should add the forwarding listenerpublic final void removeForwardingListener(Object object)
removeForwardingListener in interface SupportsPropertyChangeobject - the object that should remove the forwarding listener
public final void removeAndAddForwardingListener(Object oldobject,
Object newobject)
removeAndAddForwardingListener in interface SupportsPropertyChangeoldobject - the old object that should remove the forwarding listenernewobject - the new object that should add the forwarding listener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||