Module graph

Class Node

java.lang.Object
de.grogra.graph.impl.Edge
de.grogra.graph.impl.Node
All Implemented Interfaces:
Manageable, PersistenceCapable, Shareable, UserFields, XObject, Map, Serializable
Direct Known Subclasses:
AdjustLU, Assignment, Axiom, BlendItem, BooleanNode, ByteNode, C0, Cell, ChannelMapNode, CharNode, CollectionCloudImpl, CollectionDisplayHandler, D0, DoubleNode, Expression, FieldUpdater, FloatNode, FruitObject, H0, HDir, IncScale, IntermediateCloudNode, InterpretiveMark, IntNode, InvokeMethod, Item, K, KAssignment, KL, L0, LeafObject, LongNode, MassObject, MSMLMetadata, MSNode, N0, Null, Null, ObjectNode, P0, PDBStartNode, PhysicsModel, ProductionRootImpl, PropertyNodeImpl, QueryRootImpl, RGG, RGGRoot, Rotate, Rotation, Rotation, Scale, ScaleClass, SharedObjectNode, ShortNode, SRoot, ToolRoot, Translate, TreeCompartment, Tropism, TypeRoot, U0, V0, Variation

public class Node extends Edge implements PersistenceCapable, Shareable, Map, XObject, UserFields
This class represents the base class of nodes in a GraphManager. Such a graph is used, e.g., as the project graph of the GroIMP software.

Node extends Edge: A Node is able to represent not only itself, but also a single incoming edge. The advantage of this feature is the reduced number of instances for a given graph. E.g., a tree graph with N nodes has N-1 edges. Assuming that they point from a parent to child, all these edges can be represented as part of the child node instances.

If a node is part of the graph of GraphManager, it can be identified by its unique id. A node also has a name, however, this may be null and is not unique. Nevertheless, the graph maintains a map from names to nodes which may be used to efficiently obtain nodes having some specified name.

