A Javafx-based graph structure display
This project aims to deliver a simple, usable API for constructing and display the typical node-edge graph.
The main component will be a graph class. This graph class will act as a container for both nodes and edges. The client will interact primarily with this graph class to render nodes, edges, labels, and other displayable components.
Special thanks to user Roland, who got me started on Javafx by providing the most amazing answer to the Stack Overflow question found here: https://stackoverflow.com/questions/30679025/graph-visualisation-like-yfiles-in-javafx
Below are key functionalities that I hope to incorporate into this project. These are expected to change throughout the project, so a flexible software design will be necessary. A more concrete API will be developed once the underlying structure is implemented.The main component that contains and manages graph-nodes and graph-edges.
- Create graph: Create an abstract graph object.
- Add Node: Add a node object to the board.
- Add Edge: Add an edge object to the board.
- Add graph: Add a graph to a scene. This will most likely be accomplished by having graph extend the base JavaFX node class.
- Remove graph: Remove graph from the scene it belongs to. Much like "Add graph", this will likely be accomplished by having graph extend the base JavaFX node class.
- Display graph: Display the graph to the user. Should be similar to the pre-existing setVisible(boolean) method.
- Reorganize Display:Change the display of the graph to optimize the display. This will include minimizing the number of overlapping Graph-Edges, spreading apart the Graph-Nodes, and general decluttering of the display.
Named 'graph-node' to avoid confusion with JavaFX's 'Node' class.
- Change Position: The node must be able to change positions.
- Change Size: The size of the node must be mutable.
- Change Color: The client must be able to customize node color.
- Change inner content: The content of the Node must be manageable by the client.
- Add event handler: The client must be able to add listeners that run custom callback methods when the graph-node is clicked, dragged, hovered over, etc.
Named 'graph-edge' for consistency with 'graph-node'.
- Attach to a pair of graph-nodes: The user must be able to add a graph-edge to any pair of graph-nodes. Re-orientation of the graph-nodes must result in appropriate re-orientation of the graph-edges.
- Adjust width: The user must be able to change the width (and possibly style - dashes, color) of the graph-edge.
- Directed vs Undirected: While a graph-edge specified directed should start at a from graph-node and end at an end graph-node as denoted by an arrow-like style, an undirected graph-edge should have no such direction.
- Add event handler: The client must be able to add listeners that run custom callback methods when the graph-edge is clicked, dragged, hovered over, etc.
To achieve the above functionalities, the following API will be implemented:
The widget that serves as the view for a client.
- void setGraphLayoutManager(GraphLayoutManager): Sets the GraphLayoutManager for this graph.
- GraphLayoutManager getGraphLayoutManager(): Returns the GraphLayoutManager of graph.
- String addNode(GraphNode): Adds a GraphNode to the graph.
- void removeNode(String): Deletes a graphNode from the graph by GraphNode UUID.
Manages the layout of nodes and edges of the associated graph.
- execute: Rearranges Nodes/edges to match the GraphLayoutManager's intended layout.