-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControllerGraph.java
More file actions
131 lines (111 loc) · 3.79 KB
/
ControllerGraph.java
File metadata and controls
131 lines (111 loc) · 3.79 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.Pane;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Button;
import java.net.URL;
import java.util.ResourceBundle;
import java.io.IOException;
import javafx.scene.control.DatePicker;
import java.time.LocalDate;
import java.util.NoSuchElementException;
import javafx.scene.control.Label;
import java.util.Observable;
import java.util.Observer;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane; // Assuming rightPane is of type AnchorPane
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.time.format.DateTimeFormatter;
import javafx.scene.control.Alert;
public class ControllerGraph {
// Singleton pattern
private static ControllerGraph instance;
private int graphIdx;
@FXML
private AnchorPane graphMiniPanel;
// Declare other controllers
ControllerSubGraph controllerSubGraph;
// Declare the statistics class generator
Statistics statistics;
// Singleton getInstance() method
public static ControllerGraph getInstance() {
if (instance == null) {
instance = new ControllerGraph();
}
return instance;
}
/**
* This update method will accessed by ControllerMain
*/
public void updateCurrentPanel() {panelCycler(0);}
/**
* This sets the chosen pane and makes it load the chosen fxmlFile
*/
private <T> T loadPanel(String fxmlFile, Pane pane) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFile));
Node panel = loader.load();
pane.getChildren().setAll(panel);
return loader.getController();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private void panelCycler(int counter) {
if(counter == 0){
handlePanelOne(null);
}
else if(counter==1){
handlePanelTwo(null);
}
else if(counter==2){
handlePanelThree(null);
}
else if(counter==3){
handlePanelThree(null);
}
}
@FXML
private void incrementPanel(ActionEvent event) {
graphIdx += 1;
if(graphIdx>3){
graphIdx = 0;
}
panelCycler(graphIdx);
}
@FXML
private void decrementPanel(ActionEvent event) {
graphIdx -= 1;
if(graphIdx<0){
graphIdx = 3;
}
panelCycler(graphIdx);
}
@FXML
private void handlePanelOne(ActionEvent event) {
//statistics = statistics.getInstance();
controllerSubGraph.getInstance();
controllerSubGraph = (ControllerSubGraph) loadPanel("Graph1.fxml", graphMiniPanel);
controllerSubGraph.populateLineChart();
System.out.println("graphdebug");
//controllerSubGraph.updateStatistic("(Page 1) Total deaths in this period: " + statistics.totalDeath());
}
@FXML
private void handlePanelTwo(ActionEvent event) {
//statistics = statistics.getInstance();
//controllerSubGraph = (ControllerSubGraph) loadPanel("StatisticsTwo.fxml", graphMiniPanel);
//controllerSubGraph.updateStatistic("(Page 2) Average cases per day in this period: " + statistics.averageCases());
}
@FXML
private void handlePanelThree(ActionEvent event) {
//statistics = statistics.getInstance();
//controllerSubGraph = (ControllerSubGraph) loadPanel("StatisticsThree.fxml", graphMiniPanel);
//controllerSunGraph.updateStatistic("(Page 3) Average mobility: " + statistics.averageTransit());
}
}