UpdateController.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. package ui.controller;
  2. import classes.*;
  3. import classes.comparator.elementComparator.ElemCompOnEleName;
  4. import classes.comparator.elementComparator.ElemCompOnEnergy;
  5. import classes.comparator.elementComparator.ElemCompOnId;
  6. import classes.comparator.elementComparator.ElemCompOnIsActivated;
  7. import classes.comparator.elementComparator.ElemCompOnObj;
  8. import classes.comparator.elementComparator.ElemCompOnQuantity;
  9. import classes.comparator.elementComparator.ElementComparator;
  10. import ui.model.DecoratedGroupNode;
  11. import ui.model.DecoratedHolonObject.HolonObjectState;
  12. import ui.model.Model;
  13. import ui.view.DefaulTable;
  14. import ui.view.Languages;
  15. import ui.view.PropertyTable;
  16. import ui.view.GroupNodeCanvas;
  17. import java.util.ArrayList;
  18. import java.util.Comparator;
  19. import java.util.HashMap;
  20. import java.util.LinkedList;
  21. /**
  22. * This class is for all update methods and more ;)
  23. *
  24. * @author Gruppe14
  25. *
  26. */
  27. public class UpdateController {
  28. Model model;
  29. Control controller;
  30. private int sortBy;
  31. public UpdateController(Model model, Control control) {
  32. this.model = model;
  33. this.controller = control;
  34. sortBy= 1;
  35. }
  36. /**
  37. * Update the information concerning properties of the selected CpsObject.
  38. */
  39. public void refreshTableProperties(DefaulTable table) {
  40. if (model.getSelectedCpsObjects().size() == 1) {
  41. AbstractCanvasObject tempCps = model.getSelectedCpsObjects().get(0);
  42. if (tempCps != null && tempCps.getClass() == HolonObject.class) {
  43. if (table.getRowCount() != 0) {
  44. table.removeRow(2);
  45. Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) tempCps).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
  46. table.insertRow(2, tempEnergy);
  47. table.removeRow(3);
  48. Object[] tempFlex = { "Flexibility", ((HolonObject) tempCps).getTotalFlex() };
  49. table.insertRow(3, tempFlex);
  50. }
  51. }
  52. }
  53. }
  54. /**
  55. * Add the Information of the given ArrayList in the HolonElement Model as
  56. * Name,Energy and Amount.
  57. *
  58. * @param objects
  59. * ArrayList to be displayed
  60. */
  61. public void fillElementTable(ArrayList<AbstractCanvasObject> objects, PropertyTable table) {
  62. LinkedList<HolonElement> elemList = new LinkedList<HolonElement>();
  63. if (objects.size() > 1) {
  64. for (AbstractCanvasObject o : objects) {
  65. if (o instanceof HolonObject) {
  66. for (HolonElement he : ((HolonObject) o).getElements()) {
  67. he.setObjName(o.getName() + ", " + o.getId());
  68. elemList.add(he);
  69. elemList=sortElemList(elemList);
  70. }
  71. }
  72. }
  73. for (HolonElement e1 : elemList) {
  74. Object[] temp2 = { e1.getObjName(), e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
  75. controller.getSimManager().getActualFlexManager().isAFlexInUseOfHolonElement(e1), e1.getAmount(), e1.isActive()};
  76. table.addRow(temp2);
  77. }
  78. } else if (objects.size() == 1) {
  79. AbstractCanvasObject o = objects.get(0);
  80. if (o instanceof HolonObject) {
  81. for (HolonElement he : ((HolonObject) o).getElements()) {
  82. elemList.add(he);
  83. elemList=sortElemList(elemList);
  84. }
  85. for (HolonElement e1 : elemList) {
  86. Object[] temp2 = { e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
  87. controller.getSimManager().getActualFlexManager().isAFlexInUseOfHolonElement(e1), e1.getAmount(), e1.isActive()};
  88. table.addRow(temp2);
  89. }
  90. }
  91. }
  92. }
  93. /**
  94. * @param elemList - HolonElement-List (unsorted)
  95. * @return sorted HolonElement-List!
  96. */
  97. public LinkedList<HolonElement> sortElemList(LinkedList<HolonElement> elemList) {
  98. switch(sortBy) {
  99. case 0://"Object":
  100. elemList.sort(new ElemCompOnObj());
  101. break;
  102. case 1://ID
  103. elemList.sort(new ElemCompOnId());
  104. break;
  105. case 2://"Device":
  106. elemList.sort(new ElemCompOnEleName());
  107. break;
  108. case 3://"Energy":
  109. elemList.sort(new ElemCompOnEnergy());
  110. break;
  111. case 4://"Flexible Energy Available":
  112. elemList.sort(null);
  113. break;
  114. case 5://"Quantity":
  115. elemList.sort(new ElemCompOnQuantity());
  116. break;
  117. case 6://"Activated":
  118. elemList.sort(new ElemCompOnIsActivated());
  119. break;
  120. case 7://"Flexible":
  121. elemList.sort(null);
  122. break;
  123. default:
  124. elemList.sort(new ElemCompOnId());
  125. break;
  126. }
  127. return elemList;
  128. };
  129. /**
  130. * Update the HolonElement Table, that means erase all rows and add the new
  131. * rows with new data.
  132. */
  133. public void refreshTableHolonElement(PropertyTable multiTable, PropertyTable singleTable) {
  134. // Update of the Information about the HolonElements - only for
  135. // HolonObjects
  136. if(multiTable == null || singleTable == null ) return;
  137. if (model.getSelectedCpsObjects().size() > 1) {
  138. deleteRows(multiTable);
  139. fillElementTable(model.getSelectedCpsObjects(), multiTable);
  140. multiTable.fireTableDataChanged();
  141. } else if (model.getSelectedCpsObjects().size() == 1) {
  142. deleteRows(singleTable);
  143. fillElementTable(model.getSelectedCpsObjects(), singleTable);
  144. singleTable.fireTableDataChanged();
  145. }
  146. }
  147. /**
  148. * Erase all information of the HolonElement Model.
  149. *
  150. * @param t
  151. * the Table
  152. */
  153. public void deleteRows(PropertyTable t) {
  154. if (t.getRowCount() > 0) {
  155. for (int i = t.getRowCount() - 1; i > -1; i--) {
  156. t.removeRow(i);
  157. }
  158. }
  159. }
  160. /**
  161. * Search for clicked HolonObject through the mouse's y-Coord.
  162. *
  163. * @param yValue
  164. * the Y Coordination
  165. * @return clicked HolonObject
  166. */
  167. public HolonObject getHolonObj(int yValue, PropertyTable table) {
  168. final int yTemp = (int) Math.floor(yValue / 16);
  169. HolonObject obtTemp = null;
  170. String temp = table.getValueAt(yTemp, 0).toString();
  171. int idTemp = Integer.parseInt(temp.split(", ")[1]);
  172. obtTemp = (HolonObject) controller.searchByID(idTemp);
  173. return obtTemp;
  174. }
  175. /**
  176. * Search for actual selected HolonElement.
  177. *
  178. * @param obj
  179. * selected HolonObject, if obj==null means multi-selection
  180. * active
  181. * @param yValue
  182. * Y-Coord in the HolonElementsTable
  183. * @param toMultiHash
  184. * 0 means no MultiSelection, 1 means MultiSelection without
  185. * Control, 2 means MultiSelection with Control
  186. * @return the selected HolonElement
  187. */
  188. public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash,
  189. ArrayList<PropertyTable> tables) {
  190. final int yTemp = (int) Math.floor(yValue / 16);
  191. int rowsTotal = 0;
  192. // Filter for search --> single and multi selection
  193. if (obj == null) {
  194. rowsTotal = tables.get(1).getRowCount();
  195. } else {
  196. rowsTotal = tables.get(0).getRowCount();
  197. }
  198. // search for the clicked HolonObject and HolonElement --> in the
  199. // HolonElementTable
  200. HolonObject obtTemp = null;
  201. HolonElement toReturnEle = null;
  202. int id = 0;
  203. if (rowsTotal != 0 && rowsTotal > yTemp) {
  204. // Multi-Selection search
  205. if (obj == null) {
  206. String tempStringObj = tables.get(1).getValueAt(yTemp, 0).toString();
  207. int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
  208. if (model.getSelectedCpsObjects() != null) {
  209. obtTemp = (HolonObject) getHolonObjSelected(idTempObj);
  210. }
  211. id = Integer.parseInt(tables.get(1).getValueAt(yTemp, 1).toString());
  212. ArrayList<HolonElement> eleTemp = new ArrayList<HolonElement>();
  213. if (model.getEleToDelete().containsKey(idTempObj) && toMultiHash == 2) {
  214. eleTemp = model.getEleToDelete().get(idTempObj);
  215. if (!eleTemp.contains(obtTemp.searchElementById(id))) {
  216. eleTemp.add(obtTemp.searchElementById(id));
  217. model.getEleToDelete().replace(idTempObj, eleTemp);
  218. }
  219. } else if (toMultiHash == 2) {
  220. eleTemp.add(obtTemp.searchElementById(id));
  221. model.getEleToDelete().put(idTempObj, eleTemp);
  222. } else if (toMultiHash == 1) {
  223. model.setEleToDelete(new HashMap<Integer, ArrayList<HolonElement>>());
  224. eleTemp.add(obtTemp.searchElementById(id));
  225. model.getEleToDelete().put(idTempObj, eleTemp);
  226. } else if (toMultiHash == 0) {
  227. toReturnEle = obtTemp.searchElementById(id);
  228. }
  229. } // Single-Selection search
  230. else {
  231. model.setEleToDelete(new HashMap<Integer, ArrayList<HolonElement>>());
  232. id = Integer.parseInt(tables.get(0).getValueAt(yTemp, 0).toString());
  233. toReturnEle = obj.searchElementById(id);
  234. }
  235. model.setSelectedHolonElement(toReturnEle);
  236. return toReturnEle;
  237. } // If no HolonObject selected
  238. else {
  239. model.setEleToDelete(new HashMap<Integer, ArrayList<HolonElement>>());
  240. model.setSelectedHolonElement(null);
  241. return null;
  242. }
  243. }
  244. /**
  245. * Getter for selected CpsObject.
  246. *
  247. * @return selected CpsObject
  248. */
  249. public AbstractCanvasObject getActualCps() {
  250. AbstractCanvasObject tempCps;
  251. if (model.getSelectedCpsObjects().size() == 1) {
  252. tempCps = model.getSelectedCpsObjects().get(0);
  253. } else {
  254. int tempID = model.getSelectedObjectID();
  255. tempCps = controller.searchByID(tempID);
  256. }
  257. return tempCps;
  258. }
  259. /**
  260. * Getter for selected CpsObject.
  261. *
  262. * @return selected CpsObject
  263. */
  264. public AbstractCanvasObject getActualCpsUpperNode(GroupNodeCanvas canvas) {
  265. int tempID = model.getSelectedObjectID();
  266. AbstractCanvasObject tempCps = controller.searchByIDUpperNode(tempID, canvas.upperNode);
  267. return tempCps;
  268. }
  269. public void paintProperties(AbstractCanvasObject obj) {
  270. if (obj != null) {
  271. // Name of the CpsObject
  272. Object[] tempName = { Languages.getLanguage()[72], obj.getName() };
  273. model.getPropertyTable().addRow(tempName);
  274. // Id of the CpsObject
  275. Object[] tempId = { "ID", obj.getId() };
  276. model.getPropertyTable().addRow(tempId);
  277. // For HolonObjects the Total Energy (production or
  278. // consumption) is calculated
  279. if (obj instanceof HolonObject) {
  280. refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
  281. Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) obj).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
  282. Object[] tempFlex = { "Flexibility", ((HolonObject) obj).getTotalFlex() };
  283. model.getPropertyTable().addRow(tempEnergy);
  284. model.getPropertyTable().addRow(tempFlex);
  285. model.getPropertyTable().setCellEditable(0, 1, false);
  286. model.getPropertyTable().setCellEditable(2, 1, false);
  287. model.getPropertyTable().setCellEditable(3, 1, false);
  288. model.getPropertyTable().setCellEditable(4, 1, false);
  289. } // For HolonSwitches is showed the actual status (active
  290. // or inactive)
  291. else if (obj instanceof HolonSwitch) {
  292. deleteRows(model.getSingleTable());
  293. deleteRows(model.getMultiTable());
  294. Object[] tempMode = { Languages.getLanguage()[74], ((HolonSwitch) obj).getManualMode() };
  295. model.getPropertyTable().addRow(tempMode);
  296. if (((HolonSwitch) obj).getManualMode()) {
  297. Object[] tempActive = { Languages.getLanguage()[75], ((HolonSwitch) obj).getManualState() };
  298. model.getPropertyTable().addRow(tempActive);
  299. model.getPropertyTable().setCellEditable(3, 1, true);
  300. } else {
  301. Object[] tempActive = { Languages.getLanguage()[75],
  302. ((HolonSwitch) obj).getState(model.getCurIteration()) };
  303. model.getPropertyTable().addRow(tempActive);
  304. model.getPropertyTable().setCellEditable(3, 1, false);
  305. }
  306. // unitGraph.repaintWithNewSwitch((HolonSwitch) obj);
  307. // elementGraph.setText(obj.getName());
  308. model.getPropertyTable().setCellEditable(0, 1, true);
  309. model.getPropertyTable().setCellEditable(2, 1, true);
  310. } else if (obj instanceof GroupNode) {
  311. deleteRows(model.getSingleTable());
  312. deleteRows(model.getMultiTable());
  313. //short fix please make me new
  314. DecoratedGroupNode dGroupNode = controller.getSimManager().getVisualRepresentationalState(model.getCurIteration()).getCreatedGroupNodes().get((GroupNode) obj);
  315. Object[] info = { "Statistics:", "" };
  316. Object[] numEle = { "Number of Objects (total)", ((GroupNode) obj).getNodes().size() };
  317. Object[] numObj = { "Number of HolonObjects", ((GroupNode) obj).getNumHolonObj().size() };
  318. Object[] numSwi = { "Number of HolonSwitches", ((GroupNode) obj).getNumSwitches().size() };
  319. Object[] numUpp = { "Number of GroupNodes", ((GroupNode) obj).getNumUpperNodes().size() };
  320. model.getPropertyTable().addRow(info);
  321. model.getPropertyTable().addRow(numEle);
  322. model.getPropertyTable().addRow(numObj);
  323. model.getPropertyTable().addRow(numSwi);
  324. model.getPropertyTable().addRow(numUpp);
  325. if(dGroupNode != null) {
  326. int numerator, denominator;
  327. Object[] title = { "HolonObject Statistics:", "" };
  328. denominator = dGroupNode.getAmountOfConsumer() + dGroupNode.getAmountOfSupplier() + dGroupNode.getAmountOfPassiv();
  329. numerator = dGroupNode.getAmountOfSupplier();
  330. Object[] producer = { "Producer:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  331. numerator = dGroupNode.getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED);
  332. Object[] notSupplied = { "UnSupplied:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  333. numerator = dGroupNode.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED);
  334. Object[] partiallySupplied = { "PartriallySupplied:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  335. numerator = dGroupNode.getAmountOfConsumerWithState(HolonObjectState.SUPPLIED);
  336. Object[] supplied = { "Supplied:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  337. numerator = dGroupNode.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
  338. Object[] overSupplied = { "OverSupplied:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  339. numerator = dGroupNode.getAmountOfPassiv();
  340. Object[] passiv = { "Passiv(%):", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  341. Object[] nothing= {"", ""};
  342. numerator = dGroupNode.getAmountOfAktiveElemntsFromHolonObjects();
  343. denominator = dGroupNode.getAmountOfElemntsFromHolonObjects();
  344. Object[] aktiv = { "Active HolonElements:", numerator + "/" + denominator + "("+ (float)numerator/(float)denominator * 100 + "%)"};
  345. float consumption = dGroupNode.getConsumptionFromConsumer();
  346. float production = dGroupNode.getProductionFromSupplier();
  347. Object[] consumptionObj = { "Total Consumption:", consumption};
  348. Object[] productionObj = { "Total Production:", production};
  349. Object[] difference = { "Difference:", production - consumption};
  350. model.getPropertyTable().addRow(title);
  351. model.getPropertyTable().addRow(producer);
  352. model.getPropertyTable().addRow(notSupplied);
  353. model.getPropertyTable().addRow(partiallySupplied);
  354. model.getPropertyTable().addRow(supplied);
  355. model.getPropertyTable().addRow(overSupplied);
  356. model.getPropertyTable().addRow(passiv);
  357. model.getPropertyTable().addRow(nothing);
  358. model.getPropertyTable().addRow(aktiv);
  359. model.getPropertyTable().addRow(nothing);
  360. model.getPropertyTable().addRow(consumptionObj);
  361. model.getPropertyTable().addRow(productionObj);
  362. model.getPropertyTable().addRow(difference);
  363. }
  364. } else if (obj instanceof HolonBattery) {
  365. deleteRows(model.getSingleTable());
  366. deleteRows(model.getMultiTable());
  367. Object[] numInRatio = {"InRatio:", ((HolonBattery)obj).getInRatio() };
  368. Object[] numOutRatio = {"OutRatio:", ((HolonBattery)obj).getOutRatio() };
  369. Object[] numSOC_Capasity = {"State of charge:", Float.toString(((HolonBattery)obj).getStateOfChargeAtTimeStep(model.getCurIteration()-1)) + "/" + Float.toString(((HolonBattery)obj).getCapacity()) };
  370. model.getPropertyTable().addRow(numInRatio);
  371. model.getPropertyTable().addRow(numOutRatio);
  372. model.getPropertyTable().addRow(numSOC_Capasity);
  373. model.getPropertyTable().setCellEditable(0, 1, true);
  374. model.getPropertyTable().setCellEditable(2, 1, true);
  375. model.getPropertyTable().setCellEditable(3, 1, true);
  376. }else {
  377. deleteRows(model.getSingleTable());
  378. deleteRows(model.getMultiTable());
  379. }
  380. // For Objects the only editable cell is the name
  381. ArrayList<Edge> tempArray = obj.getConnections();
  382. // If the clicked object has connections
  383. if (!tempArray.isEmpty()) {
  384. boolean first = true;
  385. for (Edge temp2 : tempArray) {
  386. if (first) {
  387. first = false;
  388. if (obj.getId() != temp2.getA().getId()) {
  389. Object[] tempConnection = { obj.getName() + Languages.getLanguage()[76],
  390. temp2.getA().getName() + Languages.getLanguage()[77] + temp2.getA().getId() };
  391. model.getPropertyTable().addRow(tempConnection);
  392. } else {
  393. Object[] tempConnection = { obj.getName() + Languages.getLanguage()[76],
  394. temp2.getB().getName() + Languages.getLanguage()[77] + temp2.getB().getId() };
  395. model.getPropertyTable().addRow(tempConnection);
  396. }
  397. } else {
  398. if (obj.getId() != temp2.getA().getId()) {
  399. Object[] tempConnection = { "",
  400. temp2.getA().getName() + Languages.getLanguage()[77] + temp2.getA().getId() };
  401. model.getPropertyTable().addRow(tempConnection);
  402. } else {
  403. Object[] tempConnection = { "",
  404. temp2.getB().getName() + Languages.getLanguage()[77] + temp2.getB().getId() };
  405. model.getPropertyTable().addRow(tempConnection);
  406. }
  407. }
  408. }
  409. }
  410. } // If the clicked Object is an edge
  411. else if (model.getSelectedEdge() != null) {
  412. // Name displayed
  413. Object[] tempName = { Languages.getLanguage()[72],
  414. Languages.getLanguage()[78] + model.getSelectedEdge().getA().getName() + Languages.getLanguage()[79]
  415. + model.getSelectedEdge().getB().getName() };
  416. model.getPropertyTable().addRow(tempName);
  417. // Current Flow displayed
  418. Object[] tempFlow = { Languages.getLanguage()[80], "" };
  419. model.getPropertyTable().addRow(tempFlow);
  420. // Max Capacity displayed
  421. Object[] tempCapacity = { Languages.getLanguage()[81], model.getSelectedEdge().getCapacity() };
  422. model.getPropertyTable().addRow(tempCapacity);
  423. // Status displayed
  424. Object[] tempStatus = {"Length", model.getSelectedEdge().getLength() };
  425. model.getPropertyTable().addRow(tempStatus);
  426. model.getPropertyTable().addRow(new Object[]{"Real length in km", model.getSelectedEdge().getRealLength()});
  427. // For edges, the only possible editable cell is the max
  428. // flow
  429. model.getPropertyTable().setCellEditable(0, 1, false);
  430. model.getPropertyTable().setCellEditable(2, 1, true);
  431. model.getPropertyTable().setCellEditable(3, 1, false);
  432. model.getPropertyTable().setCellEditable(4, 1, true);
  433. } else if (getActualCps() == null) {
  434. deleteRows(model.getSingleTable());
  435. deleteRows(model.getMultiTable());
  436. }
  437. // Update of the HolonElementTable (Single- or Multi-Selection)
  438. if (model.getSelectedCpsObjects().size() > 1) {
  439. model.getTableHolonElement().setModel(model.getMultiTable());
  440. } else if (model.getSelectedCpsObjects().size() == 1) {
  441. model.getTableHolonElement().setModel(model.getSingleTable());
  442. }
  443. }
  444. public AbstractCanvasObject getHolonObjSelected(int id) {
  445. AbstractCanvasObject obj = null;
  446. for (AbstractCanvasObject o : model.getSelectedCpsObjects()) {
  447. if (o.getId() == id) {
  448. obj = o;
  449. break;
  450. }
  451. }
  452. return obj;
  453. }
  454. /**
  455. * fills the table when HolonCanvas is open
  456. *
  457. * @param id
  458. * ID of the selected HolonBody
  459. */
  460. public void paintHolonBody(int id) {
  461. if (id != -1) {
  462. ArrayList<SubNet> subs = controller.getSimManager().getSubNets();
  463. if (!subs.isEmpty()) {
  464. SubNet sub = subs.get(id);
  465. Object[] tempId = { "ID", id };
  466. model.getPropertyTable().addRow(tempId);
  467. Object[] tempObj = { "Nr. of Objects", sub.getObjects().size() };
  468. model.getPropertyTable().addRow(tempObj);
  469. Object[] tempEdg = { "Nr. of Edges", sub.getEdges().size() };
  470. model.getPropertyTable().addRow(tempEdg);
  471. Object[] tempSwi = { "Nr. of Switches", sub.getSwitches().size() };
  472. model.getPropertyTable().addRow(tempSwi);
  473. Object[] tempProd = { "Total Production",
  474. "" + controller.getTotalProduction(new ArrayList<AbstractCanvasObject>(sub.getObjects())) };
  475. model.getPropertyTable().addRow(tempProd);
  476. Object[] tempCons = { "Total Consumption",
  477. "" + controller.getTotalConsumption(new ArrayList<AbstractCanvasObject>(sub.getObjects())) };
  478. model.getPropertyTable().addRow(tempCons);
  479. Object[] tempEle = { "Nr. of Elements",
  480. "" + controller.getTotalElements(new ArrayList<AbstractCanvasObject>(sub.getObjects())) };
  481. model.getPropertyTable().addRow(tempEle);
  482. Object[] tempProds = { "Nr. of Producers",
  483. "" + controller.getTotalProducers(new ArrayList<AbstractCanvasObject>(sub.getObjects())) };
  484. model.getPropertyTable().addRow(tempProds);
  485. Object[] tempAct = { "Nr. of active Elements",
  486. "" + controller.getActiveElements(new ArrayList<AbstractCanvasObject>(sub.getObjects())) };
  487. model.getPropertyTable().addRow(tempAct);
  488. }
  489. }
  490. }
  491. /**
  492. *
  493. * @return id of column that should be sorted
  494. */
  495. public int getSortBy() {
  496. return sortBy;
  497. }
  498. /**
  499. * sets the column id that should be sorted
  500. * @param column
  501. */
  502. public void setSortBy(int column) {
  503. /**
  504. * if there is no "Object" column, assume coloumn 0 is
  505. */
  506. if(model.getTableHolonElement().getColumnCount()==7)
  507. this.sortBy = column+1;
  508. else
  509. this.sortBy = column;
  510. }
  511. }