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.

In 2.3.5, the class was refactored to be consistent with the new Paintable interface and the new AbstractPaintable class.

In 2.4.0, this class was updated to be consistent with refinements to the Paintable interface.

Since:
2.3.2

Field Summary
 
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
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 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)
          Apply the current opacity to calculate and set a net opacity for the given graphics context.
 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.
 XRect getActualBounds2D()
          Returns the actual bounds of the original paintable or null if the paintable is effectively empty.
 XRect getBounds2D()
          Returns a copy of the 2-dimensional bounds of the paintable.
 XPoint2D getCenter()
          Returns a copy of the center of the paintable.
 XPoint2D getCorner()
          Returns a copy of 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.
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 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.
 void move(double x, double y)
          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 should always be implemented to do exactly the same operation as the corresponding method addPostMutation.
 void mutate(Mutator.Strategy strategy)
          This method should always be implemented to do exactly the same operation as the corresponding method addPostMutation.
 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.
 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 using information from this object.
 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.
 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 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 setMutation 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
 

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 using information from this object.

A recommended implementation should adopt the following policy:

Whatever the implementation, when this method call is complete, the internal state of g should be unchanged.

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

paintAt

public void paintAt(Graphics g,
                    double x,
                    double y)
Description copied from interface: Paintable

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) should be 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.

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

paintAt

public void paintAt(Graphics g,
                    Point2D p)
Description copied from interface: Paintable

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.

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

paintAt

public void paintAt(Graphics g,
                    AffineTransform T,
                    double x,
                    double y)
Description copied from interface: Paintable

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.

Specified by:
paintAt in interface Paintable
Parameters:
g - the graphics context on which to paint
T - the affine transform to apply to the translation point
x - the original x-translation before transformation
y - the original y-translation before transformation

paintAt

public void paintAt(Graphics g,
                    AffineTransform T,
                    Point2D p)
Description copied from interface: Paintable

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.

Specified by:
paintAt in interface Paintable
Parameters:
g - the graphics context on which to paint
T - the affine transform to apply to the translation point
p - the original translation point before transformation

getBounds2D

public XRect getBounds2D()
Description copied from interface: Paintable

Returns a copy of the 2-dimensional bounds of the paintable.

A recommended implementation should adopt the following policy:

If the value of getDefaultBounds2D is non-null, then return this value.

Otherwise, return a reasonable estimate of the bounds within computational constraints.

This method must not return null.

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

getCenter

public XPoint2D getCenter()
Description copied from interface: Paintable

Returns a copy of the center of the paintable.

A recommended implementation should adopt the following policy:

If the value of getDefaultCenter is non-null, then return this value.

Otherwise, return a computed value of the center.

This method must not return null.

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

getCorner

public XPoint2D getCorner()
Description copied from interface: Paintable

Returns a copy of the corner of the paintable.

The corner should be the top-left corner of the bounds rectangle returned by getBounds2D.

Specified by:
getCorner in interface Paintable
Returns:
a copy the corner of the paintable

setDefaultBounds2D

public void setDefaultBounds2D(Rectangle2D rectangle)
Description copied from interface: Paintable

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 should be equivalent to setting it to null.

Fires property change: SET_DEFAULT_BOUNDS2D.

Specified by:
setDefaultBounds2D in interface Paintable
Parameters:
rectangle - the default Bounds2D rectangle

getDefaultBounds2D

public XRect getDefaultBounds2D()
Description copied from interface: Paintable

Returns a copy of the default Bounds2D rectangle, that is, the default for computation of getBounds2D.

Returns null to signal no setting.

Specified by:
getDefaultBounds2D in interface Paintable
Returns:
a copy of the default Bounds2D rectangle

setDefaultCenter

public void setDefaultCenter(Point2D center)
Description copied from interface: Paintable

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.

Specified by:
setDefaultCenter in interface Paintable
Parameters:
center - the default center

getDefaultCenter

