Package org.jgraph.graph
Class AttributeMap
java.lang.Object
java.util.Dictionary
java.util.Hashtable
org.jgraph.graph.AttributeMap
- All Implemented Interfaces:
Serializable
,Cloneable
,Map
A map specifically for the storage of attributes of graph cells. The main
advantage of the AttributeMap is that it allows to override cell view
behaviour for scaling, translation, diffing, and cloning on a per instance
basis without having to change the GraphConstants class
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic AttributeMap
Shared empty attribute map to return instead of null in applyMap. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new attribute map with an initial capacity of 8.AttributeMap
(int initialCapacity) Creates a new attribute map with the specified initial capacityAttributeMap
(int initialCapacity, float loadCapacity) Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.AttributeMap
(Map map) Constructs a new AttributeMap with the same mappings as the given Map. -
Method Summary
Modifier and TypeMethodDescriptionApply thechange
to this views attributes.applyValue
(Object key, Object value) Apply thekey
tovalue
clone()
Returns a clone ofmap
, from keys to values.cloneEntries
(AttributeMap newMap) Clones special object entried in the given map.Point2D[]
clonePoints
(Point2D[] points) Returns a list where all instances of PortView are replaced by their correspnding Point instance.clonePoints
(Object[] points, boolean convertPortViews) Returns a list where all instances of PortView are replaced by their correspnding Point instance.clonePoints
(List points) Returns a list where all instances of PortView are replaced by their correspnding Point instance.Creates a point of suitable type for this attribute mapcreatePoint
(double x, double y) Creates a point of suitable type for this attribute map with the same values as those passed inCreates a point of suitable type for this attribute map with the same values as the point passed inCreates a rectangle of suitable type for this attribute mapcreateRect
(double x, double y, double w, double h) Creates a rectangle of suitable type for this attribute map with the same values as those passed increateRect
(double x, double y, double w, double h, double grow1, double grow2) Creates a rectangle of suitable type for this attribute mapcreateRect
(Point2D pt) Creates a rectangle of suitable type for this attribute map at the position of the point passed increateRect
(Point2D pt, double size) Creates a rectangle of suitable type for this attribute map at the position of the point passed in with lengthssize
createRect
(Rectangle2D rect) Clones the rectangle passed increateRect
(Rectangle2D rect, double grow1, double grow2) Creates a clone of the rectangle passed in and manipulates it bygrow1
andgrow2
Returns a new map that contains all (key, value)-pairs ofnewState
where either key is not used or value is different for key inoldState
.void
Scalesmap
by the given amount.void
translate
(double dx, double dy) Translatesmap
by the given amount.static void
translate
(Collection c, double dx, double dy) Translates the maps inc
usingtranslate(Map, int, int)
.Methods inherited from class java.util.Hashtable
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
-
Field Details
-
emptyAttributeMap
Shared empty attribute map to return instead of null in applyMap.
-
-
Constructor Details
-
AttributeMap
public AttributeMap()Creates a new attribute map with an initial capacity of 8. -
AttributeMap
public AttributeMap(int initialCapacity) Creates a new attribute map with the specified initial capacity- Parameters:
initialCapacity
- the initial capacity of the new map
-
AttributeMap
public AttributeMap(int initialCapacity, float loadCapacity) Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.- Parameters:
initialCapacity
- the initial capacity of the hashtable.loadCapacity
- the load factor of the hashtable.
-
AttributeMap
Constructs a new AttributeMap with the same mappings as the given Map.- Parameters:
map
- the input map to copy
-
-
Method Details
-
createPoint
Creates a point of suitable type for this attribute map- Returns:
- a new point
-
createPoint
Creates a point of suitable type for this attribute map with the same values as the point passed in- Parameters:
p
- the point whose values the new point are to be based on- Returns:
- a new copy of the point passed in
-
createPoint
Creates a point of suitable type for this attribute map with the same values as those passed in- Parameters:
x
- the x-coordinate position of the new pointy
- the y-coordinate position of the new point- Returns:
- a new point at the coordinates passed in
-
createRect
Creates a rectangle of suitable type for this attribute map- Returns:
- a new rectangle
-
createRect
Creates a rectangle of suitable type for this attribute map with the same values as those passed in- Parameters:
x
- the x-coordinate position of the new rectangley
- the y-coordinate position of the new rectanglew
- the width of the new rectangleh
- the height of the new rectangle- Returns:
- a new rectangle at the coordinates and of the dimensions passed in
-
createRect
Creates a rectangle of suitable type for this attribute map at the position of the point passed in- Parameters:
pt
- the position of the new rectangle- Returns:
- a new rectangle the specified coordinates of zero size
-
createRect
Creates a rectangle of suitable type for this attribute map at the position of the point passed in with lengthssize
- Parameters:
pt
- the position of the new rectanglesize
- the length of both sides of the rectangle- Returns:
- a new rectangle the specified position and dimensions
-
createRect
Clones the rectangle passed in- Parameters:
rect
- the rectangle to clone- Returns:
- a copy of the rectangle passed in
-
createRect
Creates a rectangle of suitable type for this attribute map- Parameters:
x
- the x-coordinate position of the new rectangley
- the y-coordinate position of the new rectanglew
- the width of the new rectangleh
- the height of the new rectanglegrow1
- the amount both dimensions are to be increased by and the position coorindates of the rectangle are to be decreased bygrow2
- the additional amount by which both dimensions are to be increased by- Returns:
- a new rectangle at the coordinates and of the dimensions passed in
-
createRect
Creates a clone of the rectangle passed in and manipulates it bygrow1
andgrow2
- Parameters:
grow1
- the amount both dimensions are to be increased by and the position coorindates of the rectangle are to be decreased bygrow2
- the additional amount by which both dimensions are to be increased by- Returns:
- a new rectangle at the coordinates and of the dimensions passed in
-
applyMap
Apply thechange
to this views attributes.change
must be aMap
previously obtained from this object.- Parameters:
change
- the change to apply- Returns:
- a map that may be used to undo the change to target.
-
applyValue
Apply thekey
tovalue
- Parameters:
key
- the map key whose value is to be alteredvalue
- the new value to be applied to the specified key- Returns:
- the old value.
-
clonePoints
Returns a list where all instances of PortView are replaced by their correspnding Point instance.- Parameters:
points
- the points to be cloned- Returns:
- the cloned points
-
clonePoints
Returns a list where all instances of PortView are replaced by their correspnding Point instance.- Parameters:
points
- the points to be cloned- Returns:
- the cloned points
-
clonePoints
Returns a list where all instances of PortView are replaced by their correspnding Point instance. -
translate
Translates the maps inc
usingtranslate(Map, int, int)
. -
translate
public void translate(double dx, double dy) Translatesmap
by the given amount. -
scale
Scalesmap
by the given amount. -
diff
Returns a new map that contains all (key, value)-pairs ofnewState
where either key is not used or value is different for key inoldState
. In other words, this method removes the common entries from oldState and newState, and returns the "difference" between the two. This method never returns null. -
clone
Returns a clone ofmap
, from keys to values. If the map contains bounds or points, these are cloned as well. References toPortViews
are replaces by points.
Note: Extend this method to clone custom user objects. -
cloneEntries
Clones special object entried in the given map.
-