de.grogra.graph
Class GraphBase

java.lang.Object
  extended by de.grogra.graph.GraphBase
All Implemented Interfaces:
Graph, Lockable
Direct Known Subclasses:
GraphFilter

public abstract class GraphBase
extends java.lang.Object
implements Graph


Nested Class Summary
protected  class GraphBase.State
           
 
Nested classes/interfaces inherited from interface de.grogra.util.Lockable
Lockable.DeadLockException
 
Field Summary
 
Fields inherited from interface de.grogra.graph.Graph
BRANCH_EDGE, CONTAINMENT_EDGE, CONTAINMENT_END_EDGE, EDGENODE_IN_EDGE, EDGENODE_OUT_EDGE, ELLIPSE_SYMBOL, MAIN_GRAPH, MARK_EDGE, MIN_NORMAL_BIT_INDEX, MIN_UNUSED_EDGE, MIN_UNUSED_EDGE_BIT, NOTIFIES_EDGE, PERSISTENT, PERSISTENT_DELETED, RECTANGLE_SYMBOL, REFINEMENT_EDGE, RHOMBUS_SYMBOL, ROUND_RECTANGLE_SYMBOL, SPECIAL_EDGE_MASK, SPECIAL_EDGE_OF_SOURCE_BIT, STD_EDGE_5, STD_EDGE_6, SUCCESSOR_EDGE, TRANSIENT
 
Constructor Summary
GraphBase(Lockable lockable)
           
 
Method Summary
 void addAttributeChangeListener(AttributeChangeListener l)
           
 void addAttributeChangeListener(java.lang.Object object, boolean asNode, AttributeChangeListener l)
           
 void addChangeBoundaryListener(ChangeBoundaryListener l)
           
 void addEdgeChangeListener(EdgeChangeListener l)
           
 void addEdgeChangeListener(java.lang.Object object, boolean asNode, EdgeChangeListener l)
           
protected abstract  GraphBase.State createMainState()
           
 void execute(LockProtectedRunnable task, boolean write)
          Asynchronously executes a task such that it possesses a lock on this Lockable.
 void execute(LockProtectedRunnable task, Lock retained)
          Asynchronously executes a task using a lock which has been retained before within another task.
 void executeForcedly(LockProtectedRunnable task, boolean write)
          Synchronously executes a task such that it possesses a lock on this Lockable.
 void executeForcedly(LockProtectedRunnable task, Lock retained)
          Synchronously executes a task using a lock which has been retained before within another task.
 GraphState getMainState()
          Returns the main graph state.
 long getMaxWaitingTime()
          Returns the waiting time of the pending task which is waiting longest, or -1 if there is no pending task.
 int getQueueLength()
          Returns the current number of tasks which are waiting for locked execution.
 java.util.Map getStateMap()
           
