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
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Node.NType
static final ObjectAttribute
protected int
This field packs the information of someboolean
and integral attributes into a single 32-bit value.static final int
static final int
static final int
static final Node.NType.Field
static final Node.NType.Field
static final int
static final int
static final Node.NType.Field
static final int
static final Node.NType.Field
static final int
static final Node.NType.Field
static final int
static final MimeType
static final int
static final int
static final int
static final Node.NType.Field
static final int
static final int
static final Node.NType.Field
static final int
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addEdgeBitsTo
(Node target, int edges, Transaction t) void
void
appendBranchNode
(Node node) void
appendBranchNode
(Node node, Transaction xa) void
appendReferencesTo
(List out) protected Object
clone()
clone
(boolean cloneFields) Creates a clone of this node using the methodsnewInstance()
anddup(de.grogra.graph.impl.Node, boolean, de.grogra.persistence.Transaction)
.cloneGraph
(EdgePattern edges, boolean cloneFields) void
dump()
void
dumpTree()
void
dup
(Node original, boolean cloneFields, Transaction t) void
dupFrom
(Node original, boolean cloneFields, Transaction t) duplicate a node of a different type by checking the filed descriptorsvoid
dupnew
(Node original, boolean cloneFields, Transaction t) protected void
dupUnmanagedFields
(Node original) protected void
edgeChanged
(Edge set, int old, Transaction t) void
fieldModified
(PersistenceField field, int[] indices, Transaction t) findAdjacent
(boolean in, boolean out, int edgeBits) Find an adjacent node n to this one.Returns the value associated withkey
.getAccessor
(Attribute attribute) getAccessor
(String name) Returns the parent node of this node.protected boolean
getBoolean
(BooleanAttribute a, GraphState gs) Returns the first child of this node.int
getBranchNode
(int index) Returns theindex
-th child of this node.protected byte
getByte
(ByteAttribute a, GraphState gs) protected char
getChar
(CharAttribute a, GraphState gs) final GraphState
int
protected double
getDouble
(DoubleAttribute a, GraphState gs) getEdgeAttributeAccessor
(Attribute attribute) getEdgeAttributes
(Edge edge) final int
getEdgeBitsTo
(Node target) final Edge
int
Returns theextentIndex
property of this node.getFirst
(int edgeBits) final Edge
protected float
getFloat
(FloatAttribute a, GraphState gs) final GraphManager
getGraph()
final long
getId()
Returns a unique ID for this node.int
getIndex()
Returns the index of this node in the list of children of its parent.protected int
getInt
(IntAttribute a, GraphState gs) int
getLayer()
protected long
getLong
(LongAttribute a, GraphState gs) final ManageableType
final String
getName()
Returns the name of this node.final Node
getNeighbor
(Node start) final Edge
final Node.NType
getNType()
protected Node.NType
This method returns theNode.NType
which describes the managed fields of the class of this node.protected Object
getObject
(ObjectAttribute a, Object placeIn, GraphState gs) final Edge
getOrCreateEdgeTo
(Node target) final PersistenceManager
Returns the previous sibling of this node.int
protected short
getShort
(ShortAttribute a, GraphState gs) final Node
int
getStamp()
Returns a stamp for this object.Returns the next sibling of this node.int
int
final Node
final Transaction
getTransaction
(boolean create) getUserField
(int index) int
final XClass
final de.grogra.graph.impl.NodeData
getXData()
final boolean
Tests if this node has the specifiedname
.void
initProvider
(SharedObjectProvider provider) final void
initXClass
(XClass cls) void
insertBranchNode
(int index, Node node) void
insertBranchNode
(int index, Node node, Transaction xa) boolean
instantiateGraph
(int edges, ArrayPath path, Visitor v) boolean
isAncestorOf
(Node n) boolean
isDirection
(Node source, Node target) boolean
isEncoarseOf
(Node n) boolean
boolean
isMarked()
boolean
isRoot()
boolean
boolean
protected Node
This method returns a new instance of the class of this node.protected String
Computes the class-specific part of the string returned bytoString()
which shall be enclosed in brackets.final void
final void
removeEdgeBitsTo
(Node target, int edges, Transaction t) void
void
void
void
void
setBranch
(Node c, Transaction xa) void
setExtentIndex
(int index) Sets theextentIndex
property of this nodeWhen 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.void
setIgnored
(Boolean ignored) void
setLayer
(int layer) void
setMark
(boolean value) void
Sets the name of this node.void
setResolution
(int resolution) void
setSuccessor
(Node s) void
setSuccessor
(Node s, Transaction xa) protected void
specialEdgeAdded
(Edge set, Transaction t) protected void
specialEdgeRefModified
(Node ref, Node.NType.Field edgeField, PersistenceField field, int[] indices, Transaction t) protected void
specialEdgeRemoved
(Edge set, int old, Transaction t) toString()
protected Object
This method is used by object serialization.Methods inherited from class de.grogra.graph.impl.Edge
addEdgeBits, getBitMark, getEdgeBits, getEdgeKeys, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBits
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface de.grogra.persistence.PersistenceCapable
getBitMark, getObjectMark, setBitMark, setObjectMark
-
Field Details
-
$TYPE
-
name$FIELD
-
layer$FIELD
-
resolution$FIELD
-
extentIndex$FIELD
-
mark$FIELD
-
isInterpretive$FIELD
-
extentTail$FIELD
-
MIME_TYPE
-
MIN_UNUSED_SPECIAL_OF_TARGET
public static final int MIN_UNUSED_SPECIAL_OF_TARGET- See Also:
-
MIN_UNUSED_SPECIAL_OF_SOURCE
public static final int MIN_UNUSED_SPECIAL_OF_SOURCE- See Also:
-
MIN_RESOLUTION
public static final int MIN_RESOLUTION- See Also:
-
MAX_RESOLUTION
public static final int MAX_RESOLUTION- See Also:
-
DELETED
public static final int DELETED- See Also:
-
HAS_OBSERVERS
public static final int HAS_OBSERVERS- See Also:
-
IS_INTERPRETIVE
public static final int IS_INTERPRETIVE- See Also:
-
EXTENT_BIT
public static final int EXTENT_BIT- See Also:
-
LAST_EXTENT_INDEX
public static final int LAST_EXTENT_INDEX- See Also:
-
EXTENT_MASK
public static final int EXTENT_MASK- See Also:
-
MARK
public static final int MARK- See Also:
-
RESOLUTION_BIT
public static final int RESOLUTION_BIT- See Also:
-
RESOLUTION_MASK
public static final int RESOLUTION_MASK- See Also:
-
USED_BITS
public static final int USED_BITS- See Also:
-
ADDITIONAL_FIELDS
-
bits
protected int bitsThis field packs the information of someboolean
and integral attributes into a single 32-bit value. The bits defined in the base classNode
are the firstUSED_BITS
bits, starting at bit 0.
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
getManageableType
- Specified by:
getManageableType
in interfaceManageable
-
manageableReadResolve
- Specified by:
manageableReadResolve
in interfaceManageable
-
manageableWriteReplace
- Specified by:
manageableWriteReplace
in interfaceManageable
-
getNType
-
getNTypeImpl
This method returns theNode.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
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
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
clone
Creates a clone of this node using the methodsnewInstance()
anddup(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
- 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
-
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
- Specified by:
getPersistenceManager
in interfacePersistenceCapable
-
getGraph
-
getTransaction
-
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 interfacePersistenceCapable
-
getAccessor
-
getAccessor
-
getAttributes
-
getEdgeAttributes
-
getEdgeAttributeAccessor
-
getBoolean
-
getByte
-
getShort
-
getChar
-
getInt
-
getLong
-
getFloat
-
getDouble
-
getObject
-
initXClass
- Specified by:
initXClass
in interfaceXObject
-
getXClass
-
getXData
public final de.grogra.graph.impl.NodeData getXData() -
getOrNull
-
get
Description copied from interface:Map
Returns the value associated withkey
. If there is no value associated withkey
,defaultValue
is returned. -
getNext
-
getSource
-
getTarget
-
isSource
-
isTarget
-
isDirection
- Specified by:
isDirection
in classEdge
-
getNeighbor
- Specified by:
getNeighbor
in classEdge
-
getFirstEdge
-
getEdgeTo
-
getEdgeBitsTo
-
getOrCreateEdgeTo
-
removeAll
-
addEdgeBitsTo
-
removeEdgeBitsTo
-
toString
-
paramString
Computes the class-specific part of the string returned bytoString()
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
Sets the name of this node.- Parameters:
name
- new name of node, may benull
- See Also:
-
getName
Returns the name of this node. Names are not unique and may benull
. The graph of this node maintains a map from names to nodes, seeGraphManager.getNodeForName(String)
.- Returns:
- name of this node, may be
null
-
hasName
Tests if this node has the specifiedname
. I.e., bothname
and this node's name arenull
, 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 theextentIndex
property of this node- Parameters:
index
- new value for property- See Also:
-
getExtentIndex
public int getExtentIndex()Returns theextentIndex
property of this node. This determines the index of the list of theExtent
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 interfaceUserFields
-
getUserField
- Specified by:
getUserField
in interfaceUserFields
-
getInstantiator
-
instantiateGraph
-
findAdjacent
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 consideredout
- true if edges outgoing from this node should be considerededgeBits
- the type/types of edges to consider- Returns:
- an adjacent node that matches the criteria or null if none found
-
getFirst
-
getBranch
Returns the first child of this node. The underlying tree structure is defined by the edgesGraph.BRANCH_EDGE
andGraph.SUCCESSOR_EDGE
: The first child of a node is reached by traversing aGraph.BRANCH_EDGE
in forward direction, its siblings are reached by traversingGraph.SUCCESSOR_EDGE
in forward direction from sibling to sibling.- Returns:
- the first child, or
null
-
getBranchTail
-
getBranchLength
public int getBranchLength() -
getAxisParent
Returns the parent node of this node. The underlying tree structure is defined by the edgesGraph.BRANCH_EDGE
andGraph.SUCCESSOR_EDGE
.- Returns:
- the parent
- See Also:
-
getSuccessor
Returns the next sibling of this node. The underlying tree structure is defined by the edgesGraph.BRANCH_EDGE
andGraph.SUCCESSOR_EDGE
.- Returns:
- the next sibling
- See Also:
-
getPredecessor
Returns the previous sibling of this node. The underlying tree structure is defined by the edgesGraph.BRANCH_EDGE
andGraph.SUCCESSOR_EDGE
.- Returns:
- the previous sibling
- See Also:
-
getBranchNode
Returns theindex
-th child of this node. The underlying tree structure is defined by the edgesGraph.BRANCH_EDGE
andGraph.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 edgesGraph.BRANCH_EDGE
andGraph.SUCCESSOR_EDGE
.- Returns:
- the child index of this node
- See Also:
-
appendBranchNode
-
appendBranchNode
-
insertBranchNode
-
insertBranchNode
-
setBranch
-
setBranch
-
setSuccessor
-
setSuccessor
-
isAncestorOf
-
isEncoarseOf
-
findRefinementType
-
getCommonAncestor
-
removeFromChain
public void removeFromChain() -
removeFromChain
-
fieldModified
- Specified by:
fieldModified
in interfaceManageable
-
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 interfaceManageable
- Returns:
- a stamp
-
specialEdgeRefModified
protected void specialEdgeRefModified(Node ref, Node.NType.Field edgeField, PersistenceField field, int[] indices, Transaction t) -
edgeChanged
-
specialEdgeRemoved
-
specialEdgeAdded
-
getProvider
- Specified by:
getProvider
in interfaceShareable
-
appendReferencesTo
- Specified by:
appendReferencesTo
in interfaceShareable
-
dumpTree
public void dumpTree() -
dump
public void dump() -
setGraphForDeserialization
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
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
-
getIgnored
-