JHotDraw 6.0b1

org.jhotdraw.figures
Class AttributeFigure

java.lang.Object
  extended by org.jhotdraw.standard.AbstractFigure
      extended by org.jhotdraw.figures.AttributeFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Figure, Storable
Direct Known Subclasses:
ComponentFigure, EllipseFigure, ImageFigure, PolygonFigure, RectangleFigure, RoundRectangleFigure, TextAreaFigure, TextFigure

public abstract class AttributeFigure
extends AbstractFigure

A figure that can keep track of an open ended set of attributes. The attributes are stored in a dictionary implemented by FigureAttributes.

See Also:
Figure, Handle, FigureAttributes, Serialized Form

Constructor Summary
protected AttributeFigure()
           
 
Method Summary
 void draw(java.awt.Graphics g)
          Draws the figure in the given graphics.
protected  void drawBackground(java.awt.Graphics g)
          Draws the background of the figure.
protected  void drawFrame(java.awt.Graphics g)
          Draws the frame of the figure.
 java.lang.Object getAttribute(FigureAttributeConstant attributeConstant)
          Returns the named attribute or null if a a figure doesn't have an attribute.
 java.lang.Object getAttribute(java.lang.String name)
          Deprecated. use getAttribute(FigureAttributeConstant) instead
static java.lang.Object getDefaultAttribute(FigureAttributeConstant attributeConstant)
           
static java.lang.Object getDefaultAttribute(java.lang.String name)
          Gets a the default value for a named attribute
 java.awt.Color getFillColor()
          Gets the fill color of a figure.
 java.awt.Color getFrameColor()
          Gets the frame color of a figure.
static java.lang.Object initDefaultAttribute(java.lang.String name, java.lang.Object value)
          Initializes a default value for a named attribute The difference between this method and setDefaultAttribute is that if the attribute is already set then it will not be changed.
The purpose is to allow more than one source requiring the attribute to initialize it, but only the first initialization will be used.
 void read(StorableInput dr)
          Reads the Figure from a StorableInput.
 void setAttribute(FigureAttributeConstant attributeConstant, java.lang.Object value)
          Sets the named attribute to the new value.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Deprecated. use setAttribute(FigureAttributeConstant, Object) instead
static java.lang.Object setDefaultAttribute(java.lang.String name, java.lang.Object value)
          Sets or adds a default value for a named attribute
 void write(StorableOutput dw)
          Stores the Figure to a StorableOutput.
 
Methods inherited from class org.jhotdraw.standard.AbstractFigure
addDependendFigure, addFigureChangeListener, addToContainer, basicDisplayBox, basicMoveBy, canConnect, center, changed, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, figures, findFigureInside, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, handles, includes, invalidate, invalidateRectangle, isEmpty, listener, moveBy, release, removeDependendFigure, 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

AttributeFigure

protected AttributeFigure()
Method Detail

draw

public void draw(java.awt.Graphics g)
Draws the figure in the given graphics. Draw is a template method calling drawBackground followed by drawFrame.

Parameters:
g - the Graphics to draw into

drawBackground

protected void drawBackground(java.awt.Graphics g)
Draws the background of the figure.

See Also:
draw(java.awt.Graphics)

drawFrame

protected void drawFrame(java.awt.Graphics g)
Draws the frame of the figure.

See Also:
draw(java.awt.Graphics)

getFillColor

public java.awt.Color getFillColor()
Gets the fill color of a figure. This is a convenience method.

See Also:
getAttribute(java.lang.String)

getFrameColor

public java.awt.Color getFrameColor()
Gets the frame color of a figure. This is a convenience method.

See Also:
getAttribute(java.lang.String)

setDefaultAttribute

public static java.lang.Object setDefaultAttribute(java.lang.String name,
                                                   java.lang.Object value)
Sets or adds a default value for a named attribute

See Also:
getAttribute(java.lang.String)

initDefaultAttribute

public static java.lang.Object initDefaultAttribute(java.lang.String name,
                                                    java.lang.Object value)
Initializes a default value for a named attribute The difference between this method and setDefaultAttribute is that if the attribute is already set then it will not be changed.
The purpose is to allow more than one source requiring the attribute to initialize it, but only the first initialization will be used.

See Also:
getAttribute(java.lang.String), setDefaultAttribute(java.lang.String, java.lang.Object)

getDefaultAttribute

public static java.lang.Object getDefaultAttribute(java.lang.String name)
Gets a the default value for a named attribute

See Also:
getAttribute(java.lang.String)

getDefaultAttribute

public static java.lang.Object getDefaultAttribute(FigureAttributeConstant attributeConstant)

getAttribute

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

Returns the named attribute or null if a a figure doesn't have an attribute. All figures support the attribute names FillColor and FrameColor

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

getAttribute

public java.lang.Object getAttribute(FigureAttributeConstant attributeConstant)
Description copied from class: AbstractFigure
Returns the named attribute or null if a a figure doesn't have an attribute. By default figures don't have any attributes getAttribute returns null.

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

setAttribute

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

Sets the named attribute to the new value

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

setAttribute

public void setAttribute(FigureAttributeConstant attributeConstant,
                         java.lang.Object value)
Description copied from class: AbstractFigure
Sets the named attribute to the new value. By default figures don't have any attributes and the request is ignored.

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

write

public void write(StorableOutput dw)
Stores the Figure to a StorableOutput.

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

read

public void read(StorableInput dr)
          throws java.io.IOException
Reads the Figure from a StorableInput.

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

JHotDraw 6.0b1