public XPoint2D getDefaultCenter()
Description copied from interface: Paintable

Returns a copy of the default center, that is, the default for computation of getCenter.

Returns null to signal no setting.

Specified by:
getDefaultCenter in interface Paintable
Returns:
a copy of the default center

contains

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

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

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.

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

originalPaint

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

Paints onto a Graphics context using information from this object but without the use of the mutator transform.

This method should be the foundation for the paint methods that use the mutator.

The designer of this method should 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.

Whatever the implementation, when this method call is complete, the internal state of g should be unchanged.

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

getOriginalBounds2D

public XRect getOriginalBounds2D()
Description copied from interface: Paintable

Returns a copy of the 2-dimensional bounds of the original paintable prior to any mutation.

A recommended implementation should adopt the following policy:

If the value of getDefaultOriginalBounds2D is non-null, then return this value.

If the value of getActualBounds2D is non-null, then return this value.

Otherwise, return new XRect().

This method must not return null.

Specified by:
getOriginalBounds2D in interface Paintable
Returns:
a copy of the 2-dimensional bounds of the original paintable

getActualBounds2D

public XRect getActualBounds2D()
Description copied from interface: Paintable

Returns the actual bounds of the original paintable or null if the paintable is effectively empty.

Specified by:
getActualBounds2D in interface Paintable

getOriginalCenter

public XPoint2D getOriginalCenter()
Description copied from interface: Paintable

Returns a copy of the original center of the paint region.

A recommended implementation should adopt the following policy:

If the value of getDefaultOriginalCenter is non-null, then return this value.

Otherwise, return a computed value of the center.

This method must not return null.

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

setDefaultOriginalBounds2D

public void setDefaultOriginalBounds2D(Rectangle2D rectangle)
Description copied from interface: Paintable

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 should be equivalent to setting it to null.

Fires property change: SET_DEFAULT_ORIGINAL_BOUNDS2D.

Specified by:
setDefaultOriginalBounds2D in interface Paintable
Parameters:
rectangle - the default original Bounds2D rectangle

getDefaultOriginalBounds2D

public XRect getDefaultOriginalBounds2D()
Description copied from interface: Paintable

Returns a copy of the default original Bounds2D rectangle, that is, the default for computation of getOriginalBounds2D.

Returns null to signal no setting.

Specified by:
getDefaultOriginalBounds2D in interface Paintable
Returns:
a copy of the default original Bounds2D rectangle

setDefaultOriginalCenter

public void setDefaultOriginalCenter(Point2D center)
Description copied from interface: Paintable

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.

Specified by:
setDefaultOriginalCenter in interface Paintable
Parameters:
center - the default original center

getDefaultOriginalCenter

public XPoint2D getDefaultOriginalCenter()
Description copied from interface: Paintable

Returns a copy of the default original center, that is, the default for computation of getOriginalCenter.

Returns null to signal no setting.

Specified by:
getDefaultOriginalCenter in interface Paintable
Returns:
a copy of the default original center

originalContains

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

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

Specified by:
originalContains 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 original paintable

originalContains

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

Tests if a specified point is inside the original paintable without mutation.

Specified by:
originalContains in interface Paintable
Parameters:
p - a specified Point2D
Returns:
whether or not a specified point is inside the original 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

.

Fires property change: SET_VISIBLE.

Specified by:
setVisible in interface Paintable
Parameters:
visible - the visibility setting

isVisible

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

Specified by:
isVisible in interface Paintable

setOpacity

public void setOpacity(float opacity)
Description copied from interface: Paintable

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.

Specified by:
setOpacity in interface Paintable
Parameters:
opacity - the opacity of this paintable

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

applyOpacity

public void applyOpacity(Graphics2D h)
Description copied from interface: Paintable

Apply the current opacity to calculate and set a net opacity for the given graphics context.

The following conditions must hold:

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 context's AlphaComposite.

