Grootheid.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package weerstation;
  2. import java.util.ArrayList;
  3. /**
  4. * Dient als Parent voor alle grootheden en zorgt voor een constante interface
  5. *
  6. * @author Kenneth van Ewijk
  7. * @author Janco Kock
  8. */
  9. public class Grootheid
  10. {
  11. // instance variables - replace the example below with your own
  12. private double statics;
  13. private double max;
  14. private double min;
  15. private double current;
  16. private Periode period;
  17. ArrayList<Double> list = new ArrayList<Double>();
  18. //boolean to check if the variables are set
  19. private boolean max_min_check = false;
  20. private boolean current_check = false;
  21. private String statics_name = "";
  22. private String name = "";
  23. private String custom = "";
  24. //constructor
  25. public Grootheid(){
  26. }
  27. //getters & setters
  28. public double getCurrent() {
  29. return current;
  30. }
  31. public void setCurrent(double current) {
  32. current_check = true;
  33. this.current = current;
  34. }
  35. public double getMax() {
  36. return max;
  37. }
  38. public void setMax(double max) {
  39. this.max= Math.round(max * 100.0) / 100.0;;
  40. }
  41. public double getMin() {
  42. return min;
  43. }
  44. public void setMin(double min) {
  45. this.min = Math.round(min * 100.0) / 100.0;;
  46. }
  47. public double getStatics() {
  48. return statics;
  49. }
  50. public void setStatics(double statics) {
  51. this.statics = Math.round(statics * 100.0) / 100.0;
  52. }
  53. public String getName() {
  54. return name;
  55. }
  56. public void setName(String name) {
  57. this.name = name;
  58. }
  59. public Periode getPeriod() {
  60. return period;
  61. }
  62. public void setPeriod(Periode period) {
  63. this.period = period;
  64. }
  65. public void setStatics_name(String statics_name) {
  66. this.statics_name = statics_name;
  67. }
  68. public String getCustom() {
  69. return custom;
  70. }
  71. public void setCustom(String custom) {
  72. this.custom = custom;
  73. }
  74. //Methods
  75. public void maxMin(){
  76. max_min_check = true;
  77. setMax(calculate(StatisticsCalculator.max(list)));
  78. setMin(calculate(StatisticsCalculator.min(list)));
  79. }
  80. public void median(){
  81. setStatics_name("Mediaan: ");
  82. setStatics(calculate(StatisticsCalculator.median(list)));
  83. }
  84. public void modus(){
  85. setStatics_name("Modus: ");
  86. setStatics(calculate(StatisticsCalculator.modus(list)));
  87. }
  88. public void avg(){
  89. setStatics_name("Gemiddelde: ");
  90. setStatics(calculate(StatisticsCalculator.avg(list)));
  91. }
  92. public void afwijking(){
  93. setStatics_name("Afwijking: ");
  94. setStatics(calculate(StatisticsCalculator.afwijking(list)));
  95. }
  96. public void updateRecent(Measurement measurement1){
  97. }
  98. public void updatePeriod(ArrayList<Measurement> measurement2){
  99. }
  100. public void display(String periodname, Boolean p, Boolean s){
  101. GUIboard.clearLeft();
  102. GUIboard.clearRight();
  103. GUIboard.clearTop();
  104. GUIboard.clearBottom();
  105. if(current_check){
  106. GUIboard.writeUpperDigits(getCurrent());
  107. }
  108. if(max_min_check){
  109. GUIboard.writeLeftDigits(getMax());
  110. GUIboard.writeRightDigits(getMin());
  111. }
  112. if(!(statics_name == "")){
  113. GUIboard.writePageToMatrix(getName(), statics_name + getStatics(), periodname, p, s);
  114. }else if(!(custom == "")){
  115. GUIboard.writePageToMatrix(getName(), custom, periodname, p, s);
  116. }
  117. if(!(period == null)){
  118. GUIboard.writePageToMatrix(getName(), period.toString(), periodname, p, s);
  119. }
  120. }
  121. public void displayGraph()
  122. {
  123. GUIboard.writeGraphToMatrix(list, getMin(), getMax());
  124. }
  125. public double calculate(double value){
  126. return value;
  127. }
  128. }