Skip to content

Commit dbb1a1a

Browse files
committed
Update example usage.
1 parent 65a54ec commit dbb1a1a

6 files changed

Lines changed: 40 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Propagation of hover events to labels and arrows (can be styled);
88
- 🎉 Improve edge readability (issue #43) by changing the label underlying representation to a StackPane. Labels now accept CSS styles for Pane (background) and Text (the label itself).
99
- ⚠️ Fixed a regression that affected the movement of vertices.
10-
- ...
10+
- Other small fixes and improvements.
1111

1212
- (2.1.0) Notable changes:
1313

assets/smartgraph_realtime.gif

3.02 MB
Loading

smartgraph.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ This should help you understand which styles you can apply.
3333

3434
.vertex-label {
3535
-fx-font: bold 8pt "sans-serif";
36+
-fx-padding: 5px;
37+
}
38+
39+
.vertex-label:hover {
40+
-fx-background-color: white;
41+
-fx-background-radius: 5;
42+
-fx-border-color: black;
3643
}
3744

3845
.edge {
@@ -50,6 +57,17 @@ This should help you understand which styles you can apply.
5057

5158
.edge-label {
5259
-fx-font: normal 5pt "sans-serif";
60+
-fx-fill: white;
61+
-fx-background-color: red;
62+
-fx-background-radius: 0;
63+
-fx-border-color: black;
64+
-fx-padding: 2px;
65+
}
66+
67+
.edge-label:hover {
68+
-fx-font: bold 5pt "sans-serif";
69+
-fx-background-radius: 5;
70+
-fx-border-radius: 5;
5371
}
5472

5573
/* Since version 2.0.0-rc2 this style is cumulatively applied to arrows, after the "edge" class.

smartgraph.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ vertex.label = true
6565
# Edge related configurations
6666
#
6767
edge.tooltip = true
68-
edge.label = false
68+
edge.label = true
6969
# only makes sense if displaying a directed graph
7070
edge.arrow = true
7171

src/main/java/com/brunomnsilva/smartgraph/Main.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ public void start(Stage ignored) {
8181
stage.setScene(scene);
8282
stage.show();
8383

84+
85+
// Programmatically define the shape of a vertex. Uncomment to test
86+
/*graphView.setVertexShapeTypeProvider(new SmartShapeTypeProvider<String>() {
87+
@Override
88+
public String valueFor(String vertexElement) {
89+
if(vertexElement.equalsIgnoreCase("V03")) return "triangle";
90+
return "circle";
91+
}
92+
});*/
93+
8494
/*
8595
IMPORTANT: Must call init() after scene is displayed, so we can have width and height values
8696
to initially place the vertices according to the placement strategy.
@@ -130,10 +140,10 @@ public void start(Stage ignored) {
130140
/*
131141
Uncomment lines to test adding of new elements
132142
*/
133-
//continuously_test_adding_elements(g, graphView);
134-
//stage.setOnCloseRequest(event -> {
135-
// running = false;
136-
//});
143+
/*continuously_test_adding_elements(g, graphView);
144+
stage.setOnCloseRequest(event -> {
145+
running = false;
146+
});*/
137147
}
138148

139149
/**
@@ -248,11 +258,11 @@ private void continuously_test_adding_elements(Graph<String, String> g, SmartGra
248258
//underlying graph before styling a node immediately after.
249259
graphView.updateAndWait();
250260

251-
//color new vertices
252-
SmartStylableNode stylableVertex = graphView.getStylableVertex(vertexId);
253-
if(stylableVertex != null) {
254-
stylableVertex.setStyleInline("-fx-fill: orange;");
255-
}
261+
//color new vertices, uncomment
262+
//SmartStylableNode stylableVertex = graphView.getStylableVertex(vertexId);
263+
//if(stylableVertex != null) {
264+
// stylableVertex.setStyleInline("-fx-fill: orange;");
265+
//}
256266
} else {
257267
Vertex<String> existing1 = get_random_vertex(g);
258268
Vertex<String> existing2 = get_random_vertex(g);

src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
exports com.brunomnsilva.smartgraph.containers;
1212
exports com.brunomnsilva.smartgraph.graph;
1313
exports com.brunomnsilva.smartgraph.graphview;
14+
exports com.brunomnsilva.smartgraph.example;
1415
}

0 commit comments

Comments
 (0)