|
JHotDraw 7.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jhotdraw.draw.AttributeKey<T>
public class AttributeKey<T>
AttributeKey provides typesafe access to figure attributes.
An AttributeKey has a name, a type and a default value. The default value is returned by Figure.getAttribute, if a Figure does not have an attribute of the specified key.
The following code example shows how to basicSet and get an attribute on a Figure.
Figure aFigure; AttributeKeys.STROKE_COLOR.set(aFigure, Color.blue);
See AttributeKeys
for a list of useful attribute keys.
Constructor Summary | |
---|---|
AttributeKey(java.lang.String key)
Creates a new instance. |
|
AttributeKey(java.lang.String key,
T defaultValue)
|
|
AttributeKey(java.lang.String key,
T defaultValue,
boolean isNullValueAllowed)
|
Method Summary | |
---|---|
void |
basicSet(Figure f,
T value)
Sets a value on the specified figure without invoking willChange
and changed on the figure. |
void |
basicSetClone(Figure f,
T value)
Sets a clone of a value on the specified figure, without invoking willChange and changed on the figure. |
T |
get(Figure f)
Gets the value of the attribute denoted by this AttributeKey from a Figure. |
T |
get(java.util.Map<AttributeKey,java.lang.Object> a)
Gets the value of the attribute denoted by this AttributeKey from a Map. |
T |
getClone(Figure f)
Gets a clone of the value from the Figure. |
T |
getDefaultValue()
|
java.lang.String |
getKey()
|
boolean |
isAssignable(java.lang.Object value)
|
boolean |
isNullValueAllowed()
|
void |
set(Figure f,
T value)
Convenience method for setting a value on the specified figure and calling willChange before and changed after setting the value. |
void |
set(java.util.Map<AttributeKey,java.lang.Object> a,
T value)
|
void |
setClone(Figure f,
T value)
Convenience method for seting a clone of a value on the specified figure and calling willChange before and changed after setting the value. |
void |
setClone(java.util.Map<AttributeKey,java.lang.Object> a,
T value)
Sets a clone of the value to the Figure without firing events. |
javax.swing.undo.UndoableEdit |
setUndoable(Figure figure,
T value,
ResourceBundleUtil labels)
Sets the attribute and returns an UndoableEditEvent which can be used to undo it. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AttributeKey(java.lang.String key)
public AttributeKey(java.lang.String key, T defaultValue)
public AttributeKey(java.lang.String key, T defaultValue, boolean isNullValueAllowed)
Method Detail |
---|
public java.lang.String getKey()
public T getDefaultValue()
public T getClone(Figure f)
public T get(Figure f)
f
- A figure.
public T get(java.util.Map<AttributeKey,java.lang.Object> a)
a
- A Map.
public void set(Figure f, T value)
f
- the Figurevalue
- the attribute valuepublic void basicSet(Figure f, T value)
willChange
and changed
on the figure.
This method can be used to efficiently build a drawing from an
InputFormat
.
f
- the Figurevalue
- the attribute valuepublic javax.swing.undo.UndoableEdit setUndoable(Figure figure, T value, ResourceBundleUtil labels)
public void setClone(Figure f, T value)
f
- the Figurevalue
- the attribute valuepublic void basicSetClone(Figure f, T value)
willChange
and changed
on the figure.
This method can be used to efficiently build a drawing from an
InputFormat
.
f
- the Figurevalue
- the attribute valuepublic void set(java.util.Map<AttributeKey,java.lang.Object> a, T value)
public void setClone(java.util.Map<AttributeKey,java.lang.Object> a, T value)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isNullValueAllowed()
public boolean isAssignable(java.lang.Object value)
|
Copyright 1996-2007 (c) JHotDraw.org. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |