HolonElement.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. package classes;
  2. import java.awt.Point;
  3. import java.util.LinkedList;
  4. public class HolonElement {
  5. /* Name of the gadget */
  6. String eleName;
  7. /* Quantity */
  8. int amount;
  9. /* Energy per gadget */
  10. float energy;
  11. /* If the gadget is working xor not (true xor false) */
  12. boolean active;
  13. /* Total Energy */
  14. float totalEnergy;
  15. /* Path of the image for the Obj. */
  16. String image;
  17. /* +: for Consumers and -: Producers */
  18. char sign;
  19. String sav;
  20. String obj;
  21. /*
  22. * Energy at each point of the graph with 50 predefined points. At the
  23. * beginning, it starts with all values at energy
  24. */
  25. float[] energyAt = new float[100];
  26. //Points on the UnitGraph
  27. LinkedList<Point> graphPoints = new LinkedList<>();
  28. public HolonElement(String eleName, float energy, int amount) {
  29. setEleName(eleName);
  30. setAmount(amount);
  31. setEnergy(energy);
  32. setActive(true);
  33. setSign(energy);
  34. setEnergyAt(energy);
  35. }
  36. public HolonElement(HolonElement element) {
  37. setEleName(element.getEleName());
  38. setAmount(element.getAmount());
  39. setEnergy(element.getEnergy());
  40. setActive(element.getActive());
  41. setSign(element.getEnergy());
  42. setEnergyAt(element.getEnergy());
  43. setSav("Canvas");
  44. setObj(element.getObj());
  45. }
  46. public float[] getEnergyAt() {
  47. return energyAt;
  48. }
  49. public void setEnergyAt(float energy) {
  50. for (int i = 0; i < 49; i++) {
  51. this.energyAt[i] = energy;
  52. }
  53. }
  54. public void setEnergyAt(int pos, float energy) {
  55. this.energyAt[pos] = energy;
  56. }
  57. /**
  58. * @return the name
  59. */
  60. public String getEleName() {
  61. return eleName;
  62. }
  63. /**
  64. * @param name
  65. * the name to set
  66. */
  67. public void setEleName(String name) {
  68. this.eleName = name;
  69. }
  70. /**
  71. * @return the amount
  72. */
  73. public int getAmount() {
  74. return amount;
  75. }
  76. /**
  77. * @param amount
  78. * the amount to set
  79. */
  80. public void setAmount(int amount) {
  81. this.amount = amount;
  82. }
  83. /**
  84. * @return the energy
  85. */
  86. public float getEnergy() {
  87. return energy;
  88. }
  89. /**
  90. * @param energy
  91. * the energy to set
  92. */
  93. public void setEnergy(float energy) {
  94. this.energy = energy;
  95. }
  96. /**
  97. * @return the active
  98. */
  99. public boolean getActive() {
  100. return active;
  101. }
  102. /**
  103. * @param active
  104. * the active to set
  105. */
  106. public void setActive(boolean active) {
  107. this.active = active;
  108. }
  109. /**
  110. * @return the image
  111. */
  112. public String getImage() {
  113. return image;
  114. }
  115. /**
  116. * @param image
  117. * the image to set
  118. */
  119. public void setImage(String image) {
  120. this.image = image;
  121. }
  122. /**
  123. * Multiply the amount of gadgets, given by the user, and the
  124. * consumption/production. If the switch isWorking is turned off for on
  125. * gadget, the energy of this gadget have to be subtracted
  126. *
  127. * @return totalEnergy (actual)
  128. */
  129. public float getTotalEnergy() {
  130. totalEnergy = ((float) amount) * energy;
  131. return totalEnergy;
  132. }
  133. /**
  134. * @return the sign
  135. */
  136. public char getSign() {
  137. return sign;
  138. }
  139. /**
  140. * @param energy
  141. * the sign to set
  142. */
  143. public void setSign(float energy) {
  144. if (energy < 0)
  145. this.sign = '-';
  146. else
  147. this.sign = '+';
  148. }
  149. /**
  150. * @return the stored
  151. */
  152. public String getSav() {
  153. return sav;
  154. }
  155. /**
  156. * @param stored the stored to set
  157. */
  158. public void setSav(String sav) {
  159. this.sav = sav;
  160. }
  161. /**
  162. * @return the obj
  163. */
  164. public String getObj() {
  165. return obj;
  166. }
  167. /**
  168. * @param obj the obj to set
  169. */
  170. public void setObj(String obj) {
  171. this.obj = obj;
  172. }
  173. /**
  174. * @return the Graph Points
  175. */
  176. public LinkedList<Point> getGraphPoints() {
  177. return graphPoints;
  178. }
  179. /**
  180. * @param points, the Graph points
  181. */
  182. public void setGraphPoints(LinkedList<Point> points) {
  183. this.graphPoints = points;
  184. }
  185. }