-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD_Line.java
More file actions
121 lines (109 loc) · 4 KB
/
D_Line.java
File metadata and controls
121 lines (109 loc) · 4 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package exponn;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author Suleman
*/
public class D_Line extends Application {
int person_count;
static ArrayList<People> g_ind_delays = new ArrayList<People>();
public static void setMyVariable(String myVariable) {
// MyClass.myVariable = myVariable;
//= myVariable;
}
public void bulao (ArrayList<People> g_ind , int count)
{
D_Line.g_ind_delays = g_ind;
System.out.println("bulao"+g_ind_delays.size());
person_count = count;
sort();
for(int i = 0 ; i < g_ind_delays.size() ; i++)
{ System.out.println(g_ind_delays.get(i).ab_ar_tm);
}
//launch(args);
}
public void sort()
{
Collections.sort(g_ind_delays, new Comparator<People>() {
@Override
public int compare(People c1, People c2) {
return Double.compare(c1.ab_ar_tm, c2.ab_ar_tm);
}
});
System.out.println("sorted");
}
public void main(String[] args) {
launch(args);
// System.out.println("main");
}
//@Override
public void start(Stage primaryStage ) {
CategoryAxis xAxis = new CategoryAxis();
NumberAxis yAxis = new NumberAxis();
LineChart lineChart = new LineChart(xAxis, yAxis);
System.out.println("size from start"+g_ind_delays.size());
lineChart.setData(getChartData());
lineChart.setTitle("Chart");
// g_ind_delays = g_ind;
StackPane root = new StackPane();
root.getChildren().add(lineChart);
primaryStage.setScene(new Scene(root, 1366, 768));
primaryStage.show();
}
private ObservableList<XYChart.Series<String, Double>> getChartData() {
double aValue = 10;
double cValue = 20;
// g_ind;
ObservableList<XYChart.Series<String, Double>> answer = FXCollections
.observableArrayList();
Series<String, Double> aSeries = new Series<String, Double>();
Series<String, Double> cSeries = new Series<String, Double>();
Series<String, Double> dSeries = new Series<String, Double>();
Series<String, Double> sSeries = new Series<String, Double>();
aSeries.setName("Absolute time");
cSeries.setName("Total delay per individual");
dSeries.setName("Ele-size");
sSeries.setName("Stay Time");
// sort();
System.out.println("person"+person_count);
System.out.println("size from getchar" + g_ind_delays.size());
//for(int i = 0 ; i < g_ind_delays.size() ; i++)
//{ System.out.println(g_ind_delays.get(i).ab_ar_tm);
// }
// Collections.sort(g_ind_delays, new Comparator<People>() {
// @Override
// public int compare(People c1, People c2) {
// return Double.compare(c1.ab_ar_tm, c2.ab_ar_tm);
// }
//});
for (int i = 0; i <g_ind_delays.size(); i++) {
aSeries.getData().add(new XYChart.Data(Integer.toString(i),g_ind_delays.get(i).ab_ar_tm));
//aValue = aValue + Math.random()*100 -50;
// System.out.println("tot"+g_ind_delays.get(0).e_size);
cSeries.getData().add(new XYChart.Data(Integer.toString(i), g_ind_delays.get(i).tot_delay));
// cValue = cValue + Math.random()*100 -50 ;
dSeries.getData().add(new XYChart.Data(Integer.toString(i), g_ind_delays.get(i).e_size));
sSeries.getData().add(new XYChart.Data(Integer.toString(i), g_ind_delays.get(i).stay_time));
}
answer.addAll(aSeries, cSeries, dSeries, sSeries);
return answer;
}
}