de.grogra.graph
Class AttributeOverwritingFilter

java.lang.Object
  extended by de.grogra.graph.GraphBase
      extended by de.grogra.graph.GraphFilter
          extended by de.grogra.graph.AttributeOverwritingFilter
All Implemented Interfaces:
AttributeChangeListener, ChangeBoundaryListener, EdgeChangeListener, Graph, Lockable

public abstract class AttributeOverwritingFilter
extends GraphFilter

This graph filter may be used as superclass for graph filters which overwrite attribute values of their source graphs. It implements the attribute-related methods such that the attributes of the filtered graph are the attributes of the source graph plus the additionally defined attributes (which may be overwritten attributes of the source graph). The additional attributes have to be declared by overriding the methods initNodeAccessors(AccessorMap) and initEdgeAccessors(AccessorMap).

Author:
Ole Kniemeyer

Nested Class Summary
 
Nested classes/interfaces inherited from class de.grogra.graph.GraphFilter
GraphFilter.AccessorBridge, GraphFilter.State
 
Nested classes/interfaces inherited from interface de.grogra.util.Lockable
Lockable.DeadLockException
 
Field Summary
 
Fields inherited from class de.grogra.graph.GraphFilter
source
 
Fields inherited from interface de.grogra.graph.ChangeBoundaryListener
ATTRIBUTE_PRIORITY, TOPOLOGY_PRIORITY, UPDATE_PRIORITY
 
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
AttributeOverwritingFilter(Graph source)
           
 
Method Summary
 void accept(java.lang.Object startNode, Visitor visitor, ArrayPath placeInPath)
           
 AttributeAccessor getAccessor(java.lang.Object object, boolean asNode, Attribute attribute)
          Returns an attribute accessor for the given attribute on the given object.
 Attribute[] getAttributes(java.lang.Object object, boolean asNode)
          Returns the set of attributes which are available for the given object.
