(Java FX) PathGraph
What is PathGraph
Path Graph is a library with all the tools necessary to create and work both path and walk graphs in a stable and simple way.
Why PathGraph
If you need a ready-to-use library for user-side representing path graphs in which there are nodes, edges, and associated costs, which offers a user-friendly to represent, manage, and interact graphs, then this it's the right solution.
Fork-Based Project
This library is a fork based on the source code of the SmartGraph v2.0.0. It is modified to suite in specific path graphs features in a stable interface.
[!NOTE]
Read the Javadoc for more details: PathGraph-JavaFX-1.0.9-javadoc
[!NOTE]
Library available on Maven Central: PathGraph-JavaFX-1.0.9
<dependency>
<groupId>io.github.vittoriopiotti</groupId>
<artifactId>PathGraph-JavaFX</artifactId>
<version>1.0.9</version>
</dependency>
Index
- Features
- Graph Logic
- Get Started
- Ready to Code
- Examples
- Callbacks
- DTO · Data Transfer Object
- JSON · Data Management
- Configuration and Styling
- Licenses
Fork-Based On SmartGraph
1. Features
-
Nodes: New Node, Rename Node, Delete Node
-
Edges: New Edge, Delete Edge, Rotate Edge, Split Edge, Set Cost
-
Graph: Upload JSON, Download JSON, Clear Graph, , , , ,
2. Graph Logic
- Limit of 26 Nodes nameable only with uppercase characters
- Limit of two edges with opposite directions beetween two nodes
- Loop creation is not allowed
- Edge cost is an integer number
- Edge directions can be:
Bidirectional, Natural Direction, Opposite Direction
3. Get Started
Requirements
Java-21, JavaFX-22
Forward-compatible
Dependencies
Import External Dependencies
JavaFX-Swing-22, JavaFX-Controls-22, JavaFX-FXML-22
Import Library
PathGraph-JavaFX-1.0.9
Able to:
-
POM configuration:
<dependency>
<groupId>io.github.vittoriopiotti</groupId>
<artifactId>PathGraph-JavaFX</artifactId>
<version>1.0.9</version>
</dependency>
-
Manual configuration:
Download and import jar in your module dependencies: PathGraph-JavaFX-1.0.9.jar
<dependency>
<groupId>io.github.vittoriopiotti</groupId>
<artifactId>PathGraph-JavaFX</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>22</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>22</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>22</version>
</dependency>
4. Ready to Code
Import Component
import com.vittoriopiotti.pathgraph.app.*;
Instance Object
[!NOTE]
PathGraph to create your custom interface
PathGraphUIfor ready-to-use interface
PathGraph
Vanilla configurations to use in your project in which create your custom UI.
Handles the graph's display and logic independently of the user interface, acting as a standalone component without any user interface restrictions, provifind all necessary features.
PathGraph pg = new PathGraph();
Empty callbacks
or
PathGraph pg = new PathGraph(
(ContextMenuCallback) ()->{},
(EdgeCallback) (MouseEvent e, Character c1, Character c2)->{},
(NodeCallback) (MouseEvent e, Character c1, Character c2)->{},
(BackgroundCallback) (MouseEvent e)->{},
(ZoomCallback) (Double n)->{},
(AdjustPositionCallback) ()->{}
);
With callbacks
PathGraphUI
Ready-to-use configuration with default UI.
Extends PathGraph to provide a layer on top of the graph management functionalities. It allows for the interaction with the graph through a visual interface over the underlying graph logic.
PathGraphUI pg = new PathGraphUI(
(Stage) stage,
(Scene) scene
);
With default UI
or
PathGraphUI pg = new PathGraphUI(
(Stage) stage,
(Scene) scene,
/* is enabled top-left menu */
true,
/* is enabled bot-left menu */
true,
/* is enabled bot-mid menu */
true,
/* is enabled right-mid menu */
true,
/* is enabled top-right menu */
true,
/* is hide UI */
false
);
With custom UI
In both cases are customizable the visibility of the UI and its components only with an instance of PathGraphUI:
Hide UI, Show UI, Toggle UI, Set UI
Setup
[!NOTE]
To enable the use of library setup must be called only one time after making stage visible with (Stage) stage.show()
Before calling setup, no operations of any kind can be performed on the graph
pg.setup();
or
pg.setup().thenRun(() -> {
/* actions to perform on first load */
/* e.g. put here components, callba