JHotDraw 6.0b1

org.jhotdraw.standard
Class DecoratorFigure

java.lang.Object
  extended by org.jhotdraw.standard.AbstractFigure
      extended by org.jhotdraw.standard.DecoratorFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Figure, FigureChangeListener, Storable
Direct Known Subclasses:
AnimationDecorator, BorderDecorator

public abstract class DecoratorFigure
extends AbstractFigure
implements FigureChangeListener

DecoratorFigure can be used to decorate other figures with decorations like borders. Decorator forwards all the methods to their contained figure. Subclasses can selectively override these methods to extend and filter their behavior.


Design Patterns

 o Decorator
DecoratorFigure is a decorator.

See Also:
Figure, Serialized Form

Constructor Summary
DecoratorFigure()
           
DecoratorFigure(Figure figure)
          Constructs a DecoratorFigure and decorates the passed in figure.
 
Method Summary
 void addDependendFigure(Figure newDependendFigure)
          Add a dependent figure.
 void basicDisplayBox(java.awt.Point origin, java.awt.Point corner)
          Forwards basicDisplayBox to its contained figure.
protected  void basicMoveBy(int x, int y)
          Forwards basicMoveBy to its contained figure.
 boolean canConnect()
          Forwards the canConnect to its contained figure..
 Locator connectedTextLocator(Figure text)
          Returns the locator used to located connected text.
 java.awt.Insets connectionInsets()
          Forwards the connection insets to its contained figure..
 Connector connectorAt(int x, int y)
          Returns the Connector for the given location.
 void connectorVisibility(boolean isVisible, ConnectionFigure courtingConnection)
          Forwards the connector visibility request to its component.
 boolean containsPoint(int x, int y)
          Forwards containsPoint to its contained figure.
 FigureEnumeration decompose()
          Forwards decompose to its contained figure.
 void decorate(Figure figure)
          Decorates the given figure.
 java.awt.Rectangle displayBox()
          Forwards displayBox to its contained figure.
 void draw(java.awt.Graphics g)
          Forwards draw to its contained figure.
 void figureChanged(FigureChangeEvent e)
          Sent when a figure changed
 void figureInvalidated(FigureChangeEvent e)
          Propagates invalidate up the container chain.
 void figureRemoved(FigureChangeEvent e)
          Sent when a figure was removed
 void figureRequestRemove(FigureChangeEvent e)
          Propagates the removeFromDrawing request up to the container.
 void figureRequestUpdate(FigureChangeEvent e)
          Propagates figureRequestUpdate up the container chain.
 FigureEnumeration figures()
          Forwards figures to its contained figure.
 Figure findFigureInside(int x, int y)
          Forwards findFigureInside to its contained figure.
 java.lang.Object getAttribute(FigureAttributeConstant attributeConstant)
          Forwards getAttribute to its contained figure.
 java.lang.Object getAttribute(java.lang.String name)
          Deprecated. use getAttribute(FigureAttributeConstant) instead
 Figure getDecoratedFigure()
          Get the underlying figure in case the figure has been decorated.
 FigureEnumeration getDependendFigures()
          Get an enumeration of all dependent figures.
 TextHolder getTextHolder()
          Some figures have the ability to hold text.
 HandleEnumeration handles()
          Forwards handles to its contained figure.
 boolean includes(Figure figure)
          Forwards includes to its contained figure.
protected  void initialize()
          Performs additional initialization code before the figure is decorated.
 void moveBy(int x, int y)
          Forwards moveBy to its contained figure.
 Figure peelDecoration()
          Removes the decoration from the contained figure.
 void read(StorableInput dr)
          Reads itself and the contained figure from the StorableInput.
 void release()
          Releases itself and the contained figure.
 void removeDependendFigure(Figure oldDependendFigure)
          Remove a dependent figure.
 void setAttribute(FigureAttributeConstant attributeConstant, java.lang.Object value)
          Forwards setAttribute to its contained figure.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Deprecated. use setAttribute(FigureAttributeConstant, Object) instead
 void setDecoratedFigure(Figure newDecoratedFigure)
           
 void write(StorableOutput dw)
          Writes itself and the contained figure to the StorableOutput.
 
