GraphView
Static or interactive diagram graph widget displaying connected nodes, edges, labels, and tooltips with custom renderers.
Overview
Static or interactive diagram graph widget displaying connected nodes, edges, labels, and tooltips with custom renderers. Provides extensive layout configuration and interaction capabilities.
Basic Usage
GraphView graph = new GraphView();
graph.addNode("a", 0.2f, 0.5f);
graph.addNode("b", 0.8f, 0.5f);
graph.addEdge("a", "b");
Related links
- NodeGraph: Interactive 2D node graph canvas supporting movable nodes, pin connections, pan, zoom, grid snapping, and selection.
API
API
| Method | Description |
|---|---|
GraphView() |
Constructs a GraphView diagram widget with default styles. |
addEdge(String, String) |
Adds a directed edge connection between two node IDs. |
addNode(String, float, float) |
Adds a node with ID and normalized (0..1) or absolute coordinates. |
clearGraph() |
Clears all nodes and edges from the diagram. |
edgeColor() |
Returns the connection edge line color. |
hoveredNodeColor() |
Returns the hover fill color for nodes. |
labelColor() |
Returns the node label text color. |
nodeColor() |
Returns the default node circle fill color. |
nodeLabelPlacement(NodeLabelPlacement) |
Sets relative placement of text labels around node points. |
nodeLabelProvider(Function) |
Configures a function returning the text label for a given node point. |
nodeLabelRenderer(GraphNodeLabelRenderer) |
Sets a custom renderer callback for drawing node labels. |
nodeLabelsVisible(boolean) |
Sets whether text labels are rendered alongside node points. |
nodeRenderer(GraphNodeRenderer) |
Sets a custom renderer callback for drawing node points. |
nodeTooltipProvider(Function) |
Configures a function returning tooltip text for hovered nodes. |
nodeTooltipRenderer(GraphNodeTooltipRenderer) |
Sets a custom renderer callback for drawing node hover tooltips. |
onNodeClick(EventListener) |
Registers a listener called when a node point is clicked. |
preferredHeight() |
Returns the preferred height of this graph view. |
preferredHeight(float) |
Sets the preferred height of this graph view. |
preferredSize(float, float) |
Sets both preferred width and height dimensions. |
preferredWidth() |
Returns the preferred width of this graph view. |
preferredWidth(float) |
Sets the preferred width of this graph view. |
tooltipBackground() |
Returns the background fill color of node tooltip popups. |
tooltipBorder() |
Returns the border outline color of node tooltip popups. |
GraphView()
Constructs a GraphView diagram widget with default styles.
GraphView::addEdge(String, String)
Adds a directed edge connection between two node IDs.
| Parameter | Type | Description |
|---|---|---|
from |
String |
The source node identifier. |
to |
String |
The destination node identifier. |
Returns GraphView: This instance for chaining..
GraphView::addNode(String, float, float)
Adds a node with ID and normalized (0..1) or absolute coordinates.
| Parameter | Type | Description |
|---|---|---|
id |
String |
The node identifier. |
x |
float |
The X coordinate position. |
y |
float |
The Y coordinate position. |
Returns GraphView: This instance for chaining..
GraphView::clearGraph()
Clears all nodes and edges from the diagram.
Returns GraphView: This instance for chaining..
GraphView::edgeColor()
Returns the connection edge line color.
Returns MutableColor: The mutable color instance..
GraphView::hoveredNodeColor()
Returns the hover fill color for nodes.
Returns MutableColor: The mutable color instance..
GraphView::labelColor()
Returns the node label text color.
Returns MutableColor: The mutable color instance..
GraphView::nodeColor()
Returns the default node circle fill color.
Returns MutableColor: The mutable color instance..
GraphView::nodeLabelPlacement(NodeLabelPlacement)
Sets relative placement of text labels around node points.
| Parameter | Type | Description |
|---|---|---|
nodeLabelPlacement |
NodeLabelPlacement |
The relative label placement around nodes. |
Returns GraphView: This instance for chaining..
GraphView::nodeLabelProvider(Function)
Configures a function returning the text label for a given node point.
| Parameter | Type | Description |
|---|---|---|
nodeLabelProvider |
Function |
The node label provider function. |
Returns GraphView: This instance for chaining..
GraphView::nodeLabelRenderer(GraphNodeLabelRenderer)
Sets a custom renderer callback for drawing node labels.
| Parameter | Type | Description |
|---|---|---|
nodeLabelRenderer |
GraphNodeLabelRenderer |
The custom node label renderer callback. |
Returns GraphView: This instance for chaining..
GraphView::nodeLabelsVisible(boolean)
Sets whether text labels are rendered alongside node points.
| Parameter | Type | Description |
|---|---|---|
nodeLabelsVisible |
boolean |
Whether node text labels are rendered. |
Returns GraphView: This instance for chaining..
GraphView::nodeRenderer(GraphNodeRenderer)
Sets a custom renderer callback for drawing node points.
| Parameter | Type | Description |
|---|---|---|
nodeRenderer |
GraphNodeRenderer |
The custom node renderer callback. |
Returns GraphView: This instance for chaining..
GraphView::nodeTooltipProvider(Function)
Configures a function returning tooltip text for hovered nodes.
| Parameter | Type | Description |
|---|---|---|
nodeTooltipProvider |
Function |
The node tooltip provider function. |
Returns GraphView: This instance for chaining..
GraphView::nodeTooltipRenderer(GraphNodeTooltipRenderer)
Sets a custom renderer callback for drawing node hover tooltips.
| Parameter | Type | Description |
|---|---|---|
nodeTooltipRenderer |
GraphNodeTooltipRenderer |
The custom node tooltip renderer callback. |
Returns GraphView: This instance for chaining..
GraphView::onNodeClick(EventListener)
Registers a listener called when a node point is clicked.
| Parameter | Type | Description |
|---|---|---|
listener |
EventListener |
The event listener callback. |
Returns EventSubscription: The event subscription handle..
GraphView::preferredHeight()
Returns the preferred height of this graph view.
Returns float: The preferred height in pixels..
GraphView::preferredHeight(float)
Sets the preferred height of this graph view.
| Parameter | Type | Description |
|---|---|---|
preferredHeight |
float |
The preferred height in pixels. |
Returns GraphView: This instance for chaining..
GraphView::preferredSize(float, float)
Sets both preferred width and height dimensions.
| Parameter | Type | Description |
|---|---|---|
width |
float |
The preferred width in pixels. |
height |
float |
The preferred height in pixels. |
Returns GraphView: This instance for chaining..
GraphView::preferredWidth()
Returns the preferred width of this graph view.
Returns float: The preferred width in pixels..
GraphView::preferredWidth(float)
Sets the preferred width of this graph view.
| Parameter | Type | Description |
|---|---|---|
preferredWidth |
float |
The preferred width in pixels. |
Returns GraphView: This instance for chaining..
GraphView::tooltipBackground()
Returns the background fill color of node tooltip popups.
Returns MutableColor: The mutable color instance..
GraphView::tooltipBorder()
Returns the border outline color of node tooltip popups.
Returns MutableColor: The mutable color instance..
Graph Data
| Method | Description |
|---|---|
removeNode(String) |
Removes a node and all incident edges. |
nodeCount() |
Returns the number of nodes currently in the graph. |
edgeCount() |
Returns the number of edges, including edges waiting for missing endpoints. |
GraphView::removeNode(String)
Removes a node and all incident edges.
| Parameter | Type | Description |
|---|---|---|
id |
String |
Node identifier to remove; null or unknown identifiers are ignored. |
Returns GraphView: This graph view for fluent configuration..
GraphView::nodeCount()
Returns the number of nodes currently in the graph.
Returns int: The current number of nodes..
GraphView::edgeCount()
Returns the number of edges, including edges waiting for missing endpoints.
Returns int: The current number of stored edges..
Appearance
| Method | Description |
|---|---|
nodeBorderColor() |
Returns the mutable color used to outline graph nodes. |
hoveredEdgeColor() |
Returns the mutable color used for edges connected to the hovered node. |
directed(boolean) |
Enables or disables arrowheads at edge targets. |
directed() |
Returns whether edges are rendered as directed connections. |
GraphView::nodeBorderColor()
Returns the mutable color used to outline graph nodes.
Returns MutableColor: The mutable RGBA node-border color..
GraphView::hoveredEdgeColor()
Returns the mutable color used for edges connected to the hovered node.
Returns MutableColor: The mutable RGBA hovered-edge color..
GraphView::directed(boolean)
Enables or disables arrowheads at edge targets.
| Parameter | Type | Description |
|---|---|---|
directed |
boolean |
True to draw an arrowhead at each target node. |
Returns GraphView: This graph view for fluent configuration..
GraphView::directed()
Returns whether edges are rendered as directed connections.
Returns boolean: True when edge target arrowheads are enabled..