Added support for graphs

Also added small bits of code to center the name on the matrix display.
This commit is contained in:
Kenneth van Ewijk
2014-10-11 20:05:47 +02:00
parent a0c37c1a23
commit eb3718cc0b
12 changed files with 311 additions and 171 deletions
+24 -12
View File
@@ -1,32 +1,44 @@
import java.util.ArrayList;
public class AvgWindspeed extends Grootheid{
public class AvgWindSpeed extends Grootheid{
public ArrayList<Double> list;
//constructor
public AvgWindspeed(Measurement measurement1, ArrayList<Measurement> measurement2){
public AvgWindSpeed(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
update24Hour(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getAvgWindSpeed());
}
public void update24Hour(ArrayList<Measurement> measurement2){
ArrayList<Double> list = new ArrayList<Double>();
for(Measurement ms : measurement2)
{
list.add(ms.getAvgWindSpeed());
}
createList(measurement2);
calculateMaxMinAvg(list);
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Windsnelheid in m/s", "Gemiddelde: " + getAvg(), "");
GUIboard.writePageToMatrix("Gem. Windsnelheid", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
}
private void createList(ArrayList<Measurement> measurement2)
{
if(!list.isEmpty())
{
list.clear();
}
for(Measurement ms : measurement2)
{
list.add(ms.getAvgWindSpeed());
}
}
}