suvi.api.alg.attr
Class GraphLayoutAttrMap

java.lang.Object
  |
  +--javautils.maps.AbstractTypedMap
        |
        +--suvi.api.alg.attr.GraphLayoutAttrMap
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class GraphLayoutAttrMap
extends javautils.maps.AbstractTypedMap

Map from an attribute class to the attribute object.

Design rationale

Different graph layout algorithms need different layout attributes. It is not reasonable to design an attribute interface that would contain all possible attributes, because the set of all attributes is not closed. It is still desirable to be able to specify the interface for graph layout algorithms just once, because it makes it easier to parameterize clients by different graph layout algorithms. In order to pass the attributes to the algorithm, we would like to be able to compose the set of attributes dynamically.

A simple design pattern that fits this situation is the Extension Object-pattern described in [PLOP3]. Actually, in this case, we can do with a slightly simpler design. We simply represent the set of attributes as a map from an attribute class to the attribute object. The map can then be created to contain any set of individual attribute objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javautils.maps.AbstractTypedMap
map
 
Constructor Summary
GraphLayoutAttrMap()
          Default constructor for convenience.
GraphLayoutAttrMap(GraphLayoutAttr attr)
          A new attribute map that contains the specified attributes.
GraphLayoutAttrMap(GraphLayoutAttr[] attrs)
          A new attribute map that contains the specified attributes.
GraphLayoutAttrMap(java.util.Map clsToAttrMap)
          A new graph layout attribute map using the given map directly.
 
Method Summary
 java.lang.Class[] classes()
          The classes of all attribute objects stored in this map.
 GraphLayoutAttr get(java.lang.Class cls)
          The attribute object that implements the specified attribute interface or null.
protected  boolean valuePredicate(java.lang.Object value)
          True iff the value is a non null GraphLayoutAttr-object.
 
Methods inherited from class javautils.maps.AbstractTypedMap
clear, clone, containsKey, isEmpty, keyIterator, keySet, remove, size, toString, unmodifiableMap, valueIterator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphLayoutAttrMap

public GraphLayoutAttrMap()

Default constructor for convenience.


GraphLayoutAttrMap

public GraphLayoutAttrMap(GraphLayoutAttr attr)

A new attribute map that contains the specified attributes.


GraphLayoutAttrMap

public GraphLayoutAttrMap(GraphLayoutAttr[] attrs)

A new attribute map that contains the specified attributes.


GraphLayoutAttrMap

public GraphLayoutAttrMap(java.util.Map clsToAttrMap)

A new graph layout attribute map using the given map directly.

Method Detail

valuePredicate

protected boolean valuePredicate(java.lang.Object value)

True iff the value is a non null GraphLayoutAttr-object.

Specified by:
valuePredicate in class javautils.maps.AbstractTypedMap

classes

public java.lang.Class[] classes()

The classes of all attribute objects stored in this map.


get

public GraphLayoutAttr get(java.lang.Class cls)

The attribute object that implements the specified attribute interface or null.