protected  boolean getBoolean(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  byte getByte(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  char getChar(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  double getDouble(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  float getFloat(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  int getInt(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  long getLong(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  java.lang.Object getObject(java.lang.Object object, GraphFilter.AccessorBridge accessor, java.lang.Object placeIn, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  short getShort(java.lang.Object object, GraphFilter.AccessorBridge accessor, GraphState gs)
          This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge.
protected  void initAttributeOverwritingFilter()
           
protected  void initEdgeAccessors(AccessorMap accessors)
          Additional (possibly overwritten) attributes for edges have to be declared in subclasses by overriding this method.
protected  void initNodeAccessors(AccessorMap accessors)
          Additional (possibly overwritten) attributes for nodes have to be declared in subclasses by overriding this method.
protected  boolean setBoolean(java.lang.Object object, GraphFilter.AccessorBridge accessor, boolean value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  byte setByte(java.lang.Object object, GraphFilter.AccessorBridge accessor, byte value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  char setChar(java.lang.Object object, GraphFilter.AccessorBridge accessor, char value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  double setDouble(java.lang.Object object, GraphFilter.AccessorBridge accessor, double value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  float setFloat(java.lang.Object object, GraphFilter.AccessorBridge accessor, float value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  int setInt(java.lang.Object object, GraphFilter.AccessorBridge accessor, int value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  long setLong(java.lang.Object object, GraphFilter.AccessorBridge accessor, long value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  java.lang.Object setObject(java.lang.Object object, GraphFilter.AccessorBridge accessor, java.lang.Object value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
protected  short setShort(java.lang.Object object, GraphFilter.AccessorBridge accessor, short value, GraphState gs)
          This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge.
 
Methods inherited from class de.grogra.graph.GraphFilter
accept, attributeChanged, beginChange, createBooleanMap, createMainState, createObjectMap, createState, edgeChanged, endChange, getColor, getDependent, getDependentOfSource, getDescription, getEdgeBits, getFirstEdge, getId, getInstantiator, getLifeCycleState, getName, getNextEdge, getNodeForId, getObjectForName, getParentAttribute, getPriority, getRoot, getRootKeys, getSourceNode, getSourceState, getSpecialEdgeDescriptors, getStamp, getSymbol, getTargetNode, getTreePattern, isWritable
 
Methods inherited from class de.grogra.graph.GraphBase
addAttributeChangeListener, addAttributeChangeListener, addChangeBoundaryListener, addEdgeChangeListener, addEdgeChangeListener, execute, execute, executeForcedly, executeForcedly, getMainState, getMaxWaitingTime, getQueueLength, getStateMap, init, isLocked, removeAttributeChangeListener, removeAttributeChangeListener, removeChangeBoundaryListener, removeEdgeChangeListener, removeEdgeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeOverwritingFilter

public AttributeOverwritingFilter(Graph source)
Method Detail

accept

public void accept(java.lang.Object startNode,
                   Visitor visitor,
                   ArrayPath placeInPath)

getAccessor

public AttributeAccessor getAccessor(java.lang.Object object,
                                     boolean asNode,
                                     Attribute attribute)
Description copied from interface: Graph
Returns an attribute accessor for the given attribute on the given object.

Specified by:
getAccessor in interface Graph
Overrides:
getAccessor in class GraphFilter
Parameters:
object - the object
asNode - true if object is a node, false if object is an edge
attribute - the attribute
Returns:
an accessor for the object's attribute value

getAttributes

public Attribute[] getAttributes(java.lang.Object object,
                                 boolean asNode)
Description copied from interface: Graph
Returns the set of attributes which are available for the given object.

Specified by:
getAttributes in interface Graph
Overrides:
getAttributes in class GraphFilter
Parameters:
object - the object
asNode - true if object is a node, false if object is an edge
Returns:
the object's attributes

getBoolean

protected boolean getBoolean(java.lang.Object object,
                             GraphFilter.AccessorBridge accessor,
                             GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getBoolean in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getByte

protected byte getByte(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getByte in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getChar

protected char getChar(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getChar in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getDouble

protected double getDouble(java.lang.Object object,
                           GraphFilter.AccessorBridge accessor,
                           GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getDouble in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getFloat

protected float getFloat(java.lang.Object object,
                         GraphFilter.AccessorBridge accessor,
                         GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getFloat in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getInt

protected int getInt(java.lang.Object object,
                     GraphFilter.AccessorBridge accessor,
                     GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getInt in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getLong

protected long getLong(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getLong in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getObject

protected java.lang.Object getObject(java.lang.Object object,
                                     GraphFilter.AccessorBridge accessor,
                                     java.lang.Object placeIn,
                                     GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getObject in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
placeIn - an instance for the result may be provided by the caller
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

getShort

protected short getShort(java.lang.Object object,
                         GraphFilter.AccessorBridge accessor,
                         GraphState gs)
This method has to be implemented by subclasses in order to obtain the value of an additional attribute which is defined by an GraphFilter.AccessorBridge. The default implementation returns the value of accessor's attribute in the source graph.

Overrides:
getShort in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
gs - current graph state
Returns:
value of the accessor's attribute for the object
Throws:
NoSuchKeyException - if the attribute is not defined for the object

initAttributeOverwritingFilter

protected void initAttributeOverwritingFilter()

initEdgeAccessors

protected void initEdgeAccessors(AccessorMap accessors)
Additional (possibly overwritten) attributes for edges have to be declared in subclasses by overriding this method. For each overwritten attribute, a suitable accessor has to be added to accessors. Instances of GraphFilter.AccessorBridge may be used for this purpose.

Parameters:
accessors - set of node accessors

initNodeAccessors

protected void initNodeAccessors(AccessorMap accessors)
Additional (possibly overwritten) attributes for nodes have to be declared in subclasses by overriding this method. For each overwritten attribute, a suitable accessor has to be added to accessors. Instances of GraphFilter.AccessorBridge may be used for this purpose.

Parameters:
accessors - set of node accessors

setBoolean

protected boolean setBoolean(java.lang.Object object,
                             GraphFilter.AccessorBridge accessor,
                             boolean value,
                             GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setBoolean in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setByte

protected byte setByte(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       byte value,
                       GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setByte in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setChar

protected char setChar(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       char value,
                       GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setChar in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setDouble

protected double setDouble(java.lang.Object object,
                           GraphFilter.AccessorBridge accessor,
                           double value,
                           GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setDouble in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setFloat

protected float setFloat(java.lang.Object object,
                         GraphFilter.AccessorBridge accessor,
                         float value,
                         GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setFloat in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setInt

protected int setInt(java.lang.Object object,
                     GraphFilter.AccessorBridge accessor,
                     int value,
                     GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setInt in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setLong

protected long setLong(java.lang.Object object,
                       GraphFilter.AccessorBridge accessor,
                       long value,
                       GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setLong in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setObject

protected java.lang.Object setObject(java.lang.Object object,
                                     GraphFilter.AccessorBridge accessor,
                                     java.lang.Object value,
                                     GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setObject in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object

setShort

protected short setShort(java.lang.Object object,
                         GraphFilter.AccessorBridge accessor,
                         short value,
                         GraphState gs)
This method has to be implemented by subclasses in order to set value of an additional writable attribute which is defined by an GraphFilter.AccessorBridge. The default implementation sets the value of accessor's attribute in the source graph.

Overrides:
setShort in class GraphFilter
Parameters:
object - the object
accessor - the accessor bridge which invokes this method
value - the new value for the attribute
gs - current graph state
Returns:
actual new value of the attribute
Throws:
NoSuchKeyException - if the attribute is not defined for the object