edu.neu.ccs.gui
Class AbstractMutatablePaintable

java.lang.Object
  |
  +--edu.neu.ccs.gui.AbstractPaintable
        |
        +--edu.neu.ccs.gui.AbstractMutatablePaintable
All Implemented Interfaces:
MutatablePaintable, Paintable, SupportsPropertyChange
Direct Known Subclasses:
MutatableWrapper, PaintableSequence

public abstract class AbstractMutatablePaintable
extends AbstractPaintable
implements MutatablePaintable

The abstract class AbstractMutatablePaintable defines objects that extend AbstractPaintable and implement MutatablePaintable.

Since:
2.3

Field Summary
static String SET_MUTATOR
          Bound property name for set mutator.
 
Fields inherited from class edu.neu.ccs.gui.AbstractPaintable
SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_OPACITY, SET_VISIBLE
 
Constructor Summary
AbstractMutatablePaintable()
           
 
Method Summary
 void addPostMutation(AffineTransform M)
          Composes the existing 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 composition on the left using the mutated center to construct the post-mutation.
 void addPreMutation(AffineTransform M)
          Composes the existing mutator on the right with the given transform provided that the given transform is invertible.
 void addPreMutation(Mutator.Strategy strategy)
          Applies a Mutator.Strategy object to the paintable by composition on the right using the original center to construct the pre-mutation.
 Rectangle2D getBounds2D()
          Returns a copy of the 2-dimensional bounds of the mutated paintable.
 Point2D getCenter()
          Returns a copy the center of the mutated paintable.
 AffineTransform getMutator()
          Returns a copy of the existing mutator transform.
 AffineTransform getMutatorInverse()
          Returns a copy of the existing mutator inverse transform.
abstract  Rectangle2D getOriginalBounds2D()
          Returns a copy of the 2-dimensional bounds of the original paintable.
abstract  Point2D getOriginalCenter()
          Returns a copy the center of the original paintable.
 void move(double x, double y)
          Moves the mutatable by a translation using the data in the point specified by coordinates.
 void move(Point2D p)
          Moves the mutatable by a translation using the data in the point.
 void setMutator(AffineTransform M)
          Sets the mutator transform to the given transform provided that the given transform is invertible.
 
Methods inherited from class edu.neu.ccs.gui.AbstractPaintable
addForwardingListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, applyOpacity, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getDefaultBounds2D, getDefaultCenter, getForwardingListener, getOpacity, getPreparedGraphics2D, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, isVisible, paint, possiblyContains, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, setDefaultBounds2D, setDefaultCenter, setOpacity, setVisible
 
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, contains, getOpacity, getPreparedGraphics2D, isVisible, paint, setOpacity, setVisible
 

Field Detail

SET_MUTATOR

public static final String SET_MUTATOR
Bound property name for set mutator.

See Also:
Constant Field Values
Constructor Detail

AbstractMutatablePaintable

public AbstractMutatablePaintable()
Method Detail

getBounds2D

public Rectangle2D getBounds2D()

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

By default, this method returns the bounds rectangle of the image of the original bounds rectangle, getOriginalBounds2D, under the mutator transform.

This method may be overridden in a derived class if a more exact bounds rectangle may be calculated or if the relationship between getBounds2D and getOriginalBounds2D is more subtle.

This method does not use the default Bounds2D rectangle as defined by setDefaultBounds2D in AbstractPaintable. The decision to use the default Bounds2D rectangle is left to derived classes.

This method must not return null.

Specified by:
getBounds2D in interface Paintable
Specified by:
getBounds2D in class AbstractPaintable
Returns:
a copy of the 2-dimensional bounds of the mutated paintable
See Also:
getOriginalBounds2D(), AbstractPaintable.setDefaultBounds2D(Rectangle2D), AbstractPaintable.getDefaultBounds2D()

getCenter

public Point2D getCenter()

Returns a copy the center of the mutated paintable.

By default, this returns the image of getOriginalCenter() under the mutator transform.

This method may be overridden in a derived class if a more exact center may be calculated.

This method does not use the default center as defined by setDefaultCenter in AbstractPaintable. The decision to use the default center is left to derived classes.

This method must not return null.

Specified by:
getCenter in interface Paintable
Overrides:
getCenter in class AbstractPaintable
Returns:
a copy the center of the mutated paintable
See Also:
getOriginalCenter(), AbstractPaintable.setDefaultCenter(Point2D), AbstractPaintable.getDefaultCenter()

getOriginalBounds2D

public abstract Rectangle2D getOriginalBounds2D()

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

If the current paintable is empty, this method should return new Rectangle2D.Double().

This method must not return null.

