Model.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. package ui.model;
  2. import java.awt.Color;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.HashSet;
  6. import java.util.LinkedList;
  7. import java.util.List;
  8. import java.util.Set;
  9. import java.util.stream.Collectors;
  10. import com.google.gson.Gson;
  11. import com.google.gson.GsonBuilder;
  12. import TypeAdapter.AbstractCpsObjectAdapter;
  13. import TypeAdapter.ColorAdapter;
  14. import TypeAdapter.PairAdapter;
  15. import TypeAdapter.PositionAdapter;
  16. import classes.AbstractCanvasObject;
  17. import classes.Category;
  18. import classes.Edge;
  19. import classes.GroupNode;
  20. import classes.HolonElement;
  21. import classes.HolonObject;
  22. import classes.HolonSwitch;
  23. import classes.Node;
  24. import classes.Pair;
  25. import interfaces.GraphListener;
  26. import interfaces.ObjectListener;
  27. import utility.Vector2Int;
  28. /**
  29. * The Class Model is the class where everything is saved. All changes made to
  30. * the Data is managed via a controller.
  31. *
  32. * @author Gruppe14
  33. */
  34. public class Model {
  35. private static final int GRAPH_ITERATIONS = 100;
  36. // Global Variables
  37. private static int sCALE = 50; // Picture Scale
  38. private static int sCALEdIV2 = sCALE / 2;
  39. public String[] colNames = {"Field", "Information"};
  40. // Canvas Attributes
  41. private String imgPath = "";
  42. private int backgroundMode = 0;
  43. private int backgroundWidth = 0;
  44. private int backgroundHeight = 0;
  45. private int canvasX = 3000;
  46. private int canvasY = 3000;
  47. private int curIteration = 0;
  48. // ID of the Selected Object
  49. private HolonElement selectedHolonElement;
  50. private Edge selectedEdge;
  51. private Set<AbstractCanvasObject> selectedObjects = new HashSet<>();
  52. private Set<AbstractCanvasObject> clipboardObjects = new HashSet<>();
  53. private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
  54. // Capacity for Edge
  55. private float maxCapacity;
  56. private ArrayList<GraphListener> graphListeners = new ArrayList<GraphListener>();
  57. // Iteration Speed
  58. private int timerSpeed = 1000;
  59. private int selectedID = 0;
  60. // number of the current autosave
  61. private int autoSaveNr = -1;
  62. // number of max simultaneous autosaves
  63. private int numberOfSaves = 35;
  64. /** whether the supplyBars should be shown or not */
  65. private boolean showSupplyBars = true;
  66. /** the amount of iterations */
  67. private int iterations=100;
  68. /**
  69. * All implemented FairnessModels:<br>
  70. * {@link FairnessModel#MininumDemandFirst}<br>
  71. * {@link FairnessModel#AllEqual}
  72. */
  73. public enum FairnessModel{
  74. /**
  75. * One Element of each HolonObject will be powered first, starting with the
  76. * smallest Demand. If ale HolonObjects have an active Element, the
  77. * simulation will try to fully supply as many HolonObjects as possible.
  78. */
  79. MininumDemandFirst,
  80. /**
  81. * All HolonObjects will receive the same amount of energy.
  82. */
  83. AllEqual
  84. }
  85. /** the Fairness model in use */
  86. private FairnessModel fairnessModel = FairnessModel.MininumDemandFirst;
  87. /*
  88. * Array of all categories in the model. It is set by default with the
  89. * categories ENERGY, BUILDINGS and COMPONENTS
  90. */
  91. private ArrayList<Category> categories;
  92. /*
  93. * Array of all CpsObjects in our canvas. It is set by default as an empty
  94. * list.
  95. */
  96. private ArrayList<AbstractCanvasObject> objectsOnCanvas;
  97. private HashMap<String, Integer> cgIdx;
  98. private HashMap<Integer, Integer> cvsObjIdx;
  99. /*
  100. * Array of all CpsObjects in our canvas. It is set by default as an empty
  101. * list.
  102. */
  103. private ArrayList<Edge> edgesOnCanvas;
  104. private ArrayList<HolonObject> holonObjectsOnCanvas = new ArrayList<HolonObject>();
  105. private ArrayList<Node> nodesOnCanvas= new ArrayList<Node>();
  106. private ArrayList<HolonSwitch> switchsOnCanvas= new ArrayList<HolonSwitch>();
  107. private List<ObjectListener> objectListeners;
  108. private HashMap<Integer, GroupNode> hashcodeMap = new HashMap<>();
  109. private Gson gson;
  110. /**
  111. * Constructor for the model. It initializes the categories and
  112. * objectsOnCanvas by default values. Listeners are also initialized by
  113. * default values.
  114. */
  115. public Model() {
  116. setCategories(new ArrayList<>());
  117. setObjectsOnCanvas(new ArrayList<>());
  118. setEdgesOnCanvas(new ArrayList<>());
  119. setObjectListeners(new LinkedList<>());
  120. setCgIdx(new HashMap<>());
  121. setCvsObjIdx(new HashMap<>());
  122. setEleToDelete(new HashMap<>());
  123. initGson();
  124. }
  125. /**
  126. * Returns all Categories.
  127. *
  128. * @return the categories
  129. */
  130. public ArrayList<Category> getCategories() {
  131. return categories;
  132. }
  133. /**
  134. * Sets all Categories.
  135. *
  136. * @param categories the categories to set
  137. */
  138. public void setCategories(ArrayList<Category> categories) {
  139. this.categories = categories;
  140. }
  141. /**
  142. * Transform the Arraylist of categories into a string of all objectName
  143. * with a separation (',') between each name.
  144. *
  145. * @return String of all names separeted by ','
  146. */
  147. public String toStringCat() {
  148. String text = "";
  149. for (int i = 0; i < categories.size(); i++) {
  150. if (text.equals("")) {
  151. text = categories.get(i).getName();
  152. } else {
  153. text = text + ", " + categories.get(i).getName();
  154. }
  155. }
  156. return text;
  157. }
  158. /**
  159. * Returns all Objects on the Canvas.
  160. *
  161. * @return the objectsOnCanvas
  162. */
  163. public ArrayList<AbstractCanvasObject> getObjectsOnCanvas() {
  164. return objectsOnCanvas;
  165. }
  166. /**
  167. * Sets all Objects on the Canvas.
  168. *
  169. * @param objectsOnCanvas the objectsOnCanvas to set
  170. */
  171. public void setObjectsOnCanvas(ArrayList<AbstractCanvasObject> objectsOnCanvas) {
  172. this.objectsOnCanvas = objectsOnCanvas;
  173. }
  174. /**
  175. * Get all Edges on the Canvas.
  176. *
  177. * @return the edgesOnCanvas
  178. */
  179. public ArrayList<Edge> getEdgesOnCanvas() {
  180. return edgesOnCanvas;
  181. }
  182. /**
  183. * Sets the edges on the Canvas.
  184. *
  185. * @param arrayList the edgesOnCanvas to set
  186. */
  187. public void setEdgesOnCanvas(ArrayList<Edge> arrayList) {
  188. this.edgesOnCanvas = arrayList;
  189. }
  190. /**
  191. * Adds an Edge to The Canvas.
  192. *
  193. * @param edge the edgesOnCanvas to add
  194. */
  195. public void addEdgeOnCanvas(Edge edge) {
  196. this.edgesOnCanvas.add(edge);
  197. }
  198. /**
  199. * Remove an edge from the Canvas.
  200. *
  201. * @param edge the edge to remove
  202. */
  203. public void removeEdgesOnCanvas(Edge edge) {
  204. this.edgesOnCanvas.remove(edge);
  205. }
  206. /**
  207. * Returns the ObjectListener.
  208. *
  209. * @return the objectListeners
  210. */
  211. public List<ObjectListener> getObjectListeners() {
  212. return objectListeners;
  213. }
  214. /**
  215. * Sets the ObjectListener.
  216. *
  217. * @param linkedList the objectListeners to set
  218. */
  219. public void setObjectListeners(LinkedList<ObjectListener> linkedList) {
  220. this.objectListeners = linkedList;
  221. }
  222. /**
  223. * Returns the ID of the selected Object 0 = no Object is selected.
  224. *
  225. * @return ID
  226. */
  227. public int getSelectedObjectID() {
  228. return selectedID;
  229. }
  230. /**
  231. * Set the ID of the selected Object 0 = no Object is selected.
  232. *
  233. * @param id the ID
  234. */
  235. public void setSelectedObjectID(int id) {
  236. this.selectedID = id;
  237. }
  238. /**
  239. * Returns all selected Objects on the Canvas.
  240. *
  241. * @return The selected Objects
  242. */
  243. public Set<AbstractCanvasObject> getSelectedObjects() {
  244. return selectedObjects;
  245. }
  246. /**
  247. * Returns all selected Objects on the Canvas.
  248. *
  249. * @return The selected Objects
  250. */
  251. public void setSelectedCpsObjects(Set<AbstractCanvasObject> arr) {
  252. this.selectedObjects = arr;
  253. }
  254. /**
  255. * Returns the Selected Holon Element.
  256. *
  257. * @return selected Holon Element
  258. */
  259. public HolonElement getSelectedHolonElement() {
  260. return selectedHolonElement;
  261. }
  262. /**
  263. * Sets the Selecte HolonElement.
  264. *
  265. * @param selectedHolonElement that is Selected
  266. */
  267. public void setSelectedHolonElement(HolonElement selectedHolonElement) {
  268. this.selectedHolonElement = selectedHolonElement;
  269. }
  270. /**
  271. * Returns the sCale (Scale for the Images).
  272. *
  273. * @return sCALE
  274. */
  275. public int getScale() {
  276. return sCALE;
  277. }
  278. /**
  279. * Sets the Image Scale.
  280. *
  281. * @param scale for the image
  282. */
  283. public void setScale(int scale) {
  284. sCALE = scale;
  285. if ((sCALE & 1) == 0)
  286. sCALEdIV2 = sCALE / 2;
  287. else
  288. sCALEdIV2 = (sCALE + 1) / 2;
  289. }
  290. /**
  291. * Returns sCALEdIV2 (The Scale divided by 2).
  292. *
  293. * @return sCALEdIV2
  294. */
  295. public int getScaleDiv2() {
  296. return sCALEdIV2;
  297. }
  298. /**
  299. * Returns the maximum ITERATIONS.
  300. *
  301. * @return ITERATIONS
  302. */
  303. public int getIterations() {
  304. return iterations;
  305. }
  306. private void notifyGraphListeners() {
  307. for (GraphListener gl : graphListeners) {
  308. gl.repaintTree();
  309. }
  310. }
  311. /**
  312. * Returns cURiTERATION.
  313. *
  314. * @return cURiTERATION
  315. */
  316. public int getCurIteration() {
  317. return curIteration;
  318. }
  319. /**
  320. * sets the current Iteration.
  321. *
  322. * @param curIT the current Iteration
  323. */
  324. public void setCurIteration(int curIT) {
  325. this.curIteration = curIT;
  326. notifyGraphListeners();
  327. }
  328. /**
  329. * Returns the selected Edge.
  330. *
  331. * @return selectedEdge
  332. */
  333. public Edge getSelectedEdge() {
  334. return selectedEdge;
  335. }
  336. /**
  337. * Set the selected Edge.
  338. *
  339. * @param edge that is selected
  340. */
  341. public void setSelectedEdge(Edge edge) {
  342. this.selectedEdge = edge;
  343. }
  344. /**
  345. * Returns the Categorie Index.
  346. *
  347. * @return the cgIdx
  348. */
  349. public HashMap<String, Integer> getCgIdx() {
  350. return cgIdx;
  351. }
  352. /**
  353. * Sets the Categorie Index.
  354. *
  355. * @param cgIdx the cgIdx to set
  356. */
  357. public void setCgIdx(HashMap<String, Integer> cgIdx) {
  358. this.cgIdx = cgIdx;
  359. }
  360. /**
  361. * Returns the CanvasObject Index.
  362. *
  363. * @return the cvsObjIdx
  364. */
  365. public HashMap<Integer, Integer> getCvsObjIdx() {
  366. return cvsObjIdx;
  367. }
  368. /**
  369. * Sets the CanvasObject Index.
  370. *
  371. * @param cvsObjIdx the cvsObjIdx to set
  372. */
  373. public void setCvsObjIdx(HashMap<Integer, Integer> cvsObjIdx) {
  374. this.cvsObjIdx = cvsObjIdx;
  375. }
  376. /**
  377. * Returns the auto save Number.
  378. *
  379. * @return the auto save Number
  380. */
  381. public int getAutoSaveNr() {
  382. return autoSaveNr;
  383. }
  384. /**
  385. * Sets the auto save Number.
  386. *
  387. * @param autoSaveNr the auto save number
  388. */
  389. public void setAutoSaveNr(int autoSaveNr) {
  390. this.autoSaveNr = autoSaveNr;
  391. }
  392. /**
  393. * Returns the Number of Saves.
  394. *
  395. * @return the numberOfSaves
  396. */
  397. public int getNumberOfSaves() {
  398. return numberOfSaves;
  399. }
  400. /**
  401. * Set the Number of Saves.
  402. *
  403. * @param numberOfSaves the numberOfSaves to set
  404. */
  405. public void setNumberOfSaves(int numberOfSaves) {
  406. this.numberOfSaves = numberOfSaves;
  407. }
  408. /**
  409. * Returns all Objects in the Clipboard.
  410. *
  411. * @return Objects in the Clipboard
  412. */
  413. public Set<AbstractCanvasObject> getClipboradObjects() {
  414. return clipboardObjects;
  415. }
  416. /**
  417. * Sets the ClipboardObjects.
  418. *
  419. * @param c Array of Objects
  420. */
  421. public void setClipboradObjects(Set<AbstractCanvasObject> c) {
  422. this.clipboardObjects = c;
  423. }
  424. /**
  425. * @return the maxCapacity
  426. */
  427. public float getMaxCapacity() {
  428. return maxCapacity;
  429. }
  430. /**
  431. * @param maxCapacity the maxCapacity to set
  432. */
  433. public void setMaxCapacity(float maxCapacity) {
  434. this.maxCapacity = maxCapacity;
  435. }
  436. /**
  437. * get the Interval in ms between each Iteration.
  438. *
  439. * @return timerSpeed speed for the Iterations
  440. */
  441. public int getTimerSpeed() {
  442. return this.timerSpeed;
  443. }
  444. /**
  445. * Sets the Interval in ms between each Iteration.
  446. *
  447. * @param t speed for the Iterations
  448. */
  449. public void setTimerSpeed(int t) {
  450. this.timerSpeed = t;
  451. }
  452. /**
  453. * Get Canvas X Size.
  454. *
  455. * @return the cANVAS_X
  456. */
  457. public int getCanvasX() {
  458. return canvasX;
  459. }
  460. /**
  461. * Set Canvas X Size.
  462. *
  463. * @param canvasX the cANVAS_X to set
  464. */
  465. public void setCanvasX(int canvasX) {
  466. this.canvasX = canvasX;
  467. }
  468. /**
  469. * get Canvas Y size.
  470. *
  471. * @return the cANVAS_Y
  472. */
  473. public int getCanvasY() {
  474. return canvasY;
  475. }
  476. /**
  477. * Set Canvas Y size.
  478. *
  479. * @param canvasY the cANVAS_Y to set
  480. */
  481. public void setCanvasY(int canvasY) {
  482. this.canvasY = canvasY;
  483. }
  484. public HashMap<Integer, ArrayList<HolonElement>> getEleToDelete() {
  485. return this.eleToDelete;
  486. }
  487. //TODO eleToDelete is this necessary
  488. public void setEleToDelete(HashMap<Integer, ArrayList<HolonElement>> theHash) {
  489. this.eleToDelete = theHash;
  490. }
  491. public List<HolonElement> getAllHolonElemnts() {
  492. return getAllHolonObjectsOnCanvas().stream().flatMap(hO -> hO.getElements().stream()).collect(Collectors.toList());
  493. }
  494. public ArrayList<HolonObject> getAllHolonObjectsOnCanvas(){
  495. ArrayList<HolonObject> objectToReturn = new ArrayList<HolonObject>();
  496. getAllHolonObjectsRecursive(objectToReturn, getObjectsOnCanvas());
  497. return objectToReturn;
  498. }
  499. private void getAllHolonObjectsRecursive(ArrayList<HolonObject> addObjectsToThisList, List<AbstractCanvasObject> listOfObjectsToSearch){
  500. for(AbstractCanvasObject aCps : listOfObjectsToSearch) {
  501. if(aCps instanceof HolonObject) {
  502. addObjectsToThisList.add((HolonObject) aCps);
  503. }else if(aCps instanceof GroupNode){
  504. getAllHolonObjectsRecursive(addObjectsToThisList, ((GroupNode)aCps).getNodes());
  505. }
  506. }
  507. }
  508. public ArrayList<AbstractCanvasObject> getAllAbstractObjectsOnCanvas(){
  509. ArrayList<AbstractCanvasObject> objectToReturn = new ArrayList<AbstractCanvasObject>();
  510. getAllAsbtractObjectsRecursive(objectToReturn, getObjectsOnCanvas());
  511. return objectToReturn;
  512. }
  513. private void getAllAsbtractObjectsRecursive(ArrayList<AbstractCanvasObject> addObjectsToThisList, List<AbstractCanvasObject> listOfObjectsToSearch){
  514. for(AbstractCanvasObject aCps : listOfObjectsToSearch) {
  515. if(aCps instanceof GroupNode){
  516. getAllAsbtractObjectsRecursive(addObjectsToThisList, ((GroupNode)aCps).getNodes());
  517. }
  518. else{
  519. addObjectsToThisList.add(aCps);
  520. }
  521. }
  522. }
  523. /**
  524. * get all Switches
  525. */
  526. public ArrayList<HolonSwitch> getAllSwitches() {
  527. ArrayList<HolonSwitch> switches = new ArrayList<>();
  528. for (AbstractCanvasObject obj : getObjectsOnCanvas()) {
  529. if (obj instanceof HolonSwitch) {
  530. switches.add((HolonSwitch) obj);
  531. } else if (obj instanceof GroupNode) {
  532. getSwitchesRec(((GroupNode) obj).getNodes(), switches);
  533. }
  534. }
  535. return switches;
  536. }
  537. /**
  538. * get the Amount of Switches help function
  539. *
  540. * @param objects objects
  541. * @param switches List of switches
  542. */
  543. private ArrayList<HolonSwitch> getSwitchesRec(ArrayList<AbstractCanvasObject> objects,
  544. ArrayList<HolonSwitch> switches) {
  545. for (AbstractCanvasObject obj : objects) {
  546. if (obj instanceof HolonSwitch) {
  547. switches.add((HolonSwitch) obj);
  548. } else if (obj instanceof GroupNode) {
  549. getSwitchesRec(((GroupNode) obj).getNodes(), switches);
  550. }
  551. }
  552. return switches;
  553. }
  554. /**
  555. * Returns the Path for the background Image of the Canvas.
  556. *
  557. * @return imgPath the Path
  558. */
  559. public String getCanvasImagePath() {
  560. return imgPath;
  561. }
  562. /**
  563. * Set the Path for the background Image of the Canvas.
  564. *
  565. * @param path the Path
  566. */
  567. public void setCanvasImagePath(String path) {
  568. imgPath = path;
  569. }
  570. /**
  571. * Returns the mode for the background Image of the Canvas.
  572. * <p>
  573. * 0 take size of the Image 1 stretch the Image 2 Custom Image size
  574. *
  575. * @return backgroundMode the mode
  576. */
  577. public int getCanvasImageMode() {
  578. return backgroundMode;
  579. }
  580. /**
  581. * Set the mode for the background Image of the Canvas.
  582. * <p>
  583. * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
  584. *
  585. * @param mode the backgroundMode
  586. */
  587. public void setCanvasImageMode(int mode) {
  588. backgroundMode = mode;
  589. }
  590. /**
  591. * Returns the Custom width of the background Image of the Canvas.
  592. *
  593. * @return backgroundWidth the Width
  594. */
  595. public int getCanvasImageWidth() {
  596. return backgroundWidth;
  597. }
  598. /**
  599. * Set the Custom width of the background Image of the Canvas.
  600. *
  601. * @param width the Width
  602. */
  603. public void setCanvasImageWidth(int width) {
  604. backgroundWidth = width;
  605. }
  606. /**
  607. * Returns the Custom height of the background Image of the Canvas.
  608. *
  609. * @return backgroundHeight the height
  610. */
  611. public int getCanvasImageHeight() {
  612. return backgroundHeight;
  613. }
  614. /**
  615. * Set the Custom height of the background Image of the Canvas.
  616. *
  617. * @param height the height
  618. */
  619. public void setCanvasImageHeight(int height) {
  620. backgroundHeight = height;
  621. }
  622. /**
  623. * @return true if SupplyBars should be shown
  624. */
  625. public boolean getShowSupplyBars() {
  626. return showSupplyBars;
  627. }
  628. /**
  629. * @param showSupplyBars true if the SupplyBars should be shown
  630. */
  631. public void setShowSupplyBars(boolean showSupplyBars) {
  632. this.showSupplyBars = showSupplyBars;
  633. }
  634. /**
  635. * @param iterations the number of steps for this simulation
  636. */
  637. public void setIterations(int iterations){
  638. this.iterations=iterations;
  639. }
  640. /**
  641. * @return the fairnessModel
  642. */
  643. public FairnessModel getFairnessModel() {
  644. return fairnessModel;
  645. }
  646. /**
  647. * @param fairnessModel the fairnessModel to set
  648. */
  649. public void setFairnessModel(FairnessModel fairnessModel) {
  650. this.fairnessModel = fairnessModel;
  651. }
  652. public int getGraphIterations(){
  653. return GRAPH_ITERATIONS;
  654. }
  655. /**
  656. * Initialize the Gson with wanted parameters
  657. */
  658. private void initGson() {
  659. GsonBuilder builder = new GsonBuilder();
  660. builder.serializeNulls();
  661. builder.excludeFieldsWithoutExposeAnnotation();
  662. builder.setPrettyPrinting();
  663. builder.registerTypeAdapter(AbstractCanvasObject.class, new AbstractCpsObjectAdapter());
  664. builder.registerTypeAdapter(Vector2Int.class, new PositionAdapter());
  665. builder.registerTypeAdapter(Color.class, new ColorAdapter());
  666. builder.registerTypeAdapter(Pair.class, new PairAdapter());
  667. // use the builder and make a instance of the Gson
  668. this.setGson(builder.create());
  669. }
  670. /**
  671. * @return the gson
  672. */
  673. public Gson getGson() {
  674. return gson;
  675. }
  676. /**
  677. * @param gson the gson to set
  678. */
  679. public void setGson(Gson gson) {
  680. this.gson = gson;
  681. }
  682. /**
  683. * @return the hashcodeMap
  684. */
  685. public HashMap<Integer, GroupNode> getHashcodeMap() {
  686. return hashcodeMap;
  687. }
  688. /**
  689. * @param hashcodeMap the hashcodeMap to set
  690. */
  691. public void setHashcodeMap(HashMap<Integer, GroupNode> hashcodeMap) {
  692. this.hashcodeMap = hashcodeMap;
  693. }
  694. public ArrayList<HolonSwitch> getSwitchsOnCanvas() {
  695. return switchsOnCanvas;
  696. }
  697. public void setSwitchsOnCanvas(ArrayList<HolonSwitch> switchsOnCanvas) {
  698. this.switchsOnCanvas = switchsOnCanvas;
  699. }
  700. public ArrayList<Node> getNodesOnCanvas() {
  701. return nodesOnCanvas;
  702. }
  703. public void setNodesOnCanvas(ArrayList<Node> nodesOnCanvas) {
  704. this.nodesOnCanvas = nodesOnCanvas;
  705. }
  706. public ArrayList<HolonObject> getHolonObjectsOnCanvas() {
  707. return holonObjectsOnCanvas;
  708. }
  709. public void setHolonObjectsOnCanvas(ArrayList<HolonObject> holonObjectsOnCanvas) {
  710. this.holonObjectsOnCanvas = holonObjectsOnCanvas;
  711. }
  712. public void defineLists() {
  713. switchsOnCanvas.clear();
  714. nodesOnCanvas.clear();
  715. holonObjectsOnCanvas.clear();
  716. for(AbstractCanvasObject aCps : this.objectsOnCanvas) {
  717. if(aCps instanceof HolonObject)holonObjectsOnCanvas.add((HolonObject) aCps);
  718. else if(aCps instanceof Node)nodesOnCanvas.add((Node) aCps);
  719. else if(aCps instanceof HolonSwitch)switchsOnCanvas.add((HolonSwitch) aCps);
  720. }
  721. }
  722. }