Grootheid.java 3.6 KB

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