Otherwise the net opacity equals the current opacity of this object.

It is recommended that this method be used in the implementation of the getPreparedGraphics2D method.

Specified by:
applyOpacity in interface Paintable
Parameters:
h - the graphics context whose opacity will be changed

getPreparedGraphics2D

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

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 should be returned as a Graphics2D object.

It is recommended that this method be used in the implementation of the paint method.

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

setMutator

public void setMutator(AffineTransform M)
Description copied from interface: Paintable

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.

Specified by:
setMutator in interface Paintable
Parameters:
M - the invertible affine transform to set as the mutator

setMutator

public void setMutator(Mutator.Strategy strategy)
Description copied from interface: Paintable

Applies a Mutator.Strategy object to the paintable by constructing an affine transform using the original center of the paintable and then calling setMutation 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.

Specified by:
setMutator in interface Paintable
Parameters:
strategy - the mutator strategy to apply

addPreMutation

public void addPreMutation(AffineTransform M)
Description copied from interface: Paintable

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.

Specified by:
addPreMutation in interface Paintable
Parameters:
M - the invertible affine transform to compose

addPreMutation

public void addPreMutation(Mutator.Strategy strategy)
Description copied from interface: Paintable

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.

Specified by:
addPreMutation in interface Paintable
Parameters:
strategy - the mutator strategy to apply

addPostMutation

public void addPostMutation(AffineTransform M)
Description copied from interface: Paintable

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.

Specified by:
addPostMutation in interface Paintable
Parameters:
M - the invertible affine transform to compose

addPostMutation

public void addPostMutation(Mutator.Strategy strategy)
Description copied from interface: Paintable

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.

Specified by:
addPostMutation in interface Paintable
Parameters:
strategy - the mutator strategy to apply

getMutator

public AffineTransform getMutator()
Description copied from interface: Paintable

Returns a copy of the existing mutator transform.

If the implementation chooses to distribute transforms to sub-objects, then this method may validly always return the identity transform.

Specified by:
getMutator in interface Paintable
Returns:
a copy of the existing mutator transform

getMutatorInverse

public AffineTransform getMutatorInverse()
Description copied from interface: Paintable

Returns a copy of the existing mutator inverse transform.

If the implementation chooses to distribute transforms to sub-objects, then this method may validly always return the identity transform.

Specified by:
getMutatorInverse in interface Paintable
Returns:
a copy of the existing mutator inverse transform

mutate

public void mutate(AffineTransform M)
Description copied from interface: Paintable

This method should always be implemented to do exactly the same operation as the corresponding method addPostMutation. In other words, this should simply be a convenience method with a short name.

Specified by:
mutate in interface Paintable
Parameters:
M - the invertible affine transform to compose
See Also:
Paintable.addPostMutation(AffineTransform)

mutate

public void mutate(Mutator.Strategy strategy)
Description copied from interface: Paintable

This method should always be implemented to do exactly the same operation as the corresponding method addPostMutation. In other words, this should simply be a convenience method with a short name.

Specified by:
mutate in interface Paintable
Parameters:
strategy - the mutator strategy to apply
See Also:
Paintable.addPostMutation(Mutator.Strategy)

move

public void move(double x,
                 double y)
Description copied from interface: Paintable

Moves the paintable by a translation using the data in the point specified by coordinates.

Specified by:
move in interface Paintable
Parameters:
x - the x-coordinate of the translation
y - the y-coordinate of the translation

move

public void move(Point2D p)
Description copied from interface: Paintable

Moves the paintable by a translation using the data in the point.

Specified by:
move in interface Paintable
Parameters:
p - the translation vector

moveCenterTo

public void moveCenterTo(double x,
                         double y)
Description copied from interface: Paintable

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.

Specified by:
moveCenterTo in interface Paintable
Parameters:
x - the x-coordinate of the desired center
y - the y-coordinate of the desired center

moveCenterTo