Author:
Ole Kniemeyer
See Also:
  • Field Details

  • Constructor Details

    • Node

      public Node()
  • Method Details

    • getManageableType

      public final ManageableType getManageableType()
      Specified by:
      getManageableType in interface Manageable
    • manageableReadResolve

      public Manageable manageableReadResolve()
      Specified by:
      manageableReadResolve in interface Manageable
    • manageableWriteReplace

      public Object manageableWriteReplace()
      Specified by:
      manageableWriteReplace in interface Manageable
    • getNType

      public final Node.NType getNType()
    • getNTypeImpl

      protected Node.NType getNTypeImpl()
      This method returns the Node.NType which describes the managed fields of the class of this node. This method has to be implemented in every concrete subclass.
      Returns:
      type describing the managed fields of the class of this node
    • isManagingInstance

      public boolean isManagingInstance()
    • newInstance

      protected Node newInstance()
      This method returns a new instance of the class of this node. This method has to be implemented in every concrete subclass.
      Returns:
      new instance of class of this node
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • clone

      public Node clone(boolean cloneFields) throws CloneNotSupportedException
      Creates a clone of this node using the methods newInstance() and dup(de.grogra.graph.impl.Node, boolean, de.grogra.persistence.Transaction). The clone is not part of the graph.
      Parameters:
      cloneFields - perform a deep clone of field values?
      Returns:
      clone of this node
      Throws:
      CloneNotSupportedException
    • cloneGraph

      public Node cloneGraph(EdgePattern edges, boolean cloneFields) throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • dup

      public void dup(Node original, boolean cloneFields, Transaction t) throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • dupnew

      public void dupnew(Node original, boolean cloneFields, Transaction t) throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • dupUnmanagedFields

      protected void dupUnmanagedFields(Node original)
    • dupFrom

      public void dupFrom(Node original, boolean cloneFields, Transaction t) throws CloneNotSupportedException
      duplicate a node of a different type by checking the filed descriptors
      Throws:
      CloneNotSupportedException
    • getPersistenceManager

      public final PersistenceManager getPersistenceManager()
      Specified by:
      getPersistenceManager in interface PersistenceCapable
    • getGraph

      public final GraphManager getGraph()
    • getTransaction

      public final Transaction getTransaction(boolean create)
    • getCurrentGraphState

      public final GraphState getCurrentGraphState()
    • isRoot

      public boolean isRoot()
    • getDirectChildCount

      public int getDirectChildCount()
    • getId

      public final long getId()
      Returns a unique ID for this node. The IDs are serially counted up from zero for each node that is created and inserted into the graph. Nodes that are created but not inserted into the graph have an ID of -1. Nodes that were part of the graph, but were removed later on have an ID of -2.
      Specified by:
      getId in interface PersistenceCapable
    • getAccessor

      public AttributeAccessor getAccessor(Attribute attribute)
    • getAccessor

      public AttributeAccessor getAccessor(String name)
    • getAttributes

      public Attribute[] getAttributes()
    • getEdgeAttributes

      public Attribute[] getEdgeAttributes(Edge edge)
    • getEdgeAttributeAccessor

      public AttributeAccessor getEdgeAttributeAccessor(Attribute attribute)
    • getBoolean

      protected boolean getBoolean(BooleanAttribute a, GraphState gs)
    • getByte

      protected byte getByte(ByteAttribute a, GraphState gs)
    • getShort

      protected short getShort(ShortAttribute a, GraphState gs)
    • getChar

      protected char getChar(CharAttribute a, GraphState gs)
    • getInt

      protected int getInt(IntAttribute a, GraphState gs)
    • getLong

      protected long getLong(LongAttribute a, GraphState gs)
    • getFloat

      protected float getFloat(FloatAttribute a, GraphState gs)
    • getDouble

      protected double getDouble(DoubleAttribute a, GraphState gs)
    • getObject

      protected Object getObject(ObjectAttribute a, Object placeIn, GraphState gs)
    • initXClass

      public final void initXClass(XClass cls)
      Specified by:
      initXClass in interface XObject
    • getXClass

      public final XClass getXClass()
      Specified by:
      getXClass in interface XObject
    • getXData

      public final de.grogra.graph.impl.NodeData getXData()
      Specified by:
      getXData in interface XObject
    • getOrNull

      public Object getOrNull(Object key)
    • get

      public Object get(Object key, Object defaultValue)
      Description copied from interface: Map
      Returns the value associated with key. If there is no value associated with key, defaultValue is returned.
      Specified by:
      get in interface Map
      Parameters:
      key - a key for the map
      defaultValue - the default value
      Returns:
      the associated value, or defaultValue
    • getNext

      public final Edge getNext(Node parent)
      Specified by:
      getNext in class Edge
    • getSource

      public final Node getSource()
      Specified by:
      getSource in class Edge
    • getTarget

      public final Node getTarget()
      Specified by:
      getTarget in class Edge
    • isSource

      public boolean isSource(Node node)
      Specified by:
      isSource in class Edge
    • isTarget

      public boolean isTarget(Node node)
      Specified by:
      isTarget in class Edge
    • isDirection

      public boolean isDirection(Node source, Node target)
      Specified by:
      isDirection in class Edge
    • getNeighbor

      public final Node getNeighbor(Node start)
      Specified by:
      getNeighbor in class Edge
    • getFirstEdge

      public final Edge getFirstEdge()
    • getEdgeTo

      public final Edge getEdgeTo(Node target)
    • getEdgeBitsTo

      public final int getEdgeBitsTo(Node target)
    • getOrCreateEdgeTo

      public final Edge getOrCreateEdgeTo(Node target)
    • removeAll

      public final void removeAll(Transaction t)
    • addEdgeBitsTo

      public final void addEdgeBitsTo(Node target, int edges, Transaction t)
    • removeEdgeBitsTo

      public final void removeEdgeBitsTo(Node target, int edges, Transaction t)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • paramString

      protected String paramString()
      Computes the class-specific part of the string returned by toString() which shall be enclosed in brackets. This should be used to show important properties of this node.
      Returns:
      string describing some important properties of this node
    • setName

      public void setName(String name)
      Sets the name of this node.
      Parameters:
      name - new name of node, may be null
      See Also:
    • getName

      public final String getName()
      Returns the name of this node. Names are not unique and may be null. The graph of this node maintains a map from names to nodes, see GraphManager.getNodeForName(String).
      Returns:
      name of this node, may be null
    • hasName

      public final boolean hasName(String name)
      Tests if this node has the specified name. I.e., both name and this node's name are null, or they consist of the same sequence of characters.
      Parameters:
      name - a name to test
      Returns:
      has this node the specified name?
    • setLayer

      public void setLayer(int layer)
    • getLayer

      public int getLayer()
    • setResolution

      public void setResolution(int resolution)
    • getResolution

      public int getResolution()
    • setExtentIndex

      public void setExtentIndex(int index)
      Sets the extentIndex property of this node
      Parameters:
      index - new value for property
      See Also:
    • getExtentIndex

      public int getExtentIndex()
      Returns the extentIndex property of this node. This determines the index of the list of the Extent in which this node is inserted.
      Returns:
      insert node at tail or head of linked list of extent?
    • setMark

      public void setMark(boolean value)
    • isMarked

      public boolean isMarked()
    • getSymbol

      public int getSymbol()
    • getSymbolColor

      public int getSymbolColor()
    • getUserFieldCount

      public int getUserFieldCount()
      Specified by:
      getUserFieldCount in interface UserFields
    • getUserField

      public Field getUserField(int index)
      Specified by:
      getUserField in interface UserFields
    • getInstantiator

      public Instantiator getInstantiator()
    • instantiateGraph

      public boolean instantiateGraph(int edges, ArrayPath path, Visitor v)
    • findAdjacent

      public Node findAdjacent(boolean in, boolean out, int edgeBits)
      Find an adjacent node n to this one. The edgeBits are used to determine if a relation between those two nodes exists (Edge.testEdgeBits(int)). If out is true and this node is the source or if in is true and this node is the target, n is returned. Thus, if in and out is true, any adjacent node where the connecting edge matches the edgeBits is considered.
      Parameters:
      in - true if edges incoming to this node should be considered
      out - true if edges outgoing from this node should be considered
      edgeBits - the type/types of edges to consider
      Returns:
      an adjacent node that matches the criteria or null if none found
    • getFirst

      public Node getFirst(int edgeBits)
    • getBranch

      public Node getBranch()
      Returns the first child of this node. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE: The first child of a node is reached by traversing a Graph.BRANCH_EDGE in forward direction, its siblings are reached by traversing Graph.SUCCESSOR_EDGE in forward direction from sibling to sibling.
      Returns:
      the first child, or null
    • getBranchTail

      public Node getBranchTail()
    • getBranchLength

      public int getBranchLength()
    • getAxisParent

      public Node getAxisParent()
      Returns the parent node of this node. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE.
      Returns:
      the parent
      See Also:
    • getSuccessor

      public Node getSuccessor()
      Returns the next sibling of this node. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE.
      Returns:
      the next sibling
      See Also:
    • getPredecessor

      public Node getPredecessor()
      Returns the previous sibling of this node. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE.
      Returns:
      the previous sibling
      See Also:
    • getBranchNode

      public Node getBranchNode(int index)
      Returns the index-th child of this node. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE.
      Parameters:
      index - an index
      Returns:
      the index-th child
      See Also:
    • getIndex

      public int getIndex()
      Returns the index of this node in the list of children of its parent. The underlying tree structure is defined by the edges Graph.BRANCH_EDGE and Graph.SUCCESSOR_EDGE.
      Returns:
      the child index of this node
      See Also:
    • appendBranchNode

      public void appendBranchNode(Node node, Transaction xa)
    • appendBranchNode

      public void appendBranchNode(Node node)
    • insertBranchNode

      public void insertBranchNode(int index, Node node, Transaction xa)
    • insertBranchNode

      public void insertBranchNode(int index, Node node)
    • setBranch

      public void setBranch(Node c, Transaction xa)
    • setBranch

      public void setBranch(Node c)
    • setSuccessor

      public void setSuccessor(Node s, Transaction xa)
    • setSuccessor

      public void setSuccessor(Node s)
    • isAncestorOf

      public boolean isAncestorOf(Node n)
    • isEncoarseOf

      public boolean isEncoarseOf(Node n)
    • findRefinementType

      public Node findRefinementType(Node n)
    • getCommonAncestor

      public Node getCommonAncestor(Node n)
    • removeFromChain

      public void removeFromChain()
    • removeFromChain

      public void removeFromChain(Transaction t)
    • fieldModified

      public void fieldModified(PersistenceField field, int[] indices, Transaction t)
      Specified by:
      fieldModified in interface Manageable
    • getStamp

      public int getStamp()
      Description copied from interface: Manageable
      Returns a stamp for this object. Each modification to this object increments the stamp. The initial stamp is non-negative.
      Specified by:
      getStamp in interface Manageable
      Returns:
      a stamp
    • specialEdgeRefModified

      protected void specialEdgeRefModified(Node ref, Node.NType.Field edgeField, PersistenceField field, int[] indices, Transaction t)
    • edgeChanged

      protected void edgeChanged(Edge set, int old, Transaction t)
    • specialEdgeRemoved

      protected void specialEdgeRemoved(Edge set, int old, Transaction t)
    • specialEdgeAdded

      protected void specialEdgeAdded(Edge set, Transaction t)
    • initProvider

      public void initProvider(SharedObjectProvider provider)
      Specified by:
      initProvider in interface Shareable
    • getProvider

      public SharedObjectProvider getProvider()
      Specified by:
      getProvider in interface Shareable
    • addReference

      public void addReference(SharedObjectReference ref)
      Specified by:
      addReference in interface Shareable
    • removeReference

      public void removeReference(SharedObjectReference ref)
      Specified by:
      removeReference in interface Shareable
    • appendReferencesTo

      public void appendReferencesTo(List out)
      Specified by:
      appendReferencesTo in interface Shareable
    • dumpTree

      public void dumpTree()
    • dump

      public void dump()
    • setGraphForDeserialization

      public GraphManager setGraphForDeserialization(GraphManager mgr)
      When a serialized stream containing references to already existing nodes is deserialized, the graph to use for resolving the id-based references has to be specified by this method. The invocation has to be in the thread which will be used for deserialization.
      Parameters:
      mgr - the graph to use for id-resolution within deserialization
      Returns:
      graph which has been used previously, possibly null
    • writeReplace

      protected Object writeReplace()
      This method is used by object serialization.
      Returns:
      this node if it has no valid id, or a handle for the id
      See Also:
    • setIgnored

      public void setIgnored(Boolean ignored)
    • getIgnored

      public Boolean getIgnored()