3030import com .brunomnsilva .smartgraph .graph .Vertex ;
3131import com .brunomnsilva .smartgraph .graphview .SmartCircularSortedPlacementStrategy ;
3232import com .brunomnsilva .smartgraph .graphview .SmartGraphPanel ;
33- import com .brunomnsilva .smartgraph .graphview .SmartGraphProperties ;
3433import javafx .application .Application ;
3534import javafx .scene .Scene ;
3635import javafx .stage .Stage ;
@@ -46,7 +45,8 @@ public class Main extends Application {
4645 public void start (Stage ignored ) {
4746
4847 Graph <City , Distance > distances = new GraphEdgeList <>();
49-
48+
49+ /* Vertex radius will be derived from the city's population */
5050 Vertex <City > prague = distances .insertVertex (new City ("Prague" , 1.3f ));
5151 Vertex <City > tokyo = distances .insertVertex (new City ("Tokyo" , 37.5f ));
5252 Vertex <City > beijing = distances .insertVertex (new City ("Beijing" , 21.5f ));
@@ -63,37 +63,25 @@ public void start(Stage ignored) {
6363 distances .insertEdge (prague , helsinky , new Distance (1845 ));
6464 distances .insertEdge (beijing , london , new Distance (8132 ));
6565
66- /* Only Java 15 allows for multi-line strings. */
67- String customProps = "edge.label = true" + "\n " + "edge.arrow = true" ;
68-
69- SmartGraphProperties properties = new SmartGraphProperties (customProps );
70-
71- SmartGraphPanel <City , Distance > graphView = new SmartGraphPanel <>(distances , properties , new SmartCircularSortedPlacementStrategy ());
72-
66+ SmartGraphPanel <City , Distance > graphView = new SmartGraphPanel <>(distances , new SmartCircularSortedPlacementStrategy ());
67+
7368 Scene scene = new Scene (new SmartGraphDemoContainer (graphView ), 1024 , 768 );
7469
7570 Stage stage = new Stage (StageStyle .DECORATED );
7671 stage .setTitle ("JavaFX SmartGraph City Distances" );
77- stage .setMinHeight (500 );
7872 stage .setMinWidth (800 );
73+ stage .setMinHeight (400 );
7974 stage .setScene (scene );
8075 stage .show ();
8176
8277 graphView .init ();
83-
84- //graphView.setAutomaticLayout(true);
85-
86- /* You can manually place vertices at any time. However, these are
87- absolute coordinates inside the container panel.
88- Careful choice of a panel's background image can allow you to overlay
89- the vertices over a, e.g., world map.
90- */
91- graphView .setVertexPosition (beijing , 100 , 100 );
92- graphView .setVertexPosition (helsinky , 924 , 100 );
93- graphView .setVertexPosition (london , 200 , 668 );
94- graphView .setVertexPosition (prague , 824 , 668 );
95- graphView .setVertexPosition (tokyo , 512 , 200 );
96- graphView .setVertexPosition (newYork , 512 , 400 );
78+
79+ graphView .setVertexPosition (beijing , 520 , 284 ); // Center-ish
80+ graphView .setVertexPosition (tokyo , 820 , 250 ); // Far right-top
81+ graphView .setVertexPosition (newYork , 150 , 600 ); // Far left-bottom
82+ graphView .setVertexPosition (london , 250 , 200 ); // Left-top
83+ graphView .setVertexPosition (prague , 450 , 600 ); // Center-bottom
84+ graphView .setVertexPosition (helsinky ,650 , 120 ); // Right-top
9785
9886 /*
9987 * This illustrates setting an image to the background of a node.
0 commit comments