edu.neu.ccs.gui
Class PaintableSequenceComposite

java.lang.Object
  |
  +--edu.neu.ccs.gui.PaintableSequenceComposite
All Implemented Interfaces:
JPTConstants, Paintable, SupportsPropertyChange, SwingConstants
Direct Known Subclasses:
PaintBar

public class PaintableSequenceComposite
extends Object
implements Paintable, SupportsPropertyChange, JPTConstants

The class PaintableSequenceComposite is a base class for the construction of Paintable classes. Although the class is not abstract, nothing useful can be done with it directly.

A derived class can control exactly what is inserted into the internal PaintableSequence via the protected access method getPaintableSequence() but this sequence is not visible to a public caller. Thus, all features of a PaintableSequence are available to a derived class without public exposure of this implementation.

Aside from the protected access method getPaintableSequence(), all methods simply implement the two interfaces Paintable() and SupportsPropertyChange() and do this by delegation to the internal paintable sequence.

Since:
2.3.2

Field Summary
 
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
 
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
PaintableSequenceComposite()
           
 
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.
 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.
 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 affected by the paint method.
 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.
protected  PaintableSequence getPaintableSequence()
          Returns the internal paintable sequence.
 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 the 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.
 void paint(Graphics g)
          Paints onto a Graphics context g using information from this object provided that the visibility property of the object is set to true.
 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 setOpacity(float opacity)
          Sets the opacity value of this paintable 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
 

Constructor Detail

PaintableSequenceComposite

public PaintableSequenceComposite()
Method Detail

getPaintableSequence

protected PaintableSequence getPaintableSequence()

Returns the internal paintable sequence.

Returns:
the internal paintable sequence

paint

public void paint(Graphics g)
Description copied from interface: Paintable

Paints onto a Graphics context g using information from this object provided that the visibility property of the object is set to true.

After this method call is complete, the internal state of g should be unchanged. In addition, this method should not paint outside of the region returned by getBounds2D.

Implementation recommendation:

To achieve the above goals, it is recommended that the graphics context g be copied to a new graphics context h and that the clip region of h be intersected with the Bounds2D rectangle. This may be done directly or may be achieved in one step by using the method getPreparedGraphics2D which also takes care of other issues.

Specified by:
paint in interface Paintable
Parameters:
g - the graphics context on which to paint

getBounds2D

public Rectangle2D getBounds2D()
Description copied from interface: Paintable
Returns a copy of the 2-dimensional bounds of the paint region affected by the paint method.

Specified by:
getBounds2D in interface Paintable
Returns:
a copy of the 2-dimensional bounds of the paint region

getCenter

public Point2D getCenter()
Description copied from interface: Paintable

Returns a copy of the center of the paint region affected by the paint method.

By default, this method may be implemented to return the center of the rectangle returned by getBounds2D(). However, a different result is permitted if the object geometry so dictates.

Specified by:
getCenter in interface Paintable
Returns:
a copy of the center of the paint region

contains

public boolean contains(double x,
                        double y)
Description copied from interface: Paintable

Tests if a point specified by coordinates is inside the paintable.

This method must return false if one or more of the following conditions occurs:

Specified by:
contains in interface Paintable
Parameters:
x - the x-coordinate of the point
y - the y-coordinate of the point
Returns:
whether or not a specified point is inside the paintable

contains

public boolean contains(Point2D p)
Description copied from interface: Paintable

Tests if a specified point is inside the paintable.

This method must return false if one or more of the following conditions occurs:

Specified by:
contains in interface Paintable
Parameters:
p - a specified Point2D
Returns:
whether or not a specified point is inside the paintable

setVisible

public void setVisible(boolean visible)
Description copied from interface: Paintable

Sets the visibility property of this paintable.

The default for the visibility property should be true

.

Specified by:
setVisible in interface Paintable
Parameters:
visible - the visibility setting
See Also:
Paintable.isVisible()

isVisible

public boolean isVisible()
Description copied from interface: Paintable
Returns the current visibility property of this paintable.

Specified by:
isVisible in interface Paintable
See Also:
Paintable.setVisible(boolean)

setOpacity

public void setOpacity(float opacity)
Description copied from interface: Paintable
Sets the opacity value of this paintable between 0 and 1.

Specified by:
setOpacity in interface Paintable
Parameters:
opacity - the opacity value of this paintable between 0 and 1
See Also:
Paintable.getOpacity()

getOpacity

public float getOpacity()
Description copied from interface: Paintable
Returns the opacity value of this paintable between 0 and 1.

Specified by:
getOpacity in interface Paintable
Returns:
the opacity value of this paintable between 0 and 1
See Also:
Paintable.setOpacity(float)

getPreparedGraphics2D

public Graphics2D getPreparedGraphics2D(Graphics g)
Description copied from interface: Paintable

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 the paintable if needed.

