CpsObject.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package classes;
  2. import java.util.ArrayList;
  3. import Interfaces.ComparableObject;
  4. import javafx.util.Pair;
  5. import ui.model.idCounter;
  6. public abstract class CpsObject implements ComparableObject {
  7. /* Type of the Object */
  8. String objName;
  9. /* Name given by the user */
  10. String name;
  11. /* ID of the Obj. */
  12. int ID;
  13. /* Path of the image for the Obj. */
  14. String image;
  15. /* Array of neighbors */
  16. ArrayList<CpsEdge> connections;
  17. /* Position with a X and Y value */
  18. Position position;
  19. /* Energy input and output of each object in the grid */
  20. String stored;
  21. float energyIn;
  22. float energyOut;
  23. /**
  24. * Constructor for an CpsObejct with an unique ID
  25. */
  26. public CpsObject(String objName) {
  27. setObjName(objName);
  28. setName(objName);
  29. setImage("/Images/Dummy_House.png");
  30. }
  31. public CpsObject(CpsObject obj) {
  32. setObjName(obj.getObjName());
  33. setName(obj.getObjName());
  34. setConnections(new ArrayList<CpsEdge>());
  35. setPosition(new Position());
  36. setID(idCounter.nextId());
  37. setEnergyIn(obj.getEnergyIn());
  38. setEnergyOut(obj.getEnergyOut());
  39. setImage(obj.getImage());
  40. }
  41. /* Obj type */
  42. public String getObjName() {
  43. return objName;
  44. }
  45. public void setObjName(String objName) {
  46. this.objName = objName;
  47. }
  48. /* User defined Name */
  49. public String getName() {
  50. return name;
  51. }
  52. public void setName(String name) {
  53. this.name = name;
  54. }
  55. /* Unique ID number */
  56. public int getID() {
  57. return ID;
  58. }
  59. /**
  60. * @param iD
  61. * the iD to set
  62. */
  63. public void setID(int ID) {
  64. this.ID = ID;
  65. }
  66. /* Image path */
  67. public String getImage() {
  68. return image;
  69. }
  70. public void setImage(String image) {
  71. this.image = image;
  72. }
  73. /**
  74. * @return the connections
  75. */
  76. public ArrayList<CpsEdge> getConnections() {
  77. return connections;
  78. }
  79. /**
  80. * @param arrayList
  81. * the connections to set
  82. */
  83. public void setConnections(ArrayList<CpsEdge> arrayList) {
  84. this.connections = arrayList;
  85. }
  86. /* Neighbors array */
  87. public ArrayList<CpsEdge> getConnectedTo() {
  88. return connections;
  89. }
  90. public void AddConnection(CpsEdge toConnect) {
  91. connections.add(toConnect);
  92. }
  93. public void setPosition(Position pos) {
  94. this.position = pos;
  95. }
  96. /* Position (x and Y) */
  97. public void setPosition(int x, int y) {
  98. setPosition(new Position(x, y));
  99. }
  100. public Position getPosition() {
  101. return position;
  102. }
  103. /**
  104. * @return the stored
  105. */
  106. public String getStored() {
  107. return stored;
  108. }
  109. /**
  110. * @param stored the stored to set
  111. */
  112. public void setStored(String stored) {
  113. this.stored = stored;
  114. }
  115. /* Getter and Setters for the energy input and output */
  116. public float getEnergyIn() {
  117. return energyIn;
  118. }
  119. public void setEnergyIn(float energyIn) {
  120. this.energyIn = energyIn;
  121. }
  122. public float getEnergyOut() {
  123. return energyOut;
  124. }
  125. public void setEnergyOut(float energyOut) {
  126. this.energyOut = energyOut;
  127. }
  128. @Override
  129. public String getCompareName() {
  130. return objName;
  131. }
  132. }