Download this file

TacetDataPoint.java    70 lines (55 with data), 1.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
package emulation;
import java.util.ArrayList;
import net.sourceforge.openforecast.DataPoint;
public class TacetDataPoint implements DataPoint {
private long timestamp;
private double dependentValue;
private ArrayList<Datum> independentValues;
public TacetDataPoint(long timestamp, double dependentValue) {
this.timestamp = timestamp;
this.dependentValue = (double)dependentValue;
independentValues = new ArrayList<Datum>();
}
public TacetDataPoint() {
independentValues = new ArrayList<Datum>();
}
public long getTimestamp() {
return timestamp;
}
@Override
public boolean equals(DataPoint arg0) {
return false;
}
@Override
public double getDependentValue() {
return dependentValue;
}
@Override
public double getIndependentValue(String arg0) {
for(Datum d: independentValues) {
if (d.getTrackID().equals(arg0)) {
return d.getValue();
}
}
return 0;
}
@Override
public String[] getIndependentVariableNames() {
String[] names = new String[independentValues.size()];
int i = 0;
for(Datum d : independentValues) {
names[i] = d.getTrackID();
i++;
}
return names;
}
@Override
public void setDependentValue(double arg0) {
dependentValue = arg0;
}
@Override
public void setIndependentValue(String arg0, double arg1) {
Datum independentValue = new Datum(Long.parseLong(arg0), arg1);
independentValues.add(independentValue);
}
}