For convenience, return the graphics context as a Graphics2D object.

Specified by:
getPreparedGraphics2D in interface Paintable
Parameters:
g - the given graphics context to copy
Returns:
a suitably prepared copy of the given graphics context

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: SupportsPropertyChange

Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
addPropertyChangeListener in interface SupportsPropertyChange
Parameters:
listener - the PropertyChangeListener to be added

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Description copied from interface: SupportsPropertyChange

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.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
addPropertyChangeListener in interface SupportsPropertyChange
Parameters:
propertyName - the name of the property to listen on
listener - the PropertyChangeListener to be added

addPropertyChangeListeners

public void addPropertyChangeListeners(PropertyChangeListener[] listeners)
Description copied from interface: SupportsPropertyChange

Add all items in the given PropertyChangeListener array to the listener list. These items are registered for all properties.

Specified by:
addPropertyChangeListeners in interface SupportsPropertyChange
Parameters:
listeners - the PropertyChangeListener array to be added

addPropertyChangeListeners

public void addPropertyChangeListeners(String propertyName,
                                       PropertyChangeListener[] listeners)
Description copied from interface: SupportsPropertyChange

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.

Specified by:
addPropertyChangeListeners in interface SupportsPropertyChange
Parameters:
listeners - the PropertyChangeListener array to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: SupportsPropertyChange

Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
removePropertyChangeListener in interface SupportsPropertyChange
Parameters:
listener - the PropertyChangeListener to be removed

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Description copied from interface: SupportsPropertyChange

Remove a PropertyChangeListener for a specific property.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
removePropertyChangeListener in interface SupportsPropertyChange
Parameters:
propertyName - the name of the property that was listened on
listener - the PropertyChangeListener to be removed

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Description copied from interface: SupportsPropertyChange

Returns an array of all listeners that were added to this object.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
getPropertyChangeListeners in interface SupportsPropertyChange
Returns:
an array with all listeners

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Description copied from interface: SupportsPropertyChange

Returns an array of all listeners that were added to this object and associated with the named property.

This method is found in:

  • Component
  • JComponent
  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
getPropertyChangeListeners in interface SupportsPropertyChange
Parameters:
propertyName - the name of the property to seek
Returns:
an array with all listeners for the given named property

hasListeners

public boolean hasListeners(String propertyName)
Description copied from interface: SupportsPropertyChange

Check if there are any listeners for a specific property.

This method is found in:

  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
hasListeners in interface SupportsPropertyChange
Parameters:
propertyName - the name of the property to check
Returns:
whether or not there are any listeners for a specific property

firePropertyChange

public void firePropertyChange(String propertyName,
                               Object oldValue,
                               Object newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal and non-null.

This method is found in:

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               boolean oldValue,
                               boolean newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               char oldValue,
                               char newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               byte oldValue,
                               byte newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               short oldValue,
                               short newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               int oldValue,
                               int newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               long oldValue,
                               long newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               float oldValue,
                               float newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               double oldValue,
                               double newValue)
Description copied from interface: SupportsPropertyChange

Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.

This is merely a convenience wrapper around the more general firePropertyChange method that takes Object values.

This method is found in:

  • JComponent

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
propertyName - the programmatic name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(PropertyChangeEvent evt)
Description copied from interface: SupportsPropertyChange

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.

This method is found in:

  • PropertyChangeSupport
  • SwingPropertyChangeSupport

Specified by:
firePropertyChange in interface SupportsPropertyChange
Parameters:
evt - the PropertyChangeEvent object

getForwardingListener

public PropertyChangeForwardingListener getForwardingListener()
Description copied from interface: SupportsPropertyChange

Returns the PropertyChangeForwardingListener that will forward the property change events it receives to this object.

Specified by:
getForwardingListener in interface SupportsPropertyChange
Returns:
the forwarding listener

addForwardingListener

public void addForwardingListener(Object object)
Description copied from interface: SupportsPropertyChange
Add the forwarding listener as a property change listener for the given object if the object supports property change.

Specified by:
addForwardingListener in interface SupportsPropertyChange
Parameters:
object - the object that should add the forwarding listener

removeForwardingListener

public void removeForwardingListener(Object object)
Description copied from interface: SupportsPropertyChange
Remove the forwarding listener as a property change listener for the given object if the object supports property change.

Specified by:
removeForwardingListener in interface SupportsPropertyChange
Parameters:
object - the object that should remove the forwarding listener

removeAndAddForwardingListener

public void removeAndAddForwardingListener(Object oldobject,
                                           Object newobject)
Description copied from interface: SupportsPropertyChange
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.

Specified by:
removeAndAddForwardingListener in interface SupportsPropertyChange
Parameters:
oldobject - the old object that should remove the forwarding listener
newobject - the new object that should add the forwarding listener