|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.neu.ccs.gui.AbstractPaintable
The abstract class AbstractPaintable defines objects that
implement Paintable and SupportsPropertyChange.
| Field Summary | |
static String |
SET_DEFAULT_BOUNDS2D
Bound property name for set default bounds2D. |
static String |
SET_DEFAULT_CENTER
Bound property name for set default center. |
static String |
SET_OPACITY
Bound property name for set opacity. |
static String |
SET_VISIBLE
Bound property name for set visible. |
| 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 |
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 |
applyOpacity(Graphics2D h)
Applies the current opacity to calculate and set a net opacity. |
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 Rectangle2D |
getBounds2D()
Returns a copy of the 2-dimensional bounds of the paint region affected by the paint method. |
Point2D |
getCenter()
Returns a copy of the center of the paint region. |
Rectangle2D |
getDefaultBounds2D()
Returns a copy of the default Bounds2D rectangle. |
Point2D |
getDefaultCenter()
Returns a copy of the default center. |
PropertyChangeForwardingListener |
getForwardingListener()
Returns the PropertyChangeForwardingListener that
will forward the property change events it receives to this object. |
float |
getOpacity()
Returns the opacity value of this paintable between 0 and 1. |
Graphics2D |
getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to set anti-aliasing on, to clip to within the bounds region, 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. |
boolean |
hasListeners(String propertyName)
Check if there are any listeners for a specific property. |
boolean |
isVisible()
Returns the current visibility property of this paintable. |
abstract void |
paint(Graphics g)
Paints onto a Graphics context using information
from this object. |
protected boolean |
possiblyContains(double x,
double y)
Tests if a point specified by coordinates is possibly inside the paintable. |
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 |
setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle. |
void |
setDefaultCenter(Point2D center)
Sets the default center. |
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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface edu.neu.ccs.gui.Paintable |
contains |
| Field Detail |
public static final String SET_DEFAULT_BOUNDS2D
public static final String SET_DEFAULT_CENTER
public static final String SET_VISIBLE
public static final String SET_OPACITY
| Constructor Detail |
public AbstractPaintable()
| Method Detail |
public abstract void paint(Graphics g)
Paints onto a Graphics context using information
from this object.
When this method call is complete, the internal state of g should be unchanged.
paint in interface Paintableg - the graphics context on which to paintgetPreparedGraphics2D(Graphics)public abstract Rectangle2D getBounds2D()
Returns a copy of the 2-dimensional bounds of the paint region
affected by the paint method.
getBounds2D in interface PaintablesetDefaultBounds2D(Rectangle2D),
getDefaultBounds2D()public Point2D getCenter()
Returns a copy of the center of the paint region.
In this class, the method is implemented to return the
center of the rectangle returned by the method
getBounds2D.
However, a derived class may override this method if the object geometry suggests a different result.
getCenter in interface PaintablesetDefaultCenter(Point2D),
getDefaultCenter()public final void setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle.
If the default Bounds2D rectangle is non-null,
then a derived class may choose to use this default rather than
perform a computation to obtain more exact bounds. Thus, the
use of this default is optional rather than mandatory.
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.
A derived class should specify whether it uses the default
Bounds2D rectangle in cases when it is non-null.
Fires property change: SET_DEFAULT_BOUNDS2D.
rectangle - the default Bounds2D rectanglegetBounds2D(),
getDefaultBounds2D()public final Rectangle2D getDefaultBounds2D()
getBounds2D(),
setDefaultBounds2D(Rectangle2D)public final void setDefaultCenter(Point2D center)
Sets the default center.
If the default center is non-null,
then a derived class may choose to use this default rather than
perform a computation to obtain a more exact center. Thus, the
use of this default is optional rather than mandatory.
It is valid to set the default center to
null to force a computation of the center.
A derived class should specify whether it uses the default
center in cases when it is non-null.
Fires property change: SET_DEFAULT_CENTER.
center - the default centergetCenter(),
getDefaultCenter()public final Point2D getDefaultCenter()
getCenter(),
setDefaultCenter(Point2D)public final boolean contains(Point2D p)
Tests if a specified point is inside the paintable.
This method returns false if one or more of the following
conditions occurs:
null.getBounds2D.isVisible returns false.
contains 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 paintable.
This method returns true if and only if:
getBounds2D.isVisible returns true.This is a helper method for implementing contains.
x - the x-coordinate of the pointy - the y-coordinate of the 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 settingisVisible(),
setOpacity(float),
getOpacity()public final boolean isVisible()
isVisible in interface PaintablesetVisible(boolean),
setOpacity(float),
getOpacity()public 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 paintablegetOpacity(),
setVisible(boolean),
isVisible()public final float getOpacity()
getOpacity in interface PaintablesetOpacity(float),
setVisible(boolean),
isVisible()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.
h - the graphics context whose opacity will be changedpublic final Graphics2D getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to set anti-aliasing on, to clip to within the bounds region, 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 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 | |||||||||