Module graph

Class AttributeOverwritingFilter

java.lang.Object
de.grogra.graph.GraphBase
de.grogra.graph.GraphFilter
de.grogra.graph.AttributeOverwritingFilter
All Implemented Interfaces:
AttributeChangeListener, ChangeBoundaryListener, EdgeChangeListener, Graph, Lockable
Direct Known Subclasses:
HighlightFilter, TopologyGraph

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
  • Constructor Details

    • AttributeOverwritingFilter

      public AttributeOverwritingFilter(Graph source)
  • Method Details

    • initAttributeOverwritingFilter

      protected void initAttributeOverwritingFilter()
    • 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
    • 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
    • accept

      public void accept(Object startNode, Visitor visitor, ArrayPath placeInPath)
    • getAttributes

      public Attribute[] getAttributes(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
    • getAccessor

      public AttributeAccessor getAccessor(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
    • getBoolean

      protected boolean getBoolean(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
    • setBoolean

      protected boolean setBoolean(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
    • getByte

      protected byte getByte(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
    • setByte

      protected byte setByte(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
    • getShort

      protected short getShort(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
    • setShort

      protected short setShort(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
    • getChar

      protected char getChar(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
    • setChar

      protected char setChar(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
    • getInt

      protected int getInt(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
    • setInt

      protected int setInt(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
    • getLong

      protected long getLong(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
    • setLong

      protected long setLong(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
    • getFloat

      protected float getFloat(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
    • setFloat

      protected float setFloat(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
    • getDouble

      protected double getDouble(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
    • setDouble

      protected double setDouble(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
    • getObject

      protected Object getObject(Object object, GraphFilter.AccessorBridge accessor, 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
    • setObject

      protected Object setObject(Object object, GraphFilter.AccessorBridge accessor, 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