public void moveCenterTo(Point2D p)
Description copied from interface: Paintable

Moves the paintable by a translation in such a way that the paintable center specified by getCenter will move to the given point.

Specified by:
moveCenterTo in interface Paintable
Parameters:
p - the desired center

moveCornerTo

public void moveCornerTo(double x,
                         double y)
Description copied from interface: Paintable

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.

Specified by:
moveCornerTo in interface Paintable
Parameters:
x - the x-coordinate of the desired corner
y - the y-coordinate of the desired corner

moveCornerTo

public void moveCornerTo(Point2D p)
Description copied from interface: Paintable

Moves the paintable by a translation in such a way that the paintable corner specified by getCorner will move to the given point.

Specified by:
moveCornerTo in interface Paintable
Parameters:
p - the desired corner

rotate

public void rotate(double degrees)
Description copied from interface: Paintable

Rotates the paintable about its center by the given angle in degrees.

Specified by:
rotate in interface Paintable
Parameters:
degrees - the rotation angle in degrees

reflect

public void reflect(double degrees)
Description copied from interface: Paintable
Reflects the paintable along the line through its center at the given angle in degrees.

Specified by:
reflect in interface Paintable
Parameters:
degrees - the angle in degrees of the line of reflection

hreflect

public void hreflect()
Description copied from interface: Paintable
Reflects the paintable along a horizontal axis through its center.

Specified by:
hreflect in interface Paintable

vreflect

public void vreflect()
Description copied from interface: Paintable
Reflects the paintable along a vertical axis through its center.

Specified by:
vreflect in interface Paintable

scale

public void scale(double s)
Description copied from interface: Paintable

Scales the paintable about its center by the given factor s uniformly in all directions.

Specified by:
scale in interface Paintable
Parameters:
s - the scale in all directions

scale

public void scale(double degrees,
                  double s,
                  double t)
Description copied from interface: Paintable

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.

Specified by:
scale in interface Paintable
Parameters:
degrees - the angle in degrees of the main scaling axis
s - the scale factor along the axis at angle degrees
t - the scale factor along the axis at angle degrees+90

shear

public void shear(double degrees,
                  double s)
Description copied from interface: Paintable

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.

Specified by:
shear in interface Paintable
Parameters:
degrees - the angle in degrees of the fixed axis for shear
s - determines the amount of shear along lines parallel to the fixed axis for shear

glide

public void glide(double degrees,
                  double distance)
Description copied from interface: Paintable

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.

Specified by:
glide in interface Paintable
Parameters:
degrees - the angle in degrees of the line of glide
distance - the translation distance along the line of glide

glidereflect

public void glidereflect(double degrees,
                         double distance)
Description copied from interface: Paintable
Glide-reflects the paintable along the line through its center at the given angle in degrees and the given glide distance.

Specified by:
glidereflect in interface Paintable
Parameters:
degrees - the angle in degrees of the line of glide reflection
distance - the translation distance along the line of glide reflection

lineartransform

public void lineartransform(double m00,
                            double m10,
                            double m01,
                            double m11)
Description copied from interface: Paintable

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.

Specified by:
lineartransform in interface Paintable
Parameters:
m00 - the matrix coefficient in row 0 column 0
m10 - the matrix coefficient in row 1 column 0
m01 - the matrix coefficient in row 0 column 1
m11 - the matrix coefficient in row 1 column 1

affinetransform

public void affinetransform(double m00,
                            double m10,
                            double m01,
                            double m11,
                            double m02,
                            double m12)
Description copied from interface: Paintable

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.

Specified by:
affinetransform in interface Paintable
Parameters:
m00 - the matrix coefficient in row 0 column 0
m10 - the matrix coefficient in row 1 column 0
m01 - the matrix coefficient in row 0 column 1
m11 - the matrix coefficient in row 1 column 1
m02 - the matrix coefficient in row 0 column 2
m12 - the matrix coefficient in row 1 column 2

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