|
31 | 31 | import com.brunomnsilva.smartgraph.graphview.SmartCircularSortedPlacementStrategy; |
32 | 32 | import com.brunomnsilva.smartgraph.graphview.SmartGraphPanel; |
33 | 33 | import com.brunomnsilva.smartgraph.graphview.SmartGraphProperties; |
34 | | -import com.brunomnsilva.smartgraph.graphview.SmartGraphVertex; |
35 | 34 | import javafx.application.Application; |
36 | 35 | import javafx.scene.Scene; |
37 | 36 | import javafx.stage.Stage; |
@@ -95,11 +94,20 @@ public void start(Stage ignored) { |
95 | 94 | graphView.setVertexPosition(prague, 824, 668); |
96 | 95 | graphView.setVertexPosition(tokyo, 512, 200); |
97 | 96 | graphView.setVertexPosition(newYork, 512, 400); |
98 | | - |
99 | | - graphView.getStylableLabel(tokyo).setStyleInline("-fx-stroke: green; -fx-fill: green;"); |
100 | 97 |
|
101 | | - graphView.setVertexDoubleClickAction((SmartGraphVertex<City> graphVertex) -> { |
102 | | - graphVertex.addStyleClass("myVertex"); |
| 98 | + /* |
| 99 | + * This illustrates setting an image to the background of a node. |
| 100 | + * By default, the css class "vertex" is applied to all vertices. |
| 101 | + * Note that all inline styles have |
| 102 | + * priority over any properties set in css classes, even if they are applied cumulatively through |
| 103 | + * .addStyleClass(class). However, inline styles can be overwritten by using .setStyleInline(css); |
| 104 | + * also, when you use .setStyleClass(class), all previous styles will be discarded, including inline. |
| 105 | + */ |
| 106 | + graphView.getStylableVertex(tokyo).setStyleInline("-fx-fill: url(\"file:squares.jpg\");"); |
| 107 | + //graphVertex.setStyleInline("-fx-fill: red;"); //this will overwrite the property later on |
| 108 | + |
| 109 | + graphView.setVertexDoubleClickAction(graphVertex -> { |
| 110 | + graphVertex.setStyleClass("myVertex"); |
103 | 111 | }); |
104 | 112 |
|
105 | 113 | } |
|
0 commit comments