JHotDraw 7.0.6

org.jhotdraw.draw
Class AttributedFigure

java.lang.Object
  extended by org.jhotdraw.draw.AbstractFigure
      extended by org.jhotdraw.draw.AttributedFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Figure, DOMStorable
Direct Known Subclasses:
BezierFigure, DiamondFigure, EllipseFigure, RectangleFigure, RoundRectangleFigure, SVGImage, TextAreaFigure, TextFigure, TriangleFigure

public abstract class AttributedFigure
extends AbstractFigure

A figure that can keep track of an open ended set of attributes.

FIXME - Move all convenience attribute getter methods into AttributeKeys

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, decorator, listenerList
 
Constructor Summary
AttributedFigure()
          Creates a new instance.
 
Method Summary
protected  void applyAttributesTo(Figure that)
          Applies all attributes of this figure to that figure.
 void basicSetAttribute(AttributeKey key, java.lang.Object newValue)
          Sets an attribute of the figure.
 AttributedFigure clone()
          Returns a clone of the figure.
protected  void drawConnectors(java.awt.Graphics2D g)
           
 void drawFigure(java.awt.Graphics2D g)
           
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)
           
 java.lang.Object getAttribute(AttributeKey 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.awt.geom.Rectangle2D.Double getFigureDrawBounds()
           
 java.awt.Stroke getStroke()
           
 double getStrokeMiterLimitFactor()
           
 boolean hasAttribute(AttributeKey key)
           
 boolean isAttributeEnabled(AttributeKey key)
           
 void read(DOMInput in)
           
protected  void readAttributes(DOMInput in)
           
 void removeAttribute(AttributeKey key)
           
 void setAttribute(AttributeKey key, java.lang.Object newValue)
          Sets an attribute of the figure.
 void setAttributeEnabled(AttributeKey key, boolean b)
           
 void setAttributes(java.util.HashMap<AttributeKey,java.lang.Object> map)
           
 void write(DOMOutput out)
           
protected  void writeAttributes(DOMOutput out)
           
 
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addNotify, addUndoableEditListener, basicClone, basicTransform, canConnect, changed, createHandles, draw, drawDecorator, findCompatibleConnector, findConnector, findFigureInside, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getCourtingConnection, getCursor, getDecomposition, getDecorator, getDrawBounds, getDrawing, getEndPoint, getFontRenderContext, getLayer, getLock, getPreferredSize, getStartPoint, getTool, getTooltip, handleDrop, handleMouseClick, includes, invalidate, isChanging, isConnectorsVisible, isDrawDecoratorFirst, isInteractive, isVisible, remap, remap, removeFigureListener, removeNotify, removeUndoableEditListener, requestRemove, setBounds, setBounds, setConnectorsVisible, setDecorator, setDrawDecoratorFirst, setInteractive, setVisible, toString, transform, updateDecoratorBounds, validate, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.Figure
basicSetBounds, contains, getBounds, getRestoreData, restoreTo
 

Constructor Detail

AttributedFigure

public AttributedFigure()
Creates a new instance.

Method Detail

setAttribute

public void setAttribute(AttributeKey key,
                         java.lang.Object newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.


setAttributeEnabled

public void setAttributeEnabled(AttributeKey key,
                                boolean b)

isAttributeEnabled

public boolean isAttributeEnabled(AttributeKey key)

setAttributes

public void setAttributes(java.util.HashMap<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.


basicSetAttribute

public void basicSetAttribute(AttributeKey key,
                              java.lang.Object newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.

See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)

getAttribute

public java.lang.Object getAttribute(AttributeKey key)
Gets an attribute from the 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)

drawFigure

public void drawFigure(java.awt.Graphics2D g)
Specified by:
drawFigure in class AbstractFigure

drawConnectors

protected void drawConnectors(java.awt.Graphics2D g)

getStroke

public java.awt.Stroke getStroke()

getStrokeMiterLimitFactor

public double getStrokeMiterLimitFactor()

getFigureDrawBounds

public java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
Specified by:
getFigureDrawBounds in class AbstractFigure

drawFill

protected abstract void drawFill(java.awt.Graphics2D g)
This method is called by method draw() to draw the fill area of the figure. AttributedFigure 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 . AttributedFigure 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 AttributedFigure clone()
Description copied from interface: Figure
Returns a clone of the figure.

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
Throws:
java.io.IOException

read

public void read(DOMInput in)
          throws java.io.IOException
Throws:
java.io.IOException

removeAttribute

public void removeAttribute(AttributeKey key)

hasAttribute

public boolean hasAttribute(AttributeKey key)

Copyright 1996-2006 © JHotDraw.org