JHotDraw 7.5.1

org.jhotdraw.draw
Class AbstractAttributedFigure

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.AbstractFigure
          extended by org.jhotdraw.draw.AbstractAttributedFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Figure, DOMStorable
Direct Known Subclasses:
AbstractAttributedDecoratedFigure, BezierFigure, DiamondFigure, EllipseFigure, ODGAttributedFigure, RectangleFigure, RoundRectangleFigure, StraightLineFigure, SVGAttributedFigure, TriangleFigure

public abstract class AbstractAttributedFigure
extends AbstractFigure
implements DOMStorable

This abstract class can be extended to implement a Figure which has its own attribute set.

Version:
$Id: AbstractAttributedFigure.java 626 2010-01-20 08:56:21Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Fields inherited from interface org.jhotdraw.draw.Figure
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
 
Constructor Summary
AbstractAttributedFigure()
          Creates a new instance.
 
Method Summary
protected  void applyAttributesTo(Figure that)
          Applies all attributes of this figure to that figure.
 AbstractAttributedFigure clone()
          Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.
 void draw(java.awt.Graphics2D g)
          Draws the figure.
protected abstract  void drawFill(java.awt.Graphics2D g)
          This method is called by method draw() to draw the fill area of the figure.
protected abstract  void drawStroke(java.awt.Graphics2D g)
          This method is called by method draw() to draw the text of the figure .
protected  void drawText(java.awt.Graphics2D g)
           
<T> T
get(AttributeKey<T> key)
          Gets an attribute from the figure.
protected  AttributeKey getAttributeKey(java.lang.String name)
           
 java.util.Map<AttributeKey,java.lang.Object> getAttributes()
          Returns a view to all attributes of this figure.
 java.lang.Object getAttributesRestoreData()
          Gets data which can be used to restore the attributes of the figure after a set has been applied to it.
 java.awt.geom.Rectangle2D.Double getDrawingArea()
          Returns the drawing area of the figure as a Rectangle.
 java.awt.Stroke getStroke()
           
 double getStrokeMiterLimitFactor()
           
 boolean hasAttribute(AttributeKey key)
           
 boolean isAttributeEnabled(AttributeKey key)
           
 void read(DOMInput in)
           
protected  void readAttributes(DOMInput in)
           
<T> void
removeAttribute(AttributeKey<T> key)
           
 void restoreAttributesTo(java.lang.Object restoreData)
          Restores the attributes of the figure to a previously stored state.
<T> void
set(AttributeKey<T> key, T newValue)
          Sets an attribute of the figure.
 void setAttributeEnabled(AttributeKey key, boolean b)
           
 void setAttributes(java.util.Map<AttributeKey,java.lang.Object> map)
           
 void write(DOMOutput out)
           
protected  void writeAttributes(DOMOutput out)
           
 
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addNotify, basicClone, changed, createHandles, findCompatibleConnector, findConnector, findFigureInside, fireAreaInvalidated, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureHandlesChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getConnectors, getCursor, getDecomposition, getDrawing, getEndPoint, getFontRenderContext, getLayer, getLock, getPreferredSize, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, invalidate, isChanging, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removeNotify, requestRemove, setBounds, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toString, validate, willChange
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.Figure
addPropertyChangeListener, contains, getBounds, getTransformRestoreData, removePropertyChangeListener, restoreTransformTo, transform
 

Constructor Detail

AbstractAttributedFigure

public AbstractAttributedFigure()
Creates a new instance.

Method Detail

setAttributeEnabled

public void setAttributeEnabled(AttributeKey key,
                                boolean b)

isAttributeEnabled

public boolean isAttributeEnabled(AttributeKey key)

setAttributes

public void setAttributes(java.util.Map<AttributeKey,java.lang.Object> map)

getAttributes

public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
Description copied from interface: Figure
Returns a view to all attributes of this figure. By convention, an unmodifiable map is returned.

Specified by:
getAttributes in interface Figure

getAttributesRestoreData

public java.lang.Object getAttributesRestoreData()
Description copied from interface: Figure
Gets data which can be used to restore the attributes of the figure after a set has been applied to it.

Specified by:
getAttributesRestoreData in interface Figure

restoreAttributesTo

public void restoreAttributesTo(java.lang.Object restoreData)
Description copied from interface: Figure
Restores the attributes of the figure to a previously stored state.

Specified by:
restoreAttributesTo in interface Figure

set

public <T> void set(AttributeKey<T> key,
                    T newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.

Specified by:
set in interface Figure
See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)

get

public <T> T get(AttributeKey<T> key)
Gets an attribute from the figure.

Specified by:
get in interface Figure
Returns:
Returns the attribute value. If the Figure does not have an attribute with the specified key, returns key.getDefaultValue().
See Also:
AttributeKey.get(org.jhotdraw.draw.Figure)

draw

public void draw(java.awt.Graphics2D g)
Description copied from interface: Figure
Draws the figure.

Specified by:
draw in interface Figure
Parameters:
g - The Graphics2D to draw to.

getStroke

public java.awt.Stroke getStroke()

getStrokeMiterLimitFactor

public double getStrokeMiterLimitFactor()

getDrawingArea

public java.awt.geom.Rectangle2D.Double getDrawingArea()
Description copied from interface: Figure
Returns the drawing area of the figure as a Rectangle.

The drawing area is used to inform DrawingView about the area that is needed to draw this figure.

The drawing area needs to be large enough, to take line width, line caps and other decorations into account that exceed the bounds of the Figure.

Specified by:
getDrawingArea in interface Figure

drawFill

protected abstract void drawFill(java.awt.Graphics2D g)
This method is called by method draw() to draw the fill area of the figure. AbstractAttributedFigure configures the Graphics2D object with the FILL_COLOR attribute before calling this method. If the FILL_COLOR attribute is null, this method is not called.


drawStroke

protected abstract void drawStroke(java.awt.Graphics2D g)
This method is called by method draw() to draw the text of the figure . AbstractAttributedFigure configures the Graphics2D object with the TEXT_COLOR attribute before calling this method. If the TEXT_COLOR attribute is null, this method is not called.


drawText

protected void drawText(java.awt.Graphics2D g)

clone

public AbstractAttributedFigure clone()
Description copied from interface: Figure
Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators. The cloned figure does not clone the list of FigureListeners from its original.

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

writeAttributes

protected void writeAttributes(DOMOutput out)
                        throws java.io.IOException
Throws:
java.io.IOException

readAttributes

protected void readAttributes(DOMInput in)
                       throws java.io.IOException
Throws:
java.io.IOException

getAttributeKey

protected AttributeKey getAttributeKey(java.lang.String name)

applyAttributesTo

protected void applyAttributesTo(Figure that)
Applies all attributes of this figure to that figure.


write

public void write(DOMOutput out)
           throws java.io.IOException
Specified by:
write in interface DOMStorable
Throws:
java.io.IOException

read

public void read(DOMInput in)
          throws java.io.IOException
Specified by:
read in interface DOMStorable
Throws:
java.io.IOException

removeAttribute

public <T> void removeAttribute(AttributeKey<T> key)

hasAttribute

public boolean hasAttribute(AttributeKey key)

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.