Grootheid.java 3.4 KB

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