Methods inherited from class org.jhotdraw.standard.AbstractFigure
addFigureChangeListener, addToContainer, center, changed, clone, displayBox, displayBox, getZValue, invalidate, invalidateRectangle, isEmpty, listener, removeFigureChangeListener, removeFromContainer, setZValue, size, visit, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecoratorFigure

public DecoratorFigure()

DecoratorFigure

public DecoratorFigure(Figure figure)
Constructs a DecoratorFigure and decorates the passed in figure.

Method Detail

initialize

protected void initialize()
Performs additional initialization code before the figure is decorated. Subclasses may override this method.


connectionInsets

public java.awt.Insets connectionInsets()
Forwards the connection insets to its contained figure..

Specified by:
connectionInsets in interface Figure
Overrides:
connectionInsets in class AbstractFigure

canConnect

public boolean canConnect()
Forwards the canConnect to its contained figure..

Specified by:
canConnect in interface Figure
Overrides:
canConnect in class AbstractFigure

containsPoint

public boolean containsPoint(int x,
                             int y)
Forwards containsPoint to its contained figure.

Specified by:
containsPoint in interface Figure
Overrides:
containsPoint in class AbstractFigure

decorate

public void decorate(Figure figure)
Decorates the given figure.


peelDecoration

public Figure peelDecoration()
Removes the decoration from the contained figure.


setDecoratedFigure

public void setDecoratedFigure(Figure newDecoratedFigure)

getDecoratedFigure

public Figure getDecoratedFigure()
Description copied from interface: Figure
Get the underlying figure in case the figure has been decorated. If the figure has not been decorated the figure itself is returned. The DecoratorFigure does not release the the decorated figure but just returns it (in contrast to org.jhotdraw.standard.DecoratorFigure.peelDecoration).

Specified by:
getDecoratedFigure in interface Figure
Overrides:
getDecoratedFigure in class AbstractFigure
Returns:
underlying, "real" without DecoratorFigure
See Also:
DecoratorFigure

displayBox

public java.awt.Rectangle displayBox()
Forwards displayBox to its contained figure.

Specified by:
displayBox in interface Figure
Specified by:
displayBox in class AbstractFigure
See Also:
Figure.basicDisplayBox(java.awt.Point, java.awt.Point)

basicDisplayBox

public void basicDisplayBox(java.awt.Point origin,
                            java.awt.Point corner)
Forwards basicDisplayBox to its contained figure.

Specified by:
basicDisplayBox in interface Figure
Specified by:
basicDisplayBox in class AbstractFigure
Parameters:
origin - the new origin
corner - the new corner
See Also:
AbstractFigure.displayBox(java.awt.Point, java.awt.Point)

draw

public void draw(java.awt.Graphics g)
Forwards draw to its contained figure.

Specified by:
draw in interface Figure
Parameters:
g - the Graphics to draw into

findFigureInside

public Figure findFigureInside(int x,
                               int y)
Forwards findFigureInside to its contained figure.

Specified by:
findFigureInside in interface Figure
Overrides:
findFigureInside in class AbstractFigure
See Also:
AbstractFigure.containsPoint(int, int)

handles

public HandleEnumeration handles()
Forwards handles to its contained figure.

Specified by:
handles in interface Figure
Specified by:
handles in class AbstractFigure
Returns:
a type-safe iterator of handles
See Also:
Handle

includes

public boolean includes(Figure figure)
Forwards includes to its contained figure.

Specified by:
includes in interface Figure
Overrides:
includes in class AbstractFigure

moveBy

public void moveBy(int x,
                   int y)
Forwards moveBy to its contained figure.

Specified by:
moveBy in interface Figure
Overrides:
moveBy in class AbstractFigure
Parameters:
x - the x delta
y - the y delta

basicMoveBy

protected void basicMoveBy(int x,
                           int y)
Forwards basicMoveBy to its contained figure.

Specified by:
basicMoveBy in class AbstractFigure
See Also:
AbstractFigure.moveBy(int, int)

release

public void release()
Releases itself and the contained figure.

Specified by:
release in interface Figure
Overrides:
release in class AbstractFigure
See Also:
Figure.release()

figureInvalidated

public void figureInvalidated(FigureChangeEvent e)
Propagates invalidate up the container chain.

