Model.java 21 KB

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