Specified by:
getOriginalBounds2D in interface MutatablePaintable
Returns:
a copy of the 2-dimensional bounds of the original paintable
See Also:
getBounds2D()

getOriginalCenter

public abstract Point2D getOriginalCenter()

Returns a copy the center of the original paintable.

If the current paintable is empty, this method should return new Point2D.Double().

This method must not return null.

Specified by:
getOriginalCenter in interface MutatablePaintable
Returns:
a copy the center of the original paintable
See Also:
getCenter()

setMutator

public void setMutator(AffineTransform M)

Sets the mutator transform to 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.

This method may be overridden in a derived class if additional work must be done when the mutator is set.

Specified by:
setMutator in interface MutatablePaintable
Parameters:
M - the invertible affine transform to set as the mutator
See Also:
addPreMutation(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(AffineTransform), addPostMutation(Mutator.Strategy), getMutator(), getMutatorInverse()

addPreMutation

public final void addPreMutation(AffineTransform M)

Composes the existing mutator on the right with the given transform provided that the given transform is invertible.

The action of the new mutator will be to apply the given transform and then to apply the old mutator.

This method is equivalent to:

setMutator(TransformFactory.compose(getMutator(), M))

Fires property change: SET_MUTATOR.

Specified by:
addPreMutation in interface MutatablePaintable
Parameters:
M - the invertible affine transform to compose on the right with the existing mutator
See Also:
setMutator(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(AffineTransform), addPostMutation(Mutator.Strategy), getMutator(), getMutatorInverse()

addPreMutation

public void addPreMutation(Mutator.Strategy strategy)

Applies a Mutator.Strategy object to the paintable by composition on the right using the original center to construct the pre-mutation.

Fires property change: SET_MUTATOR.

This method may be overridden in a derived class if the mutator strategy will be used in a more subtle fashion. The overriding method must continue to fire the SET_MUTATOR property change.

Specified by:
addPreMutation in interface MutatablePaintable
Parameters:
strategy - the mutator strategy to apply
See Also:
setMutator(AffineTransform), addPreMutation(AffineTransform), addPostMutation(AffineTransform), addPostMutation(Mutator.Strategy), getMutator(), getMutatorInverse()

addPostMutation

public final void addPostMutation(AffineTransform M)

Composes the existing mutator on the left with the given transform provided that the given transform is invertible.

The action of the new mutator will be to apply the old mutator and then to apply the given transform.

This method is equivalent to:

setMutator(TransformFactory.compose(M, getMutator()))

Fires property change: SET_MUTATOR.

Specified by:
addPostMutation in interface MutatablePaintable
Parameters:
M - the invertible affine transform to compose on the left with the existing mutator
See Also:
setMutator(AffineTransform), addPreMutation(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(Mutator.Strategy), getMutator(), getMutatorInverse()

addPostMutation

public void addPostMutation(Mutator.Strategy strategy)

Applies a Mutator.Strategy object to the paintable by composition on the left using the mutated center to construct the post-mutation.

Fires property change: SET_MUTATOR.

This method may be overridden in a derived class if the mutator strategy will be used in a more subtle fashion. The overriding method must continue to fire the SET_MUTATOR property change.

Specified by:
addPostMutation in interface MutatablePaintable
Parameters:
strategy - the mutator strategy to apply
See Also:
setMutator(AffineTransform), addPreMutation(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(AffineTransform), getMutator(), getMutatorInverse()

getMutator

public final AffineTransform getMutator()
Returns a copy of the existing mutator transform.

Specified by:
getMutator in interface MutatablePaintable
Returns:
a copy of the existing mutator transform
See Also:
setMutator(AffineTransform), addPreMutation(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(AffineTransform), addPostMutation(Mutator.Strategy), getMutatorInverse()

getMutatorInverse

public final AffineTransform getMutatorInverse()
Returns a copy of the existing mutator inverse transform.

Specified by:
getMutatorInverse in interface MutatablePaintable
Returns:
a copy of the existing mutator inverse transform
See Also:
setMutator(AffineTransform), addPreMutation(AffineTransform), addPreMutation(Mutator.Strategy), addPostMutation(AffineTransform), addPostMutation(Mutator.Strategy), getMutator()

move

public final void move(double x,
                       double y)

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

This method should act as a convenience method that performs an addPostMutation operation using a translation defined by the given point.

Specified by:
move in interface MutatablePaintable
Parameters:
x - the x-coordinate of the point
y - the y-coordinate of the point

move

public final void move(Point2D p)

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

This method should act as a convenience method that performs an addPostMutation operation using a translation defined by the given point.

If the point is null, this method should do nothing.

Specified by:
move in interface MutatablePaintable
Parameters:
p - a specified Point2D