Specified by:
figureInvalidated in interface FigureChangeListener
See Also:
FigureChangeListener

figureChanged

public void figureChanged(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure changed

Specified by:
figureChanged in interface FigureChangeListener

figureRemoved

public void figureRemoved(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure was removed

Specified by:
figureRemoved in interface FigureChangeListener

figureRequestUpdate

public void figureRequestUpdate(FigureChangeEvent e)
Propagates figureRequestUpdate up the container chain.

Specified by:
figureRequestUpdate in interface FigureChangeListener
See Also:
FigureChangeListener

figureRequestRemove

public void figureRequestRemove(FigureChangeEvent e)
Propagates the removeFromDrawing request up to the container.

Specified by:
figureRequestRemove in interface FigureChangeListener
See Also:
FigureChangeListener

figures

public FigureEnumeration figures()
Forwards figures to its contained figure.

Specified by:
figures in interface Figure
Overrides:
figures in class AbstractFigure
See Also:
CompositeFigure

decompose

public FigureEnumeration decompose()
Forwards decompose to its contained figure.

Specified by:
decompose in interface Figure
Overrides:
decompose in class AbstractFigure
Returns:
an Enumeration with itself as the only element.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Deprecated. use setAttribute(FigureAttributeConstant, Object) instead

Forwards setAttribute to its contained figure.

Specified by:
setAttribute in interface Figure
Overrides:
setAttribute in class AbstractFigure

setAttribute

public void setAttribute(FigureAttributeConstant attributeConstant,
                         java.lang.Object value)
Forwards setAttribute to its contained figure.

Specified by:
setAttribute in interface Figure
Overrides:
setAttribute in class AbstractFigure

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Deprecated. use getAttribute(FigureAttributeConstant) instead

Forwards getAttribute to its contained figure.

Specified by:
getAttribute in interface Figure
Overrides:
getAttribute in class AbstractFigure

getAttribute

public java.lang.Object getAttribute(FigureAttributeConstant attributeConstant)
Forwards getAttribute to its contained figure.

Specified by:
getAttribute in interface Figure
Overrides:
getAttribute in class AbstractFigure

connectedTextLocator

public Locator connectedTextLocator(Figure text)
Returns the locator used to located connected text.

Specified by:
connectedTextLocator in interface Figure
Overrides:
connectedTextLocator in class AbstractFigure

connectorAt

public Connector connectorAt(int x,
                             int y)
Returns the Connector for the given location.

Specified by:
connectorAt in interface Figure
Overrides:
connectorAt in class AbstractFigure
See Also:
ChopBoxConnector

connectorVisibility

public void connectorVisibility(boolean isVisible,
                                ConnectionFigure courtingConnection)
Forwards the connector visibility request to its component.

Specified by:
connectorVisibility in interface Figure
Overrides:
connectorVisibility in class AbstractFigure

write

public void write(StorableOutput dw)
Writes itself and the contained figure to the StorableOutput.

Specified by:
write in interface Storable
Overrides:
write in class AbstractFigure

read

public void read(StorableInput dr)
          throws java.io.IOException
Reads itself and the contained figure from the StorableInput.

Specified by:
read in interface Storable
Overrides:
read in class AbstractFigure
Throws:
java.io.IOException

getTextHolder

public TextHolder getTextHolder()
Description copied from interface: Figure
Some figures have the ability to hold text. This method returns the adjunctant TextHolder.

Specified by:
getTextHolder in interface Figure
Overrides:
getTextHolder in class AbstractFigure
Returns:

getDependendFigures

public FigureEnumeration getDependendFigures()
Description copied from interface: Figure
Get an enumeration of all dependent figures.

Specified by:
getDependendFigures in interface Figure
Overrides:
getDependendFigures in class AbstractFigure

addDependendFigure

public void addDependendFigure(Figure newDependendFigure)
Description copied from interface: Figure
Add a dependent figure.

Specified by:
addDependendFigure in interface Figure
Overrides:
addDependendFigure in class AbstractFigure

removeDependendFigure

public void removeDependendFigure(Figure oldDependendFigure)
Description copied from interface: Figure
Remove a dependent figure.

Specified by:
removeDependendFigure in interface Figure
Overrides:
removeDependendFigure in class AbstractFigure

JHotDraw 6.0b1