Control.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. package ui.controller;
  2. import java.awt.Point;
  3. import java.awt.datatransfer.UnsupportedFlavorException;
  4. import java.io.File;
  5. import java.io.IOException;
  6. import java.util.ArrayList;
  7. import java.util.Collection;
  8. import java.util.HashSet;
  9. import java.util.List;
  10. import java.util.Set;
  11. import java.util.stream.Collectors;
  12. import javax.swing.JFrame;
  13. import org.apache.commons.compress.archivers.ArchiveException;
  14. import com.google.gson.JsonParseException;
  15. import model.AbstractCanvasObject;
  16. import model.Edge;
  17. import model.GroupNode;
  18. import model.HolonElement;
  19. import model.HolonObject;
  20. import model.Node;
  21. import ui.model.Model;
  22. import ui.model.Model.FairnessModel;
  23. import ui.view.dialog.CreateTemplatePopUp;
  24. import ui.view.main.Category;
  25. import ui.view.main.GUI;
  26. import utility.events.Event;
  27. /**
  28. * The Class represents the controller in the model, controller view Pattern.
  29. *
  30. * @author Gruppe14
  31. */
  32. public class Control {
  33. private final MultiPurposeController multiPurposeController;
  34. private final CategoryController categoryController;
  35. private final ObjectController objectController;
  36. private final CanvasController canvasController;
  37. private final GlobalController globalController;
  38. private final SaveController saveController;
  39. private final LoadController loadController;
  40. private final AutoSaveController autoSaveController;
  41. private final NodeController nodeController;
  42. private final ClipboardController clipboardController;
  43. private Model model;
  44. private SimulationManager simulationManager;
  45. private String autosaveDir = "";
  46. private String categoryDir = "";
  47. private String otherDir = "";
  48. private String dimensionsFileName = "dimensions";
  49. private int rand;
  50. public Event OnCategoryChanged = new Event();
  51. public Event OnSelectionChanged = new Event();
  52. /**
  53. * Constructor.
  54. *
  55. * @param model the Model
  56. */
  57. public Control(Model model) {
  58. this.model = model;
  59. this.multiPurposeController = new MultiPurposeController(model);
  60. this.categoryController = new CategoryController(model, multiPurposeController, this);
  61. this.objectController = new ObjectController(model, multiPurposeController);
  62. this.canvasController = new CanvasController(model, multiPurposeController);
  63. this.globalController = new GlobalController(model);
  64. this.saveController = new SaveController(model);
  65. this.nodeController = new NodeController(model, canvasController, multiPurposeController);
  66. this.loadController = new LoadController(model, categoryController, canvasController, objectController,
  67. nodeController, multiPurposeController);
  68. this.simulationManager = new SimulationManager(model);
  69. this.autoSaveController = new AutoSaveController(model);
  70. this.clipboardController = new ClipboardController(model, saveController, loadController, canvasController,
  71. objectController, nodeController, this.simulationManager);
  72. autosaveDir = System.getProperty("user.home") + "/.config/HolonGUI/Autosave/";
  73. categoryDir = System.getProperty("user.home") + "/.config/HolonGUI/Category/";
  74. otherDir = System.getProperty("user.home") + "/.config/HolonGUI/Other/";
  75. File autoSave = new File(autosaveDir);
  76. File category = new File(categoryDir);
  77. File other = new File(otherDir);
  78. // deleteDirectory(dest);
  79. autoSave.mkdirs();
  80. category.mkdirs();
  81. other.mkdirs();
  82. createAutoRandom();
  83. tryAutoSave();
  84. }
  85. /**
  86. * Generate random number, so that every instance of the program has unique save
  87. * files
  88. */
  89. private void createAutoRandom() {
  90. rand = (int) (Math.random() * 1000);
  91. while (new File(autosaveDir + rand + (autoSaveController.getAutoSaveNr())).exists()) {
  92. rand = (int) Math.random() * 1000;
  93. }
  94. }
  95. /**
  96. * Delete a Directory.
  97. *
  98. * @param path to delete
  99. */
  100. public void deleteDirectory(File path) {
  101. if (path.exists()) {
  102. File[] files = path.listFiles();
  103. for (File file : files) {
  104. if (file.isDirectory()) {
  105. deleteDirectory(file);
  106. } else {
  107. if (file.getName().contains("" + rand))
  108. file.delete();
  109. }
  110. }
  111. // path.delete();
  112. }
  113. }
  114. /* Operations for searching */
  115. /**
  116. * Search for Object by ID.
  117. *
  118. * @param id the id of the Object
  119. * @return the CpsObject
  120. */
  121. public AbstractCanvasObject searchByID(int id) {
  122. return multiPurposeController.searchByID(id);
  123. }
  124. /**
  125. * Search for Object by ID in upperNode
  126. *
  127. * @param id the id of the Object
  128. * @return the CpsObject
  129. */
  130. public AbstractCanvasObject searchByIDUpperNode(int id, GroupNode upperNode) {
  131. return multiPurposeController.searchByIDUpperNode(id, upperNode);
  132. }
  133. public AbstractCanvasObject searchTracked(int id) {
  134. return multiPurposeController.searchByID(id);
  135. }
  136. /**
  137. * search for category.
  138. *
  139. * @param cat name of the Category
  140. * @return the Category
  141. */
  142. public Category searchCategory(String cat) {
  143. return multiPurposeController.searchCat(cat);
  144. }
  145. /* Operations for Categories and Objects */
  146. /**
  147. * init default category and objects.
  148. *
  149. * @throws IOException
  150. */
  151. public void resetCategorys() throws IOException {
  152. categoryController.initCategories();
  153. objectController.initHolonElements();
  154. saveCategory();
  155. }
  156. /**
  157. * Adds New Category into Model.
  158. *
  159. * @param cat name of the new Category
  160. * @throws IOException
  161. */
  162. public void addCategory(String cat) throws IOException {
  163. categoryController.addNewCategory(cat);
  164. saveCategory();
  165. }
  166. /**
  167. * Gives all Category as String
  168. *
  169. * @return a array of strings from all Categorys
  170. */
  171. public String[] getCategoriesStrings() {
  172. return ((ArrayList<String>) categoryController.getCategories().stream().map(c -> c.getName())
  173. .collect(Collectors.toList())).toArray(new String[categoryController.getCategories().size()]);
  174. }
  175. /**
  176. * Add new Holon Object to a Category.
  177. *
  178. * @param cat Category
  179. * @param obj New Object Name
  180. * @param list Array of Elements
  181. * @param img the image Path
  182. * @throws IOException
  183. */
  184. public void addObject(Category cat, String obj, List<HolonElement> list, String img) throws IOException {
  185. categoryController.addNewHolonObject(cat, obj, list, img);
  186. saveCategory();
  187. }
  188. /**
  189. * Add new Holon Switch to a Category.
  190. *
  191. * @param cat Category
  192. * @param obj New Object Name
  193. * @throws IOException
  194. */
  195. public void addSwitch(Category cat, String obj) throws IOException {
  196. categoryController.addNewHolonSwitch(cat, obj, "/Images/switch-on.png");
  197. saveCategory();
  198. }
  199. /**
  200. * delete a given Category.
  201. *
  202. * @param cat the Category
  203. * @throws IOException
  204. */
  205. public void deleteCategory(String cat) throws IOException {
  206. categoryController.deleteCategory(cat);
  207. saveCategory();
  208. }
  209. /**
  210. * Delete an Object from a Category.
  211. *
  212. * @param cat the Category
  213. * @param obj the Object
  214. * @throws IOException
  215. */
  216. public void delObjectCategory(String cat, String obj) throws IOException {
  217. categoryController.deleteObject(cat, obj);
  218. saveCategory();
  219. }
  220. /**
  221. * removes a selectedObject from selection.
  222. *
  223. * @param obj Cpsobject
  224. */
  225. public void removeObjectsFromSelection(Collection<AbstractCanvasObject> objects) {
  226. for (AbstractCanvasObject object : objects) {
  227. objectController.removeObjectFromSelection(object);
  228. }
  229. OnSelectionChanged.broadcast();
  230. }
  231. /**
  232. * removes a selectedObject from selection.
  233. *
  234. * @param obj Cpsobject
  235. */
  236. public void removeObjectFromSelection(AbstractCanvasObject obj) {
  237. objectController.removeObjectFromSelection(obj);
  238. OnSelectionChanged.broadcast();
  239. }
  240. /**
  241. * add an Object to selectedObject.
  242. *
  243. * @param obj AbstractCpsobject
  244. */
  245. public void addSelectedObject(AbstractCanvasObject obj) {
  246. objectController.addSelectedObject(obj);
  247. OnSelectionChanged.broadcast();
  248. }
  249. public void addSelectedObjects(Collection<AbstractCanvasObject> objects) {
  250. objectController.addSelectedObjects(objects);
  251. OnSelectionChanged.broadcast();
  252. }
  253. public void clearSelection() {
  254. if(!model.getSelectedObjects().isEmpty()) {
  255. model.getSelectedObjects().clear();
  256. OnSelectionChanged.broadcast();
  257. }
  258. }
  259. /**
  260. * This method is primarily for the multi-selection. It adds unselected objects
  261. * to the selection and Removes selected objects from the selection. Like the
  262. * normal OS Desktop selection.
  263. *
  264. * @param objects
  265. */
  266. public void toggleSelectedObjects(Collection<AbstractCanvasObject> objects) {
  267. Set<AbstractCanvasObject> intersection = new HashSet<>(objects);
  268. intersection.retainAll(model.getSelectedObjects());
  269. model.getSelectedObjects().addAll(objects);
  270. model.getSelectedObjects().removeAll(intersection);
  271. OnSelectionChanged.broadcast();
  272. }
  273. /* Operations for Canvas */
  274. /**
  275. * Add a new Object.
  276. *
  277. * @param object the Object
  278. */
  279. public void addObjectCanvas(AbstractCanvasObject object) {
  280. canvasController.addNewObject(object);
  281. calculateStateAndVisualForTimeStep(model.getActualTimeStep());
  282. if (!(object instanceof Node)) {
  283. tryAutoSave();
  284. }
  285. }
  286. /**
  287. * Deletes an CpsObject on the Canvas and its connections.
  288. *
  289. * @param obj AbstractCpsObject
  290. * @param save
  291. */
  292. public void delCanvasObject(AbstractCanvasObject obj, boolean save) {
  293. canvasController.deleteObjectOnCanvas(obj);
  294. if (obj instanceof GroupNode) {
  295. canvasController.bfsNodeCleaner((GroupNode) obj);
  296. }
  297. calculateStateAndVisualForCurrentTimeStep();
  298. if (save) {
  299. tryAutoSave();
  300. }
  301. }
  302. public void delCanvasObjects(Collection<AbstractCanvasObject> objects) {
  303. canvasController.deleteObjectsOnCanvas(objects);
  304. calculateStateAndVisualForCurrentTimeStep();
  305. tryAutoSave();
  306. }
  307. /**
  308. * Replaces {@code toBeReplaced} by {@code by} on the canvas
  309. *
  310. * @param toBeReplaced the object that will be replaced
  311. * @param by the object that will replace it
  312. */
  313. public void replaceCanvasObject(AbstractCanvasObject toBeReplaced, AbstractCanvasObject by) {
  314. canvasController.replaceObjectOnCanvas(toBeReplaced, by);
  315. tryAutoSave();
  316. }
  317. /**
  318. * Add an edge to the Canvas.
  319. *
  320. * @param edge the edge
  321. */
  322. public void addEdgeOnCanvas(Edge edge) {
  323. canvasController.addEdgeOnCanvas(edge);
  324. tryAutoSave();
  325. }
  326. /**
  327. * Removes an Edge from the Canvas.
  328. *
  329. * @param edge the edge to remove
  330. */
  331. public void removeEdgesOnCanvas(Edge edge) {
  332. canvasController.removeEdgesOnCanvas(edge);
  333. tryAutoSave();
  334. }
  335. /**
  336. * Set the selected Edge.
  337. *
  338. * @param edge that is selected
  339. */
  340. public void setSelecteEdge(Edge edge) {
  341. model.setSelectedEdge(edge);
  342. }
  343. /* Operations for Objects and Elements */
  344. /**
  345. * Add a new Element into a Object on the Canvas.
  346. *
  347. * @param objectId the Object ID
  348. * @param ele the Name of the Element
  349. * @param energy the Energy
  350. * @param elementId the Element ID
  351. */
  352. public void addElementCanvasObject(int objectId, String ele, float energy, int elementId) {
  353. objectController.addNewElementIntoCanvasObject(objectId, ele, energy, elementId);
  354. tryAutoSave();
  355. }
  356. /**
  357. * Add a new Element into a Object in Category.
  358. *
  359. * @param catName the Category
  360. * @param objName the Object
  361. * @param eleName the Element Name
  362. * @param amount the amount
  363. * @param energy the Energy
  364. */
  365. public void addElementCategoryObject(String catName, String objName, String eleName, float energy) {
  366. objectController.addNewElementIntoCategoryObject(catName, objName, eleName, energy);
  367. }
  368. /**
  369. * Returns SCALE.
  370. *
  371. * @return SCALE
  372. */
  373. public int getScale() {
  374. return globalController.getScale();
  375. }
  376. /**
  377. * Changes the value of SCALE and SCALEDIV2.
  378. *
  379. * @param s Scale
  380. */
  381. public void setScale(int s) {
  382. globalController.setScale(s);
  383. }
  384. /**
  385. * Returns SCALE Divided by 2.
  386. *
  387. * @return SCALE Divided by 2
  388. */
  389. public int getScaleDiv2() {
  390. return globalController.getScaleDiv2();
  391. }
  392. /**
  393. * sets the current Iteration.
  394. *
  395. * @param curit the current Iteration
  396. */
  397. public void setCurIteration(int curit) {
  398. globalController.setCurIteration(curit);
  399. // getGui().getTimePanel().getTimeSlider().setValue(curit);
  400. }
  401. /**
  402. * Writes the current State of the Modelling into a JSON File which can be
  403. * loaded.
  404. *
  405. * @param path the Path
  406. * @throws IOException exception
  407. */
  408. public void saveFile(String path) throws IOException, ArchiveException {
  409. saveController.writeSave(path);
  410. }
  411. /**
  412. * Reads the the Save File and load the state into the Model.
  413. *
  414. * @param path the Path
  415. * @throws IOException exception
  416. * @throws ArchiveException
  417. */
  418. public void loadFile(String path) throws IOException, ArchiveException {
  419. loadController.readSave(path);
  420. saveCategory();
  421. autoSave();
  422. }
  423. /**
  424. * Reads the Json File from Autosave
  425. *
  426. * @param path
  427. * @throws IOException
  428. */
  429. public void loadAutoSave(String path) throws IOException {
  430. loadController.readJson(path);
  431. }
  432. public ArrayList<Integer> loadSavedWindowDimensionsIfExistent() {
  433. try {
  434. return loadController.readWindowDimensions(otherDir + dimensionsFileName);
  435. } catch (Exception e) {
  436. return new ArrayList<>();
  437. }
  438. }
  439. /**
  440. * calculates the flow of the edges and the supply for objects for the current
  441. * Timestep.
  442. */
  443. public void calculateStateAndVisualForCurrentTimeStep() {
  444. calculateStateAndVisualForTimeStep(model.getActualTimeStep());
  445. }
  446. public void calculateStateOnlyForCurrentTimeStep() {
  447. simulationManager.calculateStateForTimeStep(model.getActualTimeStep(), false);
  448. }
  449. /**
  450. * calculates the flow of the edges and the supply for objects.
  451. *
  452. * @param x current Iteration
  453. */
  454. public void calculateStateAndVisualForTimeStep(int x) {
  455. simulationManager.calculateStateForTimeStep(x, true);
  456. updateOutliner();
  457. updateFlexWindow();
  458. this.updateCanvas();
  459. }
  460. /**
  461. * resets the whole State of the simulation including a reset of all Edges to
  462. * the default "is working" state
  463. */
  464. public void resetSimulation() {
  465. System.out.println("RESET SIMULATION");
  466. }
  467. /**
  468. * make an autosave.
  469. *
  470. * @throws IOException Exception
  471. */
  472. public void autoSave() throws IOException {
  473. autoSaveController.increaseAutoSaveNr();
  474. saveController.writeAutosave(autosaveDir + rand + autoSaveController.getAutoSaveNr());
  475. if (autoSaveController.allowed()) {
  476. new File(autosaveDir + rand + (autoSaveController.getAutoSaveNr() - globalController.getNumbersOfSaves()))
  477. .delete();
  478. }
  479. }
  480. public void tryAutoSave() {
  481. try {
  482. autoSave();
  483. } catch (IOException e) {
  484. e.printStackTrace();
  485. }
  486. }
  487. /**
  488. * find all old auto save files (with a file-name, that does not contain the
  489. * current rand)
  490. *
  491. * @return a list of files, that are not from the current run
  492. */
  493. public ArrayList<File> filterOldAutoSaveFiles() {
  494. File[] files = new File(autosaveDir).listFiles();
  495. ArrayList<File> oldAutoSaves = new ArrayList<>();
  496. for (File file : files) {
  497. if (!file.getName().contains(String.valueOf(rand)))
  498. oldAutoSaves.add(file);
  499. }
  500. return oldAutoSaves;
  501. }
  502. /**
  503. * deletes the old autosave files
  504. */
  505. public void deleteObsoleteAutoSaveFiles() {
  506. for (File file : filterOldAutoSaveFiles()) {
  507. file.delete();
  508. }
  509. }
  510. public void saveCategory() throws IOException {
  511. saveController.writeCategory(categoryDir + "Category.json");
  512. }
  513. public void savePosAndSizeOfWindow(int x, int y, int width, int height) throws IOException, ArchiveException {
  514. saveController.writeWindowStatus(otherDir + dimensionsFileName, x, y, width, height);
  515. }
  516. /**
  517. * Returns the undo save.
  518. *
  519. * @return the undo save
  520. */
  521. public String getUndoSave() {
  522. autoSaveController.decreaseAutoSaveNr();
  523. if (!new File(autosaveDir + rand + (autoSaveController.getAutoSaveNr())).exists()) {
  524. autoSaveController.increaseAutoSaveNr();
  525. }
  526. return autosaveDir + rand + (autoSaveController.getAutoSaveNr());
  527. }
  528. /**
  529. * Returns the redo save.
  530. *
  531. * @return the redo save
  532. */
  533. public String getRedoSave() {
  534. autoSaveController.increaseAutoSaveNr();
  535. if (!new File(autosaveDir + rand + (autoSaveController.getAutoSaveNr())).exists()) {
  536. autoSaveController.decreaseAutoSaveNr();
  537. // if it still does not exist, try old autosaves
  538. if (!new File(autosaveDir + rand + (autoSaveController.getAutoSaveNr())).exists()) {
  539. ArrayList<File> oldAutoSaves = filterOldAutoSaveFiles();
  540. if (oldAutoSaves.size() > 0) {
  541. return autosaveDir + oldAutoSaves.get(oldAutoSaves.size() - 1).getName();
  542. }
  543. }
  544. }
  545. return autosaveDir + rand + (autoSaveController.getAutoSaveNr());
  546. }
  547. /**
  548. * Getter for Model.
  549. *
  550. * @return the Model
  551. */
  552. public Model getModel() {
  553. return model;
  554. }
  555. /**
  556. * get the Simulation Manager.
  557. *
  558. * @return the Simulation Manager
  559. */
  560. public SimulationManager getSimManager() {
  561. return simulationManager;
  562. }
  563. /**
  564. * Set the timerSpeed.
  565. *
  566. * @param t interval in ms
  567. */
  568. public void setTimerSpeed(int t) {
  569. globalController.setTimerSpeed(t);
  570. }
  571. /**
  572. * Set the Canvas X Size.
  573. *
  574. * @param canvasX the cANVAS_X to set
  575. */
  576. public void setCanvasX(int canvasX) {
  577. globalController.setCanvasX(canvasX);
  578. tryAutoSave();
  579. }
  580. /**
  581. * Set the Canvas Y Size.
  582. *
  583. * @param canvasY the cANVAS_Y to set
  584. */
  585. public void setCanvasY(int canvasY) {
  586. globalController.setCanvasY(canvasY);
  587. tryAutoSave();
  588. }
  589. public void setMaxCapacity(float cap) {
  590. globalController.setMaxCapacity(cap);
  591. }
  592. // ========================== MANAGING TRACKED OBJECTS END ================
  593. /**
  594. * Controlling Nodes of Nodes
  595. */
  596. public void addUpperNode(String nodeName, GroupNode upperNode, ArrayList<AbstractCanvasObject> toGroup) {
  597. nodeController.doUpperNode(nodeName, upperNode, toGroup);
  598. tryAutoSave();
  599. }
  600. public void ungroupGroupNode(GroupNode node, GroupNode upperNode) {
  601. nodeController.undoUpperNode(node, upperNode);
  602. tryAutoSave();
  603. }
  604. public void addObjUpperNode(AbstractCanvasObject object, GroupNode upperNode) {
  605. nodeController.addObjectInUpperNode(object, upperNode, true);
  606. tryAutoSave();
  607. }
  608. public void delObjUpperNode(AbstractCanvasObject object, GroupNode upperNode) {
  609. nodeController.deleteObjectInUpperNode(object, upperNode);
  610. if (object instanceof GroupNode)
  611. canvasController.bfsNodeCleaner((GroupNode) object);
  612. tryAutoSave();
  613. }
  614. /**
  615. * Replaces {@code toBePlaced} by {@code by} in {@code upperNode}
  616. *
  617. * @param toBeReplaced
  618. * @param by
  619. * @param upperNode
  620. */
  621. public void replaceObjUpperNode(AbstractCanvasObject toBeReplaced, AbstractCanvasObject by, GroupNode upperNode) {
  622. nodeController.replaceObjectInUpperNode(toBeReplaced, by, upperNode);
  623. tryAutoSave();
  624. }
  625. /**
  626. * Get the number of HolonObjects in the given List
  627. *
  628. * @param list
  629. */
  630. public int getNumberHolonObjects(ArrayList<AbstractCanvasObject> list) {
  631. return objectController.getNumberHolonObjects(list);
  632. }
  633. /**
  634. * Copy all Selected Objects.
  635. */
  636. public void copy(GroupNode upperNode) {
  637. clipboardController.copy(upperNode);
  638. }
  639. public void paste(GroupNode upperNode, Point point)
  640. throws JsonParseException, UnsupportedFlavorException, IOException {
  641. clipboardController.paste(upperNode, point);
  642. OnSelectionChanged.broadcast();
  643. tryAutoSave();
  644. }
  645. public void cut(GroupNode upperNode) {
  646. clipboardController.cut(upperNode);
  647. OnSelectionChanged.broadcast();
  648. tryAutoSave();
  649. }
  650. /**
  651. * creates a new Template for the given cps Object
  652. *
  653. * @param cps Object, which should become a template
  654. * @param parentFrame
  655. */
  656. public void createTemplate(HolonObject cps, JFrame parentFrame) {
  657. CreateTemplatePopUp t = new CreateTemplatePopUp(cps, model, parentFrame, this);
  658. t.setVisible(true);
  659. }
  660. public void getObjectsInDepth() {
  661. clipboardController.getObjectsInDepth();
  662. }
  663. /**
  664. * Set the Background Image;
  665. *
  666. * @param imagePath Image Path
  667. * @param mode Image Mode
  668. * @param width Image custom width
  669. * @param height Image custom height
  670. */
  671. public void setBackgroundImage(String imagePath, int mode, int width, int height) {
  672. canvasController.setBackgroundImage(imagePath, mode, width, height);
  673. }
  674. /**
  675. * Sets show
  676. *
  677. * @param showSupplyBars wether the bars should be shown
  678. */
  679. public void setShowSupplyBars(boolean showSupplyBars) {
  680. globalController.setShowSupplyBars(showSupplyBars);
  681. }
  682. /**
  683. * Sets fairness Model
  684. *
  685. * @param fairnessModel that should be used.
  686. */
  687. public void setFairnessModel(FairnessModel fairnessModel) {
  688. globalController.setFairnessModel(fairnessModel);
  689. }
  690. public void updateOutliner() {
  691. this.canvasController.updateOutliner(simulationManager);
  692. }
  693. public void updateFlexWindow() {
  694. canvasController.updateFlexWindow();
  695. }
  696. public void updateCanvas() {
  697. canvasController.updateCanvas();
  698. }
  699. public GUI getGui() {
  700. return canvasController.getGui();
  701. }
  702. public void guiDisable(boolean state) {
  703. canvasController.guiDisable(state);
  704. }
  705. public void setGui(GUI gui) {
  706. canvasController.setGui(gui);
  707. }
  708. }