CpsObject.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package classes;
  2. import java.awt.Color;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import ui.model.idCounter;
  6. public abstract class CpsObject {
  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. /* Where the Object is Stored */
  21. String sav;
  22. /* BorderColor the user sets */
  23. Color BorderColor = Color.WHITE;
  24. /* a Tag that can be used */
  25. ArrayList<Integer> tags;
  26. /**
  27. * Constructor for an CpsObejct with an unique ID
  28. */
  29. public CpsObject(String objName) {
  30. setObjName(objName);
  31. setName(objName);
  32. setImage("/Images/Dummy_House.png");
  33. }
  34. public CpsObject(CpsObject obj) {
  35. setObjName(obj.getObjName());
  36. setName(obj.getObjName());
  37. setConnections(new ArrayList<CpsEdge>());
  38. setPosition(new Position());
  39. setID(idCounter.nextId());
  40. setImage(obj.getImage());
  41. }
  42. /* Obj type */
  43. public String getObjName() {
  44. return objName;
  45. }
  46. public void setObjName(String objName) {
  47. this.objName = objName;
  48. }
  49. /* User defined Name */
  50. public String getName() {
  51. return name;
  52. }
  53. public void setName(String name) {
  54. this.name = name;
  55. }
  56. /* Unique ID number */
  57. public int getID() {
  58. return ID;
  59. }
  60. /**
  61. * @param iD
  62. * the iD to set
  63. */
  64. public void setID(int ID) {
  65. this.ID = ID;
  66. }
  67. /* Image path */
  68. public String getImage() {
  69. return image;
  70. }
  71. /**
  72. * @param image
  73. * the Image to set
  74. */
  75. public void setImage(String image) {
  76. this.image = image;
  77. }
  78. /**
  79. * @return the connections
  80. */
  81. public ArrayList<CpsEdge> getConnections() {
  82. return connections;
  83. }
  84. /**
  85. * @param arrayList
  86. * the connections to set
  87. */
  88. public void setConnections(ArrayList<CpsEdge> arrayList) {
  89. this.connections = arrayList;
  90. }
  91. /* Neighbors array */
  92. public ArrayList<CpsEdge> getConnectedTo() {
  93. return connections;
  94. }
  95. public void AddConnection(CpsEdge toConnect) {
  96. connections.add(toConnect);
  97. }
  98. public void setPosition(Position pos) {
  99. this.position = pos;
  100. }
  101. /* Position (x and Y) */
  102. public void setPosition(int x, int y) {
  103. setPosition(new Position(x, y));
  104. }
  105. public Position getPosition() {
  106. return position;
  107. }
  108. /**
  109. * @return the stored
  110. */
  111. public String getSav() {
  112. return sav;
  113. }
  114. /**
  115. * @param stored
  116. * the stored to set
  117. */
  118. public void setSav(String sav) {
  119. this.sav = sav;
  120. }
  121. /**
  122. * @return the BorderColor
  123. */
  124. public Color getBorderColor() {
  125. return BorderColor;
  126. }
  127. /**
  128. * @param Color
  129. * the Color to set
  130. */
  131. public void setConnections(Color color) {
  132. this.BorderColor = color;
  133. }
  134. public void addTag(int tag){
  135. this.tags.add(tag);
  136. }
  137. public ArrayList<Integer> getTag(){
  138. return tags;
  139. }
  140. public void resetTags(){
  141. this.tags = new ArrayList<Integer>();
  142. }
  143. public void setTags(ArrayList<Integer> tags){
  144. this.tags = tags;
  145. }
  146. }