Category.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package classes;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import com.google.gson.annotations.Expose;
  5. /**
  6. * Class "Category" performs the functionality of listing elements into groups.
  7. * Each Category contains an ArrayList of CpsObjects, a name and a HashMap of
  8. * ObjIdx.
  9. *
  10. * @author Gruppe14
  11. *
  12. */
  13. public class Category {
  14. // objects: is a ArrayList of all Objects that belongs to the Category
  15. private ArrayList<AbstractCanvasObject> objects;
  16. // name: is a String chosen by the User
  17. @Expose
  18. private String name;
  19. // ObjIdx: Index of each Category that corresponds to the order in the tree
  20. private HashMap<String, Integer> objIdx;
  21. /**
  22. * Category Constructor.
  23. *
  24. * @param name name of the Category
  25. */
  26. public Category(String name) {
  27. setObjects(new ArrayList<AbstractCanvasObject>());
  28. setName(name);
  29. setObjIdx(new HashMap<String, Integer>());
  30. }
  31. /**
  32. * Getter for all CpsObjects.
  33. *
  34. * @return the objects
  35. */
  36. public ArrayList<AbstractCanvasObject> getObjects() {
  37. return objects;
  38. }
  39. /**
  40. * Set a new ArrayList of CpsObjects.
  41. *
  42. * @param objects
  43. * the objects to set
  44. */
  45. public void setObjects(ArrayList<AbstractCanvasObject> objects) {
  46. this.objects = objects;
  47. }
  48. /**
  49. * Getter the name of the Category.
  50. *
  51. * @return the name
  52. */
  53. public String getName() {
  54. return name;
  55. }
  56. /**
  57. * Set the name of the Category to a new one.
  58. *
  59. * @param name
  60. * the name to set
  61. */
  62. public void setName(String name) {
  63. this.name = name;
  64. }
  65. /**
  66. * Getter of the Objects in the Tree with their respective order.
  67. *
  68. * @return the objIdx
  69. */
  70. public HashMap<String, Integer> getObjIdx() {
  71. return objIdx;
  72. }
  73. /**
  74. * Set a new sequence of Objects in the tree.
  75. *
  76. * @param objIdx
  77. * the objIdx to set
  78. */
  79. public void setObjIdx(HashMap<String, Integer> objIdx) {
  80. this.objIdx = objIdx;
  81. }
  82. }