diff --git a/pom.xml b/pom.xml
index dced969..1aa6d88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,11 +17,6 @@
JavaFXSmartGraph
file://${pom.basedir}/libs/JavaFXSmartGraph
-
- PlantUML
- PlantUML
- file://${pom.basedir}/libs/PlantUML
-
ithaka
http://beckchr.github.io/ithaka-maven/mvnrepo/
@@ -104,9 +99,9 @@
0.1
- PlantUML
- PlantUML
- 1.2023.7
+ net.sourceforge.plantuml
+ plantuml
+ 1.2023.9
com.github.javaparser
diff --git a/src/main/java/model/diagram/javafx/JavaFXClassVisualization.java b/src/main/java/model/diagram/javafx/JavaFXClassVisualization.java
index d8ba544..aadb1c4 100644
--- a/src/main/java/model/diagram/javafx/JavaFXClassVisualization.java
+++ b/src/main/java/model/diagram/javafx/JavaFXClassVisualization.java
@@ -6,18 +6,28 @@
import com.brunomnsilva.smartgraph.graph.Vertex;
import com.brunomnsilva.smartgraph.graphview.SmartCircularSortedPlacementStrategy;
import com.brunomnsilva.smartgraph.graphview.SmartGraphPanel;
+import com.brunomnsilva.smartgraph.graphview.SmartGraphProperties;
import model.diagram.ClassDiagram;
import model.graph.Arc;
import model.graph.ArcType;
import model.graph.ClassifierVertex;
import model.graph.VertexType;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Collection;
+import java.util.Objects;
import java.util.Set;
public class JavaFXClassVisualization implements JavaFXVisualization
{
+ public static final String DEFAULT_PROPERTIES_PATH = "styles/smartgraph.properties";
+ public static final String DEFAULT_STYLE_PATH = "styles/smartgraph.css";
+
private final ClassDiagram classDiagram;
private SmartGraphPanel graphView;
private Collection> vertexCollection;
@@ -34,16 +44,28 @@ public SmartGraphPanel createGraphView()
{
Graph graph = createGraph();
vertexCollection = graph.vertices();
- graphView = new SmartGraphPanel<>(graph, new SmartCircularSortedPlacementStrategy());
+ graphView = createGraphView(graph);
setSinkVertexCustomStyle();
return graphView;
}
- @Override
- public Collection> getVertexCollection()
+ private static SmartGraphPanel createGraphView(Graph graph)
{
- return vertexCollection;
+ try (InputStream resource = JavaFXClassVisualization.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES_PATH))
+ {
+ SmartGraphProperties properties = new SmartGraphProperties(resource);
+
+ URL url = JavaFXClassVisualization.class.getClassLoader().getResource(DEFAULT_STYLE_PATH);
+ URI cssFile = Objects.requireNonNull(url).toURI();
+
+ return new SmartGraphPanel<>(graph, properties, new SmartCircularSortedPlacementStrategy(), cssFile);
+ }
+ catch (IOException | URISyntaxException ignored)
+ {
+ // Fallback to default paths.
+ return new SmartGraphPanel<>(graph, new SmartCircularSortedPlacementStrategy());
+ }
}
@@ -55,10 +77,10 @@ private Graph createGraph()
directedGraph.insertVertex(classifierVertex.getName());
}
insertSinkVertexArcs(directedGraph);
+
return directedGraph;
}
-
private void insertSinkVertexArcs(Digraph directedGraph)
{
for (Set> arcs : classDiagram.getDiagram().values())
@@ -86,18 +108,22 @@ private void setSinkVertexCustomStyle()
{
for (ClassifierVertex classifierVertex : classDiagram.getDiagram().keySet())
{
- if (classifierVertex.getVertexType().equals(VertexType.INTERFACE))
- {
- graphView.getStylableVertex(classifierVertex.getName()).setStyleClass("vertexInterface");
- }
- else
- {
- graphView.getStylableVertex(classifierVertex.getName()).setStyleClass("vertexPackage");
- }
+ String styleClass = classifierVertex.getVertexType().equals(VertexType.INTERFACE) ?
+ "vertexInterface" :
+ "vertexPackage";
+
+ graphView.getStylableVertex(classifierVertex.getName()).setStyleClass(styleClass);
}
}
+ @Override
+ public Collection> getVertexCollection()
+ {
+ return vertexCollection;
+ }
+
+
@Override
public SmartGraphPanel getLoadedGraph()
{