diff --git a/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphPanel.java b/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphPanel.java index bd692f8..4dd45d1 100644 --- a/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphPanel.java +++ b/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphPanel.java @@ -652,6 +652,11 @@ private void initNodes() { addVertex(v); } + for (Vertex vertex : vertexNodes.keySet()) { + SmartGraphVertexNode v = vertexNodes.get(vertex); + + addVertexLabels(v); + } } private SmartGraphVertexNode createVertex(Vertex v, double x, double y) { @@ -693,18 +698,29 @@ private void addVertex(SmartGraphVertexNode v) { this.getChildren().add(v); String labelText = getVertexLabelFor(v.getUnderlyingVertex().element()); - - if (graphProperties.getUseVertexTooltip()) { + + if (graphProperties.getUseVertexTooltip()) { Tooltip t = new Tooltip(labelText); Tooltip.install(v, t); } + } + private void addVertexLabels(SmartGraphVertexNode v) { + + String labelText = getVertexLabelFor(v.getUnderlyingVertex().element()); + if (graphProperties.getUseVertexLabel()) { SmartLabel label = new SmartLabel(labelText); - label.addStyleClass("vertex-label"); + + javafx.scene.shape.Rectangle rect=new javafx.scene.shape.Rectangle(0,0,100,100); + rect.getStyleClass().add("vertex-label-rect"); + + this.getChildren().add(rect); this.getChildren().add(label); + v.attachLabel(label); + v.attachLabelRect(rect); } } @@ -827,6 +843,9 @@ The opposite vertex exists in the (di)graph, but we have not yet for (SmartGraphVertexNode v : newVertices) { addVertex(v); } + for (SmartGraphVertexNode v : newVertices) { + addVertexLabels(v); + } } } diff --git a/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphVertexNode.java b/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphVertexNode.java index c0db43a..fe315ca 100644 --- a/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphVertexNode.java +++ b/src/main/java/com/brunomnsilva/smartgraph/graphview/SmartGraphVertexNode.java @@ -76,6 +76,7 @@ public class SmartGraphVertexNode extends Group implements SmartGraphVertex