Package com.storedobject.chart
Class GraphData.Node
java.lang.Object
com.storedobject.chart.GraphData.Node
- All Implemented Interfaces:
ComponentPart,ComponentProperty
- Direct Known Subclasses:
GraphData.ValueNode,GraphData.XYNode
- Enclosing class:
GraphData<N extends GraphData.Node>
The abstract class Node serves as the base class for components within a graph structure.
It represents a single node entity that can be connected to other nodes via edges and contains
functionality to manage its own metadata and relationships.
This class ensures each node has a unique identifier, a name, a category, and a list of edges.
Nodes can be connected to other nodes and can serialize themselves into JSON format.
- Author:
- Syam
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconnectTo(GraphData.Node target) Connects the current node to the specified target node by creating an edge between them.voidEncode the JSON string with the properties of this.Retrieves the category associated with this node.final longgetId()Each part should have a unique Id.final StringgetName()Retrieves the name of the node.intGet the current serial number (Serial number used for internal purposes only).voidsetCategory(GraphData.Category category) Sets the category associated with this node.voidSets the name of this node.voidsetSerial(int serial) Set a serial number (Serial number used for internal purposes only).final Stream<GraphData.Edge> Streams the edges associated with this node as aStream.voidvalidate()This method is invoked bySOChartto check if the component or part is valid or not.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.chart.ComponentPart
className, getRenderingIndex, setRenderingIndex
-
Field Details
-
name
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
getCategory
Retrieves the category associated with this node.- Returns:
- The category of this node.
-
setCategory
Sets the category associated with this node.- Parameters:
category- The category to be associated with this node.
-
connectTo
Connects the current node to the specified target node by creating an edge between them. If an edge already exists between the current node and the target node, it is returned. Otherwise, a new edge is created, added to the current node's list of edges, and returned.- Parameters:
target- The target node to which a connection is to be established. May not be null.- Returns:
- The
Edgeobject representing the connection to the target node, ornullif the target node is null.
-
getName
Retrieves the name of the node.- Specified by:
getNamein interfaceComponentPart- Returns:
- the name of the node as a String.
-
setName
Sets the name of this node.- Specified by:
setNamein interfaceComponentPart- Parameters:
name- The name to be set for this node.
-
getId
public final long getId()Description copied from interface:ComponentPartEach part should have a unique Id. (It can be a final variable and can be set by callingID.newID().- Specified by:
getIdin interfaceComponentPart- Returns:
- Unique Id.
-
setSerial
public void setSerial(int serial) Description copied from interface:ComponentPartSet a serial number (Serial number used for internal purposes only). The implementation of this method must be in such a way that the serial number set here must be returned by theComponentPart.getSerial()method.- Specified by:
setSerialin interfaceComponentPart- Parameters:
serial- Serial number to set.
-
getSerial
public int getSerial()Description copied from interface:ComponentPartGet the current serial number (Serial number used for internal purposes only). The serial number set by theComponentPart.setSerial(int)method should be returned by this method.- Specified by:
getSerialin interfaceComponentPart- Returns:
- Current serial number.
-
validate
Description copied from interface:ComponentPartThis method is invoked bySOChartto check if the component or part is valid or not.- Specified by:
validatein interfaceComponentPart- Throws:
ChartException- Raises exception if the component or part is not valid.
-
streamEdges
Streams the edges associated with this node as aStream.- Returns:
- A
StreamofEdgeobjects representing the edges of this node.
-
encodeJSON
Description copied from interface:ComponentPropertyEncode the JSON string with the properties of this.- Specified by:
encodeJSONin interfaceComponentProperty- Parameters:
sb- Encoded JSON string to be appended to this.
-