- All Superinterfaces:
Lockable
- All Known Implementing Classes:
AttributeOverwritingFilter
,GraphBase
,GraphFilter
,GraphManager
,HighlightFilter
,TopologyGraph
A
Graph
represents a graph-like structure. It consists of
nodes, connected by directed edges. Both nodes and edges are objects,
their classes are not restricted by this interface.
Topological Structure
The nodes and edges of a graph are obtained in the following way:- The method
getRootKeys()
returns an array of strings, the root keys. These are used as arguments togetRoot(String)
. The returned value is a node, namely the root of the subgraph identified by the root key. The root keyMAIN_GRAPH
is a predefined root key, it identifies the root of the main graph which should always be present. Further root keys may be defined, depending on theGraph
. - For every node n, there is a linked list of edges with
unspecified order. The first edge of this linked list is obtained by
getFirstEdge(Object)
with n passed as argument, the next edges are obtained bygetNextEdge(Object, Object)
with the previous edge as first argument and n as second. Thus, a loop over all edges of n in a graph g can be implemented as follows:for (Object e = g.getFirstEdge(n); e != null; e = g.getNextEdge(e, n)) { // do something with the current edge e }
- Given an edge e, its source and target nodes are obtained by
the method
getSourceNode(Object)
andgetTargetNode(Object)
.
Attributes
Besides topological information, aGraph
provides
attribute-like information for nodes and edges:
- Every node has a unique id which is obtained by
getId(Object)
. The inverse methodgetNodeForId(long)
returns the node identified by the given id. - Every node and every edge has a name which is obtained by
getName(Object, boolean)
. The name is not necessarily unique, the inverse methodgetObjectForName(boolean, String)
returns one of the nodes or edges with the given name. - Every edge has a set of edge bits
(
getEdgeBits(Object)
). These are stored in a singleint
-value which is interpreted as a set of sub-edges in the following way:- The bits 0 to 7 (masked by
SPECIAL_EDGE_MASK
) represent the edge's special sub-edge. If these bits, interpreted as a byte, have the value 0, no special sub-edge is present. Otherwise, the special sub-edge identified by this byte is present in this edge. The value 255 (all bits set) is reserved for special purposes. Note that at most one special edge may exist at a time between an ordered tuple of nodes. - The other 24 bits (bits 8 to 31) represent 24 possible
sub-edges, each indicated by the presence of its specific bit in the
int
-value. It is up to the concrete graph to specify the meaning of the sub-edges. TheGraph
interface provides three standard meanings:SUCCESSOR_EDGE
,BRANCH_EDGE
, andCONTAINMENT_EDGE
.
- The bits 0 to 7 (masked by
- Every node and every edge has a set of attributes which is returned by
getAttributes(Object, boolean)
. Each attribute is represented by an instance ofAttribute
, attribute values are read and written on nodes and edges within the context of aGraphState
.
Threading Issues
In order to ensure a stable and predictable behaviour in the context of multiple threads, the following rules have to be followed:- Modifications to a graph may only be performed within the context
of the main graph state (see
getMainState()
), and only when a write lock has been obtained by (seeLockable
which is extended by this interface). - In principle, reading of structure and attributes can be done
without any special arrangement. However, it is safer to do this
when a read lock has been obtained
(again see
Lockable
). because then it is guaranteed that no other thread may modify the graph during the invocation (if the other threads conform to these rules). - The methods for adding and removing of event listeners in this interface have to be implemented thread-safe.
- The implementation of this interface has to ensure that its event listeners are notified about modifications only within the context of the main graph state.
The Tree of a Graph
A graph defines a tree pattern (seegetTreePattern()
).
Starting at the root of the main graph
(getRoot(String)
, MAIN_GRAPH
), this pattern is used
as a filter to construct a subgraph out of the whole graph. The subgraph
has to be a tree, but it is not necessarily a spanning tree for the whole
graph. The parent attribute (see getParentAttribute()
)
of the graph has to be a derived attribute which has as value for every node
of the tree its parent edge and for every edge of the tree its parent
node. For objects which are not part of the tree the value is
null
.- Author:
- Ole Kniemeyer
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.grogra.util.Lockable
Lockable.DeadLockException
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The bit mask indicating the presence of a branch edge in edge bits.static final int
The bit mask indicating the presence of a containment edge in edge bits.static final int
The bit mask indicating the presence in edge bits of an edge signalling "end of containment".static final int
static final int
static final int
static final int
The bit mask indication the presence of an ignored edge bits.static final int
The bit mask indication the presence of an instantiation edge bits.static final String
The predefined root key which identifies the main graph.static final int
The bit mask indicating the presence of a mark edge in edge bits.static final int
static final int
static final int
static final int
static final int
Return value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object is persistent, i.e., it belongs the graph.static final int
Return value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object has been persistent and is currently being deleted from the graph.static final int
static final int
static final int
static final int
static final int
The bit mask for the special edge in edge bits.static final int
static final int
static final int
static final int
The bit mask indicating the presence of a successor edge in edge bits.static final int
Return value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object is transient, i.e., it does not belong to the graph. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
addAttributeChangeListener
(Object object, boolean asNode, AttributeChangeListener l) void
void
void
addEdgeChangeListener
(Object object, boolean asNode, EdgeChangeListener l) <V> ObjectMap<V>
getAccessor
(Object object, boolean asNode, Attribute attribute) Returns an attribute accessor for the given attribute on the given object.getAttributes
(Object object, boolean asNode) Returns the set of attributes which are available for the given object.int
getDependent
(Object object, boolean asNode, Attribute a) Returns the set of attributes whose values depend on the given attributea
for the givenobject
.getDescription
(Object object, boolean asNode, String type) Returns a description for the given object.int
getEdgeBits
(Object edge) Returns the edge bits of an edge.getFirstEdge
(Object node) Returns the first edge of the linked list of edges ofnode
.long
Returns a unique identifier for the givennode
.getInstantiator
(Object node) int
getLifeCycleState
(Object object, boolean asNode) Returns the life cycle state of the given object as part of this graph.Returns the main graph state.Returns a name for the given object.getNextEdge
(Object edge, Object node) Returns the edge afteredge
in the linked list of edges ofnode
.getNodeForId
(long id) Returns the node identified byid
.getObjectForName
(boolean node, String name) Returns the object with the given name.Defines the derived attribute which has as value the parent object.Returns the root node for the given root key.String[]
Returns the root keys for the graph.getSourceNode
(Object edge) Returns the source node ofedge
.getSpecialEdgeDescriptors
(Object node, boolean asSource) int
getStamp()
Returns a modification stamp for the whole graph.int
getTargetNode
(Object edge) Returns the target node ofedge
.Defines the pattern used for the construction of this graph's tree.void
void
removeAttributeChangeListener
(Object object, boolean asNode, AttributeChangeListener l) void
void
void
removeEdgeChangeListener
(Object object, boolean asNode, EdgeChangeListener l) Methods inherited from interface de.grogra.util.Lockable
execute, execute, executeForcedly, executeForcedly, getMaxWaitingTime, getQueueLength, isLocked
-
Field Details
-
SPECIAL_EDGE_OF_SOURCE_BIT
static final int SPECIAL_EDGE_OF_SOURCE_BIT- See Also:
-
SPECIAL_EDGE_MASK
static final int SPECIAL_EDGE_MASKThe bit mask for the special edge in edge bits.- See Also:
-
EDGENODE_IN_EDGE
static final int EDGENODE_IN_EDGE- See Also:
-
EDGENODE_OUT_EDGE
static final int EDGENODE_OUT_EDGE- See Also:
-
MIN_NORMAL_BIT_INDEX
static final int MIN_NORMAL_BIT_INDEX- See Also:
-
SUCCESSOR_EDGE
static final int SUCCESSOR_EDGEThe bit mask indicating the presence of a successor edge in edge bits. This means that the target node of the edge is the successor (in some graph-dependent sense) of the source node of the edge.- See Also:
-
BRANCH_EDGE
static final int BRANCH_EDGEThe bit mask indicating the presence of a branch edge in edge bits. This means that the target node of the edge is the first node of a branch (in some graph-dependent sense) originating at the source node of the edge.- See Also:
-
CONTAINMENT_EDGE
static final int CONTAINMENT_EDGEThe bit mask indicating the presence of a containment edge in edge bits. This means that the target node of the edge is contained (in some graph-dependent sense) in the source node of the edge.- See Also:
-
CONTAINMENT_END_EDGE
static final int CONTAINMENT_END_EDGEThe bit mask indicating the presence in edge bits of an edge signalling "end of containment".- See Also:
-
REFINEMENT_EDGE
static final int REFINEMENT_EDGE- See Also:
-
MARK_EDGE
static final int MARK_EDGEThe bit mask indicating the presence of a mark edge in edge bits. The precise meaning of a mark edge is not specified by this interface, it may be used for multiple purposes.- See Also:
-
NOTIFIES_EDGE
static final int NOTIFIES_EDGE- See Also:
-
STD_EDGE_5
static final int STD_EDGE_5- See Also:
-
STD_EDGE_6
static final int STD_EDGE_6- See Also:
-
INSTANTIATION_EDGE
static final int INSTANTIATION_EDGEThe bit mask indication the presence of an instantiation edge bits. It is used when importing a graph into the scene.- See Also:
-
IGNORED_EDGE
static final int IGNORED_EDGEThe bit mask indication the presence of an ignored edge bits. It is used when a part of the graph should be ignored.- See Also:
-
MIN_UNUSED_EDGE
static final int MIN_UNUSED_EDGE- See Also:
-
MIN_UNUSED_EDGE_BIT
static final int MIN_UNUSED_EDGE_BIT- See Also:
-
RECTANGLE_SYMBOL
static final int RECTANGLE_SYMBOL- See Also:
-
ROUND_RECTANGLE_SYMBOL
static final int ROUND_RECTANGLE_SYMBOL- See Also:
-
ELLIPSE_SYMBOL
static final int ELLIPSE_SYMBOL- See Also:
-
RHOMBUS_SYMBOL
static final int RHOMBUS_SYMBOL- See Also:
-
PERSISTENT
static final int PERSISTENTReturn value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object is persistent, i.e., it belongs the graph.- See Also:
-
PERSISTENT_DELETED
static final int PERSISTENT_DELETEDReturn value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object has been persistent and is currently being deleted from the graph.- See Also:
-
TRANSIENT
static final int TRANSIENTReturn value forgetLifeCycleState(java.lang.Object, boolean)
indicating that the object is transient, i.e., it does not belong to the graph.- See Also:
-
MAIN_GRAPH
The predefined root key which identifies the main graph.- See Also:
-
-
Method Details
-
getMainState
GraphState getMainState()Returns the main graph state. The main graph state is the only graph state within which modifications to the graph may be done. The notification of event listeners is done in the context of this state, too.- Returns:
- this graph's main graph state
- See Also:
-
getStamp
int getStamp()Returns a modification stamp for the whole graph. Each modification increments the value, so that the test whether some modification occured can be simply performed on values of the stamp.- Returns:
- a stamp for the whole graph
-
getRootKeys
String[] getRootKeys()Returns the root keys for the graph.- Returns:
- an array of root keys
- See Also:
-
getRoot
Returns the root node for the given root key.- Parameters:
key
- a root key, one ofgetRootKeys()
- Returns:
- the root node of the graph identified by
key
, ornull
if no such root node exists - See Also:
-
getFirstEdge
Returns the first edge of the linked list of edges ofnode
.- Parameters:
node
- the common node of the edges of the linked list- Returns:
- the first edge of the linked list
- See Also:
-
getNextEdge
Returns the edge afteredge
in the linked list of edges ofnode
.- Parameters:
edge
- the previous edge in the linked listnode
- the common node of the edges of the linked list- Returns:
- the next edge of the linked list
- See Also:
-
getSourceNode
Returns the source node ofedge
.- Parameters:
edge
- an edge- Returns:
- the source node
- See Also:
-
getTargetNode
Returns the target node ofedge
.- Parameters:
edge
- an edge- Returns:
- the target node
- See Also:
-
getLifeCycleState
Returns the life cycle state of the given object as part of this graph.- Parameters:
object
- the object to testasNode
-true
ifobject
is a node,false
ifobject
is an edge- Returns:
- life cycle state, one of
PERSISTENT
,PERSISTENT_DELETED
,TRANSIENT
-
getId
Returns a unique identifier for the givennode
.- Parameters:
node
- a node- Returns:
- the node's unique identifier
- See Also:
-
getNodeForId
Returns the node identified byid
.- Parameters:
id
- an identifier- Returns:
- the corresponding node, or
null
ifid
identifies no node - See Also:
-
getName
Returns a name for the given object. Names are not necessarily unique.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edge- Returns:
- a name
- See Also:
-
getObjectForName
Returns the object with the given name. If several such objects exist, one of them is chosen in an unspecified manner. If no such object exists,null
is returned.- Parameters:
node
-true
if a node of the given name is to be found,false
if an edge is to be foundname
- the name of the object- Returns:
- an object of the given kind (node or edge) with the given name,
or
null
if no such object exists - See Also:
-
getEdgeBits
Returns the edge bits of an edge.- Parameters:
edge
- the edge- Returns:
- the edge's edge bits
- See Also:
-
getAttributes
Returns the set of attributes which are available for the given object.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edge- Returns:
- the object's attributes
-
getDependent
Returns the set of attributes whose values depend on the given attributea
for the givenobject
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute- Returns:
- the set of dependent attributes
-
getAccessor
Returns an attribute accessor for the given attribute on the given object.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgeattribute
- the attribute- Returns:
- an accessor for the object's attribute value
-
getInstantiator
-
accept
-
getStateMap
Map getStateMap() -
createBooleanMap
BooleanMap createBooleanMap() -
createObjectMap
-
getParentAttribute
ObjectAttribute getParentAttribute()Defines the derived attribute which has as value the parent object.- Returns:
- the parent attribute
- See Also:
-
getTreePattern
EdgePattern getTreePattern()Defines the pattern used for the construction of this graph's tree.- Returns:
- an edge pattern
- See Also:
-
getSpecialEdgeDescriptors
-
getDescription
Returns a description for the given object. The type of the desired description (e.g., text, icon) is specified in the argumenttype
; it is interpreted as inDescribed.getDescription(String)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgetype
- the type of description- Returns:
- a description of the given type, or
null
-
getSymbol
-
getColor
-
addChangeBoundaryListener
-
removeChangeBoundaryListener
-
addAttributeChangeListener
-
removeAttributeChangeListener
-
addEdgeChangeListener
-
removeEdgeChangeListener
-
addAttributeChangeListener
-
removeAttributeChangeListener
-
addEdgeChangeListener
-
removeEdgeChangeListener
-