Model.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. package ui.model;
  2. import java.awt.Color;
  3. import java.awt.RenderingHints;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.LinkedList;
  7. import java.util.List;
  8. import javax.swing.JTable;
  9. import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
  10. import classes.Category;
  11. import classes.CpsEdge;
  12. import classes.CpsUpperNode;
  13. import classes.AbstractCpsObject;
  14. import classes.HolonElement;
  15. import classes.HolonObject;
  16. import classes.HolonSwitch;
  17. import interfaces.CategoryListener;
  18. import interfaces.GraphListener;
  19. import interfaces.ObjectListener;
  20. import ui.view.Console;
  21. import ui.view.DefaulTable;
  22. import ui.view.PropertyTable;
  23. import ui.view.DefaulTable;
  24. /**
  25. * The Class Model is the class where everything is saved. All changes made to
  26. * the Data is managed via a controller.
  27. *
  28. * @author Gruppe14
  29. *
  30. */
  31. public class Model {
  32. // Canvas Attributes
  33. private String imgPath = "";
  34. private int backgroundMode = 0;
  35. private int backgroundWidth = 0;
  36. private int backgroundHeight = 0;
  37. private int canvasX = 1000;
  38. private int canvasY = 1000;
  39. // Global Variables
  40. private static int sCALE = 50; // Picture Scale
  41. private static int sCALEdIV2 = sCALE / 2;
  42. private static int holonBodysCALE = 100; // Picture Scale
  43. private static final int ITERATIONS = 100;
  44. private int curIteration = 0;
  45. private LinkedList<Color> subNetColors = new LinkedList<>();
  46. // ID of the Selected Object
  47. private AbstractCpsObject selectedCpsObject = null;
  48. private HolonElement selectedHolonElement;
  49. private CpsEdge selectedEdge;
  50. private ArrayList<AbstractCpsObject> selectedObjects = new ArrayList<AbstractCpsObject>();
  51. private ArrayList<AbstractCpsObject> clipboardObjects = new ArrayList<AbstractCpsObject>();
  52. private Console console;
  53. private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
  54. // Capacity for Edge
  55. private float maxCapacity;
  56. // Table for HolonElements --> all cells are editable
  57. private JTable tableHolonElement;
  58. private ArrayList<GraphListener> graphListeners = new ArrayList<GraphListener>();
  59. // Iteration Speed
  60. private int timerSpeed = 1000;
  61. // Simulation boolean
  62. private boolean isSimulation = false;
  63. private int selectedID = 0;
  64. // number of the current autosave
  65. private int autoSaveNr = -1;
  66. // number of max simultaneous autosaves
  67. private int numberOfSaves = 35;
  68. /*
  69. * Array of all categories in the model. It is set by default with the
  70. * categories ENERGY, BUILDINGS and COMPONENTS
  71. */
  72. private ArrayList<Category> categories;
  73. /*
  74. * Array of all HolonObj and HolonSwitches, that should be tracked through
  75. * out the statistics tab
  76. */
  77. private ArrayList<AbstractCpsObject> trackedObjects;
  78. /*
  79. * Array of all CpsObjects in our canvas. It is set by default as an empty
  80. * list.
  81. */
  82. private ArrayList<AbstractCpsObject> objectsOnCanvas;
  83. private HashMap<String, Integer> cgIdx;
  84. private HashMap<Integer, Integer> cvsObjIdx;
  85. /*
  86. * Array of all CpsObjects in our canvas. It is set by default as an empty
  87. * list.
  88. */
  89. private ArrayList<CpsEdge> edgesOnCanvas;
  90. /*
  91. * Array for all Listeners
  92. */
  93. private List<CategoryListener> categoryListeners;
  94. private List<ObjectListener> objectListeners;
  95. private PropertyTable tableModelHolonElementMulti;
  96. private PropertyTable tableModelHolonElementSingle;
  97. private DefaulTable tableModelProperties;
  98. public String[] colNames = { "Field", "Information" };
  99. /*
  100. * Object that runs the Algorithm
  101. */
  102. private Object algorithm = null;
  103. private int selectedHolonBody;
  104. /**
  105. * Constructor for the model. It initializes the categories and
  106. * objectsOnCanvas by default values. Listeners are also initialized by
  107. * default values.
  108. */
  109. public Model() {
  110. setCategories(new ArrayList<Category>());
  111. setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
  112. setEdgesOnCanvas(new ArrayList<CpsEdge>());
  113. setCategoryListeners(new LinkedList<CategoryListener>());
  114. setObjectListeners(new LinkedList<ObjectListener>());
  115. setCgIdx(new HashMap<String, Integer>());
  116. setCvsObjIdx(new HashMap<Integer, Integer>());
  117. setClipboradObjects(new ArrayList<AbstractCpsObject>());
  118. setTrackingObj(new ArrayList<AbstractCpsObject>());
  119. setEleToDelete(new HashMap<Integer, ArrayList<HolonElement>>());
  120. setSingleTable(new PropertyTable());
  121. setMultiTable(new PropertyTable());
  122. setPropertyTable(new DefaulTable(1000, colNames.length));
  123. getPropertyTable().setColumnIdentifiers(colNames);
  124. setTableHolonElement(new JTable());
  125. }
  126. /**
  127. * Returns all Categories.
  128. *
  129. * @return the categories
  130. */
  131. public ArrayList<Category> getCategories() {
  132. return categories;
  133. }
  134. /**
  135. * Sets all Categories.
  136. *
  137. * @param categories
  138. * the categories to set
  139. */
  140. public void setCategories(ArrayList<Category> categories) {
  141. this.categories = categories;
  142. }
  143. /**
  144. * Transform the Arraylist of categories into a string of all objectName
  145. * with a separation (',') between each name.
  146. *
  147. * @return String of all names separeted by ','
  148. */
  149. public String toStringCat() {
  150. String text = "";
  151. for (int i = 0; i < categories.size(); i++) {
  152. if (text == "") {
  153. text = categories.get(i).getName();
  154. } else {
  155. text = text + ", " + categories.get(i).getName();
  156. }
  157. }
  158. return text;
  159. }
  160. /**
  161. * Returns all Objects on the Canvas.
  162. *
  163. * @return the objectsOnCanvas
  164. */
  165. public ArrayList<AbstractCpsObject> getObjectsOnCanvas() {
  166. return objectsOnCanvas;
  167. }
  168. /**
  169. * Sets all Objects on the Canvas.
  170. *
  171. * @param objectsOnCanvas
  172. * the objectsOnCanvas to set
  173. */
  174. public void setObjectsOnCanvas(ArrayList<AbstractCpsObject> objectsOnCanvas) {
  175. this.objectsOnCanvas = objectsOnCanvas;
  176. }
  177. /**
  178. * Get all Edges on the Canvas.
  179. *
  180. * @return the objectsOnCanvas
  181. */
  182. public ArrayList<CpsEdge> getEdgesOnCanvas() {
  183. return edgesOnCanvas;
  184. }
  185. /**
  186. * Adds an Edge to The Canvas.
  187. *
  188. * @param edge
  189. * the edgesOnCanvas to add
  190. */
  191. public void addEdgeOnCanvas(CpsEdge edge) {
  192. this.edgesOnCanvas.add(edge);
  193. }
  194. /**
  195. * Remove an edge from the Canvas.
  196. *
  197. * @param edge
  198. * the edge to remove
  199. */
  200. public void removeEdgesOnCanvas(CpsEdge edge) {
  201. this.edgesOnCanvas.remove(edge);
  202. }
  203. /**
  204. * Sets the edges on the Canvas.
  205. *
  206. * @param arrayList
  207. * the edgesOnCanvas to set
  208. */
  209. public void setEdgesOnCanvas(ArrayList<CpsEdge> arrayList) {
  210. this.edgesOnCanvas = arrayList;
  211. }
  212. /**
  213. * Returns the ObjectListener.
  214. *
  215. * @return the objectListeners
  216. */
  217. public List<ObjectListener> getObjectListeners() {
  218. return objectListeners;
  219. }
  220. /**
  221. * Sets the ObjectListener.
  222. *
  223. * @param linkedList
  224. * the objectListeners to set
  225. */
  226. public void setObjectListeners(LinkedList<ObjectListener> linkedList) {
  227. this.objectListeners = linkedList;
  228. }
  229. /**
  230. * Returns the CategorieListener.
  231. *
  232. * @return the categoryListeners
  233. */
  234. public List<CategoryListener> getCategoryListeners() {
  235. return categoryListeners;
  236. }
  237. /**
  238. * Sets the CategorieListener.
  239. *
  240. * @param linkedList
  241. * the categoryListeners to set
  242. */
  243. public void setCategoryListeners(LinkedList<CategoryListener> linkedList) {
  244. this.categoryListeners = linkedList;
  245. }
  246. /**
  247. * Set the ID of the selected Object 0 = no Object is selected.
  248. *
  249. * @param id
  250. * the ID
  251. *
  252. */
  253. public void setSelectedObjectID(int id) {
  254. this.selectedID = id;
  255. }
  256. /**
  257. * Returns the ID of the selected Object 0 = no Object is selected.
  258. *
  259. * @return ID
  260. */
  261. public int getSelectedObjectID() {
  262. return selectedID;
  263. }
  264. /**
  265. * Returns the Selected Cps Object.
  266. *
  267. * @return selected Cps Object
  268. */
  269. public AbstractCpsObject getSelectedCpsObject() {
  270. return selectedCpsObject;
  271. }
  272. /**
  273. * Set the Selected Objecs.
  274. *
  275. * @param selectedCpsObject
  276. * Objects that are selected
  277. */
  278. public void setSelectedCpsObject(AbstractCpsObject selectedCpsObject) {
  279. this.selectedCpsObject = selectedCpsObject;
  280. }
  281. /**
  282. * Returns all selected Objects on the Canvas.
  283. *
  284. * @return The selected Objects
  285. */
  286. public ArrayList<AbstractCpsObject> getSelectedCpsObjects() {
  287. return selectedObjects;
  288. }
  289. /**
  290. * Returns all selected Objects on the Canvas.
  291. *
  292. * @return The selected Objects
  293. */
  294. public void setSelectedCpsObjects(ArrayList<AbstractCpsObject> arr) {
  295. this.selectedObjects = arr;
  296. }
  297. /**
  298. * Returns the Selected Holon Element.
  299. *
  300. * @return selected Holon Element
  301. */
  302. public HolonElement getSelectedHolonElement() {
  303. return selectedHolonElement;
  304. }
  305. /**
  306. * Sets the Selecte HolonElement.
  307. *
  308. * @param selectedHolonElement
  309. * that is Selected
  310. */
  311. public void setSelectedHolonElement(HolonElement selectedHolonElement) {
  312. this.selectedHolonElement = selectedHolonElement;
  313. }
  314. /**
  315. * Returns the sCale (Scale for the Images).
  316. *
  317. * @return sCALE
  318. */
  319. public int getScale() {
  320. return sCALE;
  321. }
  322. /**
  323. * Returns sCALEdIV2 (The Scale divided by 2).
  324. *
  325. * @return sCALEdIV2
  326. */
  327. public int getScaleDiv2() {
  328. return sCALEdIV2;
  329. }
  330. /**
  331. * Sets the Image Scale.
  332. *
  333. * @param scale
  334. * for the image
  335. */
  336. public void setScale(int scale) {
  337. sCALE = scale;
  338. sCALEdIV2 = sCALE / 2;
  339. }
  340. /**
  341. * Returns ITERATIONS.
  342. *
  343. * @return ITERATIONS
  344. */
  345. public int getIterations() {
  346. return ITERATIONS;
  347. }
  348. /**
  349. * sets the current Iteration.
  350. *
  351. * @param curIT
  352. * the current Iteration
  353. */
  354. public void setCurIteration(int curIT) {
  355. this.curIteration = curIT;
  356. notifyGraphListeners();
  357. }
  358. private void notifyGraphListeners() {
  359. for (GraphListener gl : graphListeners) {
  360. gl.repaintTree();
  361. }
  362. }
  363. /**
  364. * Returns cURiTERATION.
  365. *
  366. * @return cURiTERATION
  367. */
  368. public int getCurIteration() {
  369. return curIteration;
  370. }
  371. /**
  372. * Set the selected Edge.
  373. *
  374. * @param edge
  375. * that is selected
  376. *
  377. */
  378. public void setSelectedEdge(CpsEdge edge) {
  379. this.selectedEdge = edge;
  380. }
  381. /**
  382. * Returns the selected Edge.
  383. *
  384. * @return selectedEdge
  385. */
  386. public CpsEdge getSelectedEdge() {
  387. return selectedEdge;
  388. }
  389. /**
  390. * Returns the Categorie Index.
  391. *
  392. * @return the cgIdx
  393. */
  394. public HashMap<String, Integer> getCgIdx() {
  395. return cgIdx;
  396. }
  397. /**
  398. * Sets the Categorie Index.
  399. *
  400. * @param cgIdx
  401. * the cgIdx to set
  402. */
  403. public void setCgIdx(HashMap<String, Integer> cgIdx) {
  404. this.cgIdx = cgIdx;
  405. }
  406. /**
  407. * Returns the CanvasObject Index.
  408. *
  409. * @return the cvsObjIdx
  410. */
  411. public HashMap<Integer, Integer> getCvsObjIdx() {
  412. return cvsObjIdx;
  413. }
  414. /**
  415. * Sets the CanvasObject Index.
  416. *
  417. * @param cvsObjIdx
  418. * the cvsObjIdx to set
  419. */
  420. public void setCvsObjIdx(HashMap<Integer, Integer> cvsObjIdx) {
  421. this.cvsObjIdx = cvsObjIdx;
  422. }
  423. /**
  424. * Sets the auto save Number.
  425. *
  426. * @param autoSaveNr
  427. * the auto save number
  428. */
  429. public void setAutoSaveNr(int autoSaveNr) {
  430. this.autoSaveNr = autoSaveNr;
  431. }
  432. /**
  433. * Returns the auto save Number.
  434. *
  435. * @return the auto save Number
  436. */
  437. public int getAutoSaveNr() {
  438. return autoSaveNr;
  439. }
  440. /**
  441. * Returns the Number of Saves.
  442. *
  443. * @return the numberOfSaves
  444. */
  445. public int getNumberOfSaves() {
  446. return numberOfSaves;
  447. }
  448. /**
  449. * Set the Number of Saves.
  450. *
  451. * @param numberOfSaves
  452. * the numberOfSaves to set
  453. */
  454. public void setNumberOfSaves(int numberOfSaves) {
  455. this.numberOfSaves = numberOfSaves;
  456. }
  457. /**
  458. * Sets the ClipboardObjects.
  459. *
  460. * @param c
  461. * Array of Objects
  462. */
  463. public void setClipboradObjects(ArrayList<AbstractCpsObject> c) {
  464. this.clipboardObjects = c;
  465. }
  466. /**
  467. * Returns all Objects in the Clipboard.
  468. *
  469. * @return Objects in the Clipboard
  470. */
  471. public ArrayList<AbstractCpsObject> getClipboradObjects() {
  472. return clipboardObjects;
  473. }
  474. /**
  475. * Sets the console.
  476. *
  477. * @param console
  478. * the console
  479. */
  480. public void setConsole(Console console) {
  481. this.console = console;
  482. }
  483. /**
  484. * Returns the Console.
  485. *
  486. * @return console the console
  487. */
  488. public Console getConsole() {
  489. return console;
  490. }
  491. /**
  492. * @return the maxCapacity
  493. */
  494. public float getMaxCapacity() {
  495. return maxCapacity;
  496. }
  497. /**
  498. * @param maxCapacity
  499. * the maxCapacity to set
  500. */
  501. public void setMaxCapacity(float maxCapacity) {
  502. this.maxCapacity = maxCapacity;
  503. }
  504. /**
  505. * Sets the Interval in ms between each Iteration.
  506. *
  507. * @param t
  508. * speed for the Iterations
  509. */
  510. public void setTimerSpeed(int t) {
  511. this.timerSpeed = t;
  512. }
  513. /**
  514. * get the Interval in ms between each Iteration.
  515. *
  516. * @return timerSpeed speed for the Iterations
  517. */
  518. public int getTimerSpeed() {
  519. return this.timerSpeed;
  520. }
  521. /**
  522. * Sets the Simulation state (true = simulation, false = modeling).
  523. *
  524. * @param isSimulation
  525. * boolean for for isSimulation
  526. */
  527. public void setIsSimulation(boolean isSimulation) {
  528. this.isSimulation = isSimulation;
  529. }
  530. /**
  531. * Returns the Simulation state (true = simulation, false = modeling).
  532. *
  533. * @return isSimulation boolean for for isSimulation
  534. */
  535. public boolean getIsSimulation() {
  536. return this.isSimulation;
  537. }
  538. /**
  539. * Get Canvas X Size.
  540. *
  541. * @return the cANVAS_X
  542. */
  543. public int getCanvasX() {
  544. return canvasX;
  545. }
  546. /**
  547. * Set Canvas X Size.
  548. *
  549. * @param canvasX
  550. * the cANVAS_X to set
  551. */
  552. public void setCanvasX(int canvasX) {
  553. this.canvasX = canvasX;
  554. }
  555. /**
  556. * get Canvas Y size.
  557. *
  558. * @return the cANVAS_Y
  559. */
  560. public int getCanvasY() {
  561. return canvasY;
  562. }
  563. /**
  564. * Set Canvas Y size.
  565. *
  566. * @param canvasY
  567. * the cANVAS_Y to set
  568. */
  569. public void setCanvasY(int canvasY) {
  570. this.canvasY = canvasY;
  571. }
  572. /**
  573. * get the Algorithm.
  574. *
  575. * @return the Algorithm
  576. */
  577. public Object getAlgorithm() {
  578. return algorithm;
  579. }
  580. /**
  581. * Set the Algorithm.
  582. *
  583. * @param obj
  584. * the Algorithm
  585. */
  586. public void setAlgorithm(Object obj) {
  587. this.algorithm = null;
  588. this.algorithm = obj;
  589. }
  590. /**
  591. * Add a SubNetColor.
  592. *
  593. * @param c
  594. * the Color
  595. */
  596. public void addSubNetColor(Color c) {
  597. this.subNetColors.add(c);
  598. }
  599. /**
  600. * Get the SubNetColors.
  601. *
  602. * @return SubNetColors
  603. */
  604. public LinkedList<Color> getSubNetColors() {
  605. return this.subNetColors;
  606. }
  607. public void setTrackingObj(ArrayList<AbstractCpsObject> toTrack) {
  608. trackedObjects = toTrack;
  609. }
  610. public ArrayList<AbstractCpsObject> getTrackingObj() {
  611. return trackedObjects;
  612. }
  613. public void addGraphListener(GraphListener gl) {
  614. graphListeners.add(gl);
  615. }
  616. public void setEleToDelete(HashMap<Integer, ArrayList<HolonElement>> theHash) {
  617. this.eleToDelete = theHash;
  618. }
  619. public HashMap<Integer, ArrayList<HolonElement>> getEleToDelete() {
  620. return this.eleToDelete;
  621. }
  622. public void setSingleTable(PropertyTable pt) {
  623. this.tableModelHolonElementSingle = pt;
  624. }
  625. public PropertyTable getSingleTable() {
  626. return this.tableModelHolonElementSingle;
  627. }
  628. public PropertyTable getMultiTable() {
  629. return this.tableModelHolonElementMulti;
  630. }
  631. public void setMultiTable(PropertyTable pt) {
  632. this.tableModelHolonElementMulti = pt;
  633. }
  634. public void addObjectsToGraphListeners() {
  635. for (GraphListener gl : graphListeners) {
  636. gl.addTrackedObject(trackedObjects);
  637. gl.repaintTree();
  638. }
  639. }
  640. public DefaulTable getPropertyTable() {
  641. return this.tableModelProperties;
  642. }
  643. public void setPropertyTable(DefaulTable pt) {
  644. this.tableModelProperties = pt;
  645. }
  646. public JTable getTableHolonElement() {
  647. return tableHolonElement;
  648. }
  649. public void setTableHolonElement(JTable tableHolonElement) {
  650. this.tableHolonElement = tableHolonElement;
  651. }
  652. /**
  653. * Sets the HolonBody Scale.
  654. *
  655. * @param scale
  656. * for the HolonBody
  657. */
  658. public void setHolonBodyScale(int scale) {
  659. holonBodysCALE = scale;
  660. }
  661. /**
  662. * Returns the sCale (Scale for the Images).
  663. *
  664. * @return sCALE
  665. */
  666. public int getHolonBodyScale() {
  667. return holonBodysCALE;
  668. }
  669. /**
  670. * Sets the ID of the selected HolonBody
  671. *
  672. * @param i
  673. * int
  674. */
  675. public void setSelectedHolonBody(int i) {
  676. selectedHolonBody = i;
  677. }
  678. /**
  679. * Returns the ID of the selected HolonBody
  680. *
  681. * @return selectedHolonBody
  682. */
  683. public int getSelectedHolonBody() {
  684. return selectedHolonBody;
  685. }
  686. /**
  687. * get all Switches
  688. */
  689. public ArrayList<HolonSwitch> getSwitches() {
  690. ArrayList<HolonSwitch> switches = new ArrayList<>();
  691. for (AbstractCpsObject obj : getObjectsOnCanvas()) {
  692. if (obj instanceof HolonSwitch) {
  693. switches.add((HolonSwitch) obj);
  694. } else if (obj instanceof CpsUpperNode) {
  695. getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
  696. }
  697. }
  698. return switches;
  699. }
  700. /**
  701. * get the Amount of Switches help function
  702. *
  703. * @param objects
  704. * objects
  705. * @param switches
  706. * List of switches
  707. */
  708. private ArrayList<HolonSwitch> getSwitchesRec(ArrayList<AbstractCpsObject> objects,
  709. ArrayList<HolonSwitch> switches) {
  710. for (AbstractCpsObject obj : objects) {
  711. if (obj instanceof HolonSwitch) {
  712. switches.add((HolonSwitch) obj);
  713. } else if (obj instanceof CpsUpperNode) {
  714. getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
  715. }
  716. }
  717. return switches;
  718. }
  719. /**
  720. * Returns the Path for the background Image of the Canvas.
  721. *
  722. * @return imgPath the Path
  723. */
  724. public String getCanvasImagePath() {
  725. return imgPath;
  726. }
  727. /**
  728. * Returns the mode for the background Image of the Canvas.
  729. *
  730. * 0 take size of the Image 1 stretch the Image 2 Custom Image size
  731. *
  732. * @return backgroundMode the mode
  733. */
  734. public int getCanvasImageMode() {
  735. return backgroundMode;
  736. }
  737. /**
  738. * Returns the Custom width of the background Image of the Canvas.
  739. *
  740. * @return backgroundWidth the Width
  741. */
  742. public int getCanvasImageWidth() {
  743. return backgroundWidth;
  744. }
  745. /**
  746. * Returns the Custom height of the background Image of the Canvas.
  747. *
  748. * @return backgroundHeight the height
  749. */
  750. public int getCanvasImageHeight() {
  751. return backgroundHeight;
  752. }
  753. /**
  754. * Set the Path for the background Image of the Canvas.
  755. *
  756. * @param paththe Path
  757. */
  758. public void setCanvasImagePath(String path) {
  759. imgPath = path;
  760. }
  761. /**
  762. * Set the mode for the background Image of the Canvas.
  763. *
  764. * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
  765. *
  766. * @param backgroundMode the mode
  767. */
  768. public void setCanvasImageMode(int mode) {
  769. backgroundMode = mode;
  770. }
  771. /**
  772. * Set the Custom width of the background Image of the Canvas.
  773. *
  774. * @param width the Width
  775. */
  776. public void setCanvasImageWidth(int width) {
  777. backgroundWidth = width;
  778. }
  779. /**
  780. * Set the Custom height of the background Image of the Canvas.
  781. *
  782. * @param height the height
  783. */
  784. public void setCanvasImageHeight(int height) {
  785. backgroundHeight = height;
  786. }
  787. }