protected  void init()
           
 boolean isLocked(boolean write)
          Determines if the current thread has a lock for this Lockable.
 void removeAttributeChangeListener(AttributeChangeListener l)
           
 void removeAttributeChangeListener(java.lang.Object object, boolean asNode, AttributeChangeListener l)
           
 void removeChangeBoundaryListener(ChangeBoundaryListener l)
           
 void removeEdgeChangeListener(EdgeChangeListener l)
           
 void removeEdgeChangeListener(java.lang.Object object, boolean asNode, EdgeChangeListener l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.grogra.graph.Graph
accept, createBooleanMap, createObjectMap, getAccessor, getAttributes, getColor, getDependent, getDescription, getEdgeBits, getFirstEdge, getId, getInstantiator, getLifeCycleState, getName, getNextEdge, getNodeForId, getObjectForName, getParentAttribute, getRoot, getRootKeys, getSourceNode, getSpecialEdgeDescriptors, getStamp, getSymbol, getTargetNode, getTreePattern
 

Constructor Detail

GraphBase

public GraphBase(Lockable lockable)
Method Detail

addAttributeChangeListener

public void addAttributeChangeListener(AttributeChangeListener l)
Specified by:
addAttributeChangeListener in interface Graph

addAttributeChangeListener

public void addAttributeChangeListener(java.lang.Object object,
                                       boolean asNode,
                                       AttributeChangeListener l)
Specified by:
addAttributeChangeListener in interface Graph

addChangeBoundaryListener

public void addChangeBoundaryListener(ChangeBoundaryListener l)
Specified by:
addChangeBoundaryListener in interface Graph

addEdgeChangeListener

public void addEdgeChangeListener(EdgeChangeListener l)
Specified by:
addEdgeChangeListener in interface Graph

addEdgeChangeListener

public void addEdgeChangeListener(java.lang.Object object,
                                  boolean asNode,
                                  EdgeChangeListener l)
Specified by:
addEdgeChangeListener in interface Graph

createMainState

protected abstract GraphBase.State createMainState()

execute

public void execute(LockProtectedRunnable task,
                    boolean write)
Description copied from interface: Lockable
Asynchronously executes a task such that it possesses a lock on this Lockable. Note that the execution is asynchronous, so that the thread in which the task will actually be executed may differ from the current thread.

Specified by:
execute in interface Lockable
Parameters:
task - the task to execute
write - shall a write lock be obtained?

execute

public void execute(LockProtectedRunnable task,
                    Lock retained)
Description copied from interface: Lockable
Asynchronously executes a task using a lock which has been retained before within another task. Note that the execution is asynchronous, so that the thread in which the task will actually be executed may differ from the current thread.

Specified by:
execute in interface Lockable
Parameters:
task - the task to execute
retained - the previously retained lock
See Also:
Lock.retain()

executeForcedly

public void executeForcedly(LockProtectedRunnable task,
                            boolean write)
                     throws java.lang.InterruptedException,
                            Lockable.DeadLockException
Description copied from interface: Lockable
Synchronously executes a task such that it possesses a lock on this Lockable. The execution is performed in the current thread.

Specified by:
executeForcedly in interface Lockable
Parameters:
task - the task to execute
write - shall a write lock be obtained?
Throws:
java.lang.InterruptedException
Lockable.DeadLockException

executeForcedly

public void executeForcedly(LockProtectedRunnable task,
                            Lock retained)
                     throws java.lang.InterruptedException
Description copied from interface: Lockable
Synchronously executes a task using a lock which has been retained before within another task. The execution is performed in the current thread.

Specified by:
executeForcedly in interface Lockable
Parameters:
task - the task to execute
retained - the previously retained lock
Throws:
java.lang.InterruptedException
See Also:
Lock.retain()

getMainState

public GraphState getMainState()
Description copied from interface: Graph
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.

Specified by:
getMainState in interface Graph
Returns:
this graph's main graph state
See Also:
Graph

getMaxWaitingTime

public long getMaxWaitingTime()
Description copied from interface: Lockable
Returns the waiting time of the pending task which is waiting longest, or -1 if there is no pending task.

Specified by:
getMaxWaitingTime in interface Lockable
Returns:
current maximum waiting time of pending tasks

getQueueLength

public int getQueueLength()
Description copied from interface: Lockable
Returns the current number of tasks which are waiting for locked execution.

Specified by:
getQueueLength in interface Lockable
Returns:
current number of waiting tasks

getStateMap

public java.util.Map getStateMap()
Specified by:
getStateMap in interface Graph

init

protected void init()

isLocked

public boolean isLocked(boolean write)
Description copied from interface: Lockable
Determines if the current thread has a lock for this Lockable.

Specified by:
isLocked in interface Lockable
Parameters:
write - check for write locks only (true) or for both read and write locks (false)
Returns:
true if the current thread has a lock

removeAttributeChangeListener

public void removeAttributeChangeListener(AttributeChangeListener l)
Specified by:
removeAttributeChangeListener in interface Graph

removeAttributeChangeListener

public void removeAttributeChangeListener(java.lang.Object object,
                                          boolean asNode,
                                          AttributeChangeListener l)
Specified by:
removeAttributeChangeListener in interface Graph

removeChangeBoundaryListener

public void removeChangeBoundaryListener(ChangeBoundaryListener l)
Specified by:
removeChangeBoundaryListener in interface Graph

removeEdgeChangeListener

public void removeEdgeChangeListener(EdgeChangeListener l)
Specified by:
removeEdgeChangeListener in interface Graph

removeEdgeChangeListener

public void removeEdgeChangeListener(java.lang.Object object,
                                     boolean asNode,
                                     EdgeChangeListener l)
Specified by:
removeEdgeChangeListener in interface Graph