-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMenuPane.java
96 lines (80 loc) · 3.17 KB
/
MenuPane.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package graphvisualizer.containers;
import graphvisualizer.graphview.SmartGraphPanel;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import java.io.File;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MenuPane extends VBox {
private Button strongConnectivityButton;
private Button cycleDetectionButton;
private Button shortestPathButton;
private Button resetButton;
private Button addVertexButton;
private TextArea statusBox;
public MenuPane() {
setSpacing(40);
setAlignment(Pos.TOP_CENTER);
createButton();
createStatusBox();
loadStylesheet();
}
private void loadStylesheet() {
try {
getStylesheets().add(new File("menu.css").toURI().toURL().toExternalForm());
this.getStyleClass().add("menu");
} catch (MalformedURLException ex) {
Logger.getLogger(SmartGraphPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void createButton() {
strongConnectivityButton = new Button("STRONG CONNECTIVITY");
strongConnectivityButton.getStyleClass().add("function-button");
getChildren().add(strongConnectivityButton);
cycleDetectionButton = new Button("CYCLE DETECTION");
cycleDetectionButton.getStyleClass().add("function-button");
getChildren().add(cycleDetectionButton);
shortestPathButton = new Button("SHORTEST PATH");
shortestPathButton.getStyleClass().add("function-button");
getChildren().add(shortestPathButton);
addVertexButton = new Button("ADD VERTEX");
addVertexButton.getStyleClass().add("add-vertex-button");
getChildren().add(addVertexButton);
resetButton = new Button("RESET");
resetButton.getStyleClass().add("reset-button");
getChildren().add(resetButton);
}
private void createStatusBox() {
statusBox = new TextArea();
statusBox.setWrapText(true);
statusBox.setEditable(false);
statusBox.setFocusTraversable(false);
statusBox.getStyleClass().add("status-box");
getChildren().add(statusBox);
setVgrow(statusBox, Priority.ALWAYS);
}
public TextArea getStatusBox() {
return statusBox;
}
public void setStrongConnectivityButtonAction(EventHandler<ActionEvent> actionEvent) {
strongConnectivityButton.setOnAction(actionEvent);
}
public void setCycleDetectionButtonAction(EventHandler<ActionEvent> actionEvent) {
cycleDetectionButton.setOnAction(actionEvent);
}
public void setShortestPathButtonAction(EventHandler<ActionEvent> actionEvent) {
shortestPathButton.setOnAction(actionEvent);
}
public void setResetButtonAction(EventHandler<ActionEvent> actionEvent) {
resetButton.setOnAction(actionEvent);
}
public void setAddVertexButtonAction(EventHandler<ActionEvent> actionEvent) {
addVertexButton.setOnAction(actionEvent);
}
}