MyCanvas.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. package ui.view;
  2. import java.awt.BasicStroke;
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Image;
  7. import java.awt.Rectangle;
  8. import java.awt.RenderingHints;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import java.awt.event.MouseEvent;
  12. import java.awt.event.MouseListener;
  13. import java.awt.event.MouseMotionListener;
  14. import java.awt.geom.Line2D;
  15. import java.io.File;
  16. import java.io.IOException;
  17. import java.util.ArrayList;
  18. import java.util.LinkedList;
  19. import java.util.Timer;
  20. import java.util.TimerTask;
  21. import javax.swing.ImageIcon;
  22. import javax.swing.JMenuItem;
  23. import javax.swing.JPanel;
  24. import javax.swing.JPopupMenu;
  25. import javax.swing.JToolTip;
  26. import classes.CpsEdge;
  27. import classes.CpsNode;
  28. import classes.CpsObject;
  29. import classes.HolonElement;
  30. import classes.HolonObject;
  31. import classes.HolonSwitch;
  32. import classes.HolonTransformer;
  33. import ui.controller.Control;
  34. import ui.model.Model;
  35. import ui.model.idCounter;
  36. public class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
  37. /**
  38. *
  39. */
  40. private static final long serialVersionUID = 1L;
  41. private Image img = null; // Contains the image to draw on MyCanvas
  42. private int x = 0;
  43. private int y = 0;
  44. // edge Object Start Point
  45. private Model model;
  46. private final Control controller;
  47. Graphics2D g2; // For Painting
  48. private int cx, cy;
  49. private int sx, sy; // Mark Coords
  50. ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
  51. ArrayList<CpsObject> TempSelected = new ArrayList<CpsObject>();
  52. private boolean dragging = false; // for dragging
  53. private boolean drawEdge = false; // for drawing edges
  54. private boolean click = false; // for double click
  55. private boolean doMark = false; // for double click
  56. public CpsObject tempCps = null;
  57. private Rectangle selectRect = new Rectangle();
  58. private CpsEdge edgeHighlight = null;
  59. // PopUpMenu
  60. private JPopupMenu popmenu = new JPopupMenu();
  61. private JMenuItem itemDelete = new JMenuItem("Delete Object");
  62. private JToolTip objectTT = new JToolTip();
  63. // contains the value of the Capacity for new created Edges
  64. private float edgeCapacity;
  65. public MyCanvas(final Model model, Control control) {
  66. this.add(objectTT);
  67. this.controller = control;
  68. this.model = model;
  69. edgeCapacity = 100;
  70. popmenu.add(itemDelete);
  71. itemDelete.setEnabled(false);
  72. itemDelete.addActionListener(new ActionListener() {
  73. @Override
  74. public void actionPerformed(ActionEvent e) {
  75. // Remove the selected Object object
  76. controller.delCanvasObject(tempCps);
  77. tempCps = null;
  78. selectRect.setRect(0, 0, 0, 0);
  79. repaint();
  80. }
  81. });
  82. this.addMouseListener(this);
  83. this.addMouseMotionListener(this);
  84. }
  85. /**
  86. * Paints all Components on the Canvas
  87. *
  88. * @param Graphics
  89. *
  90. */
  91. public void paintComponent(Graphics g) {
  92. super.paintComponent(g);
  93. // Rendering
  94. g2 = (Graphics2D) g;
  95. RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  96. g2.setRenderingHints(rh);
  97. // drawEdges
  98. // g2.setColor(Color.BLACK);
  99. if (drawEdge) {
  100. g2.setColor(Color.BLACK);
  101. g2.setStroke(new BasicStroke(2));
  102. g2.drawLine(tempCps.getPosition().x + controller.getScaleDiv2(),
  103. tempCps.getPosition().y + controller.getScaleDiv2(), x, y);
  104. }
  105. for (CpsEdge con : model.getEdgesOnCanvas()) {
  106. if (con.getA().getID() != model.getSelectedObjectID() && con.getB().getID() != model.getSelectedObjectID()
  107. && con != edgeHighlight) {
  108. if (con.getFlow() <= con.getCapacity()) {
  109. g2.setColor(Color.GREEN);
  110. g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
  111. } else {
  112. g2.setColor(Color.RED);
  113. g2.setStroke(new BasicStroke(2));
  114. }
  115. g2.drawLine(con.getA().getPosition().x + controller.getScaleDiv2(),
  116. con.getA().getPosition().y + controller.getScaleDiv2(),
  117. con.getB().getPosition().x + controller.getScaleDiv2(),
  118. con.getB().getPosition().y + controller.getScaleDiv2());
  119. g2.drawString(con.getFlow() + "/" + con.getCapacity(),
  120. (con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
  121. (con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
  122. }
  123. }
  124. // Highlighted Edge
  125. if (model.getSelectedObjectID() > 0) {
  126. g2.setColor(Color.BLUE);
  127. for (CpsEdge con : model.getEdgesOnCanvas()) {
  128. if (con.getFlow() <= con.getCapacity()) {
  129. g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
  130. } else {
  131. g2.setStroke(new BasicStroke(2));
  132. }
  133. if (con.getA().getID() == model.getSelectedObjectID()
  134. || con.getB().getID() == model.getSelectedObjectID() && con != edgeHighlight) {
  135. g2.drawLine(con.getA().getPosition().x + controller.getScaleDiv2(),
  136. con.getA().getPosition().y + controller.getScaleDiv2(),
  137. con.getB().getPosition().x + controller.getScaleDiv2(),
  138. con.getB().getPosition().y + controller.getScaleDiv2());
  139. g2.drawString(con.getFlow() + "/" + con.getCapacity(),
  140. (con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
  141. (con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
  142. }
  143. }
  144. } else if (edgeHighlight != null) {
  145. g2.setColor(Color.BLUE);
  146. g2.setStroke(new BasicStroke(2));
  147. g2.drawLine(edgeHighlight.getA().getPosition().x + controller.getScaleDiv2(),
  148. edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
  149. edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
  150. edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
  151. g2.drawString(edgeHighlight.getFlow() + "/" + edgeHighlight.getCapacity(),
  152. (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2
  153. + controller.getScaleDiv2(),
  154. (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2
  155. + controller.getScaleDiv2());
  156. }
  157. // Objects
  158. for (CpsObject cps : model.getObjectsOnCanvas()) {
  159. if (cps.getID() == model.getSelectedObjectID() && controller.searchByID(model.getSelectedObjectID()) != null
  160. && controller.searchByID(model.getSelectedObjectID()) instanceof CpsNode) {
  161. img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
  162. } else {
  163. if (cps instanceof HolonSwitch) {
  164. if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
  165. ((HolonSwitch) cps).setState(true);
  166. } else {
  167. ((HolonSwitch) cps).setState(false);
  168. }
  169. }
  170. if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && TempSelected.size() == 0)
  171. || model.getSelectedCpsObjects().contains(cps) || TempSelected.contains(cps)) {
  172. g2.setColor(Color.BLUE);
  173. g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
  174. cps.getPosition().y - (controller.getScale() / 20),
  175. controller.getScale() + ((controller.getScale() / 20) * 2),
  176. controller.getScale() + ((controller.getScale() / 20) * 2));
  177. } else if (cps instanceof HolonObject) {
  178. if (((HolonObject) cps).getState() == 4) {
  179. g2.setColor(Color.YELLOW);
  180. }
  181. if (((HolonObject) cps).getState() == 3) {
  182. g2.setColor(Color.lightGray);
  183. }
  184. if (((HolonObject) cps).getState() == 2) {
  185. g2.setColor(Color.GREEN);
  186. }
  187. if (((HolonObject) cps).getState() == 1) {
  188. g2.setColor(Color.ORANGE);
  189. }
  190. if (((HolonObject) cps).getState() == 0) {
  191. g2.setColor(Color.WHITE);
  192. }
  193. g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
  194. cps.getPosition().y - (controller.getScale() / 20),
  195. controller.getScale() + ((controller.getScale() / 20) * 2),
  196. controller.getScale() + ((controller.getScale() / 20) * 2));
  197. }
  198. File checkPath = new File(cps.getImage());
  199. if (checkPath.exists()) {
  200. img = new ImageIcon(cps.getImage()).getImage();
  201. } else {
  202. img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
  203. }
  204. }
  205. g2.drawImage(img, cps.getPosition().x, cps.getPosition().y, controller.getScale(), controller.getScale(),
  206. null);
  207. }
  208. // Dragg Highlighting
  209. if (doMark) {
  210. g2.setColor(Color.BLACK);
  211. g2.setStroke(new BasicStroke(1));
  212. if (sx > x && sy > y) {
  213. g2.drawRect(x, y, sx - x, sy - y);
  214. } else if (sx < x && sy < y) {
  215. g2.drawRect(sx, sy, x - sx, y - sy);
  216. } else if (sx >= x) {
  217. g2.drawRect(x, sy, sx - x, y - sy);
  218. } else if (sy >= y) {
  219. g2.drawRect(sx, y, x - sx, sy - y);
  220. }
  221. }
  222. }
  223. @Override
  224. public void mouseClicked(MouseEvent e) {
  225. // clear SelectedObjects
  226. if (!e.isControlDown() && dragging == false) {
  227. model.getSelectedCpsObjects().clear();
  228. TempSelected.clear();
  229. }
  230. }
  231. @Override
  232. public void mouseEntered(MouseEvent e) {
  233. }
  234. @Override
  235. public void mouseExited(MouseEvent e) {
  236. }
  237. @Override
  238. public void mousePressed(MouseEvent e) {
  239. tempCps = null;
  240. dataSelected = null;
  241. edgeHighlight = null;
  242. controller.setSelecteEdge(null);
  243. // Object Selection
  244. for (CpsObject cps : model.getObjectsOnCanvas()) {
  245. cx = cps.getPosition().x;
  246. cy = cps.getPosition().y;
  247. if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
  248. tempCps = cps;
  249. dragging = true;
  250. // If drawing an Edge (CTRL down)
  251. if (tempCps.getClass() == HolonObject.class) {
  252. HolonObject tempObj = ((HolonObject) tempCps);
  253. dataSelected = tempObj.getElements();
  254. }
  255. if (e.isShiftDown()) {
  256. drawEdge = true;
  257. dragging = false;
  258. }
  259. }
  260. }
  261. // Edge Selection
  262. if (tempCps == null) {
  263. edgeHighlight = mousePositionOnEdge(x, y);
  264. controller.setSelecteEdge(edgeHighlight);
  265. }
  266. if (edgeHighlight == null && tempCps == null) {
  267. sx = e.getX();
  268. sy = e.getY();
  269. doMark = true;
  270. }
  271. // Object Selection Highlighting (selectRect)
  272. objectSelectionHighlighting();
  273. repaint();
  274. }
  275. @Override
  276. public void mouseReleased(MouseEvent e) {
  277. if (drawEdge) {
  278. drawEdge = false;
  279. drawDeleteEdge();
  280. }
  281. // if Dragged reposition the Object
  282. if (dragging) {
  283. x = e.getX();
  284. y = e.getY();
  285. dragging = false;
  286. }
  287. // Rightclick List
  288. if (e.getButton() == MouseEvent.BUTTON3) {
  289. if (e.getButton() == MouseEvent.BUTTON3 && tempCps != null) {
  290. itemDelete.setEnabled(true);
  291. } else {
  292. itemDelete.setEnabled(false);
  293. }
  294. popmenu.show(e.getComponent(), e.getX(), e.getY());
  295. }
  296. if (doMark) {
  297. doMark = false;
  298. for (CpsObject cps : TempSelected) {
  299. if (!model.getSelectedCpsObjects().contains(cps)) {
  300. controller.addSelectedObject(cps);
  301. }
  302. }
  303. }
  304. controller.calculateStateForTimeStep(model.getCurIteration());
  305. repaint();
  306. }
  307. @Override
  308. public void mouseDragged(MouseEvent e) {
  309. // If Edge is drawn
  310. x = e.getX();
  311. y = e.getY();
  312. if (!model.getSelectedCpsObjects().contains(tempCps)) {
  313. model.getSelectedCpsObjects().clear();
  314. TempSelected.clear();
  315. }
  316. if (dragging) {
  317. try {
  318. float xDist, yDist; //Distance
  319. x = e.getX() - controller.getScaleDiv2();
  320. y = e.getY() - controller.getScaleDiv2();
  321. //Make sure its in bounds
  322. if (e.getX() < controller.getScaleDiv2())
  323. x = 0;
  324. else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
  325. x = this.getWidth() - controller.getScale();
  326. if (e.getY() < controller.getScaleDiv2())
  327. y = 0;
  328. else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
  329. y = this.getHeight() - controller.getScale();
  330. //Distance
  331. xDist = x-tempCps.getPosition().x;
  332. yDist = y-tempCps.getPosition().y;
  333. tempCps.setPosition(x, y); // Drag Position
  334. selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20)); // Highlighting-Position
  335. // TipText Position and name
  336. objectTT.setTipText(tempCps.getName());
  337. objectTT.setLocation(x, y + controller.getScale());
  338. //All Selected Objects
  339. for (CpsObject cps : model.getSelectedCpsObjects()) {
  340. if (cps != tempCps) {
  341. x = (int) (cps.getPosition().x+xDist);
  342. y = (int) (cps.getPosition().y+yDist);
  343. //Make sure its in bounds
  344. if (x < 0)
  345. x = 0;
  346. else if (x > this.getWidth())
  347. x = this.getWidth() - controller.getScale();
  348. if (y < controller.getScaleDiv2())
  349. y = 0;
  350. else if (y > this.getHeight())
  351. y = this.getHeight() - controller.getScale();
  352. cps.setPosition(x, y);
  353. }
  354. }
  355. repaint();
  356. } catch (Exception e2) {
  357. }
  358. }
  359. // Mark Objects
  360. TempSelected.clear();
  361. if (doMark)
  362. {
  363. for (CpsObject cps : model.getObjectsOnCanvas()) {
  364. int x1 = sx, x2 = x, y1 = sy, y2 = y;
  365. if (sx >= x) {
  366. x1 = x;
  367. x2 = sx;
  368. }
  369. if (sy >= y) {
  370. y1 = y;
  371. y2 = sy;
  372. }
  373. if (x1 <= cps.getPosition().x && y1 <= cps.getPosition().y && x2 >= cps.getPosition().x
  374. && y2 >= cps.getPosition().y) {
  375. TempSelected.add(cps);
  376. }
  377. }
  378. }
  379. repaint();
  380. }
  381. @Override
  382. public void mouseMoved(MouseEvent e) {
  383. x = e.getX();
  384. y = e.getY();
  385. // Everytghing for the tooltip :)
  386. boolean on = false;
  387. for (CpsObject cps : model.getObjectsOnCanvas()) {
  388. cx = cps.getPosition().x;
  389. cy = cps.getPosition().y;
  390. if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
  391. objectTT.setTipText(cps.getName());
  392. objectTT.setLocation(cx, cy + controller.getScale());
  393. on = true;
  394. }
  395. }
  396. if (!on) {
  397. objectTT.setLocation(-200, -200);
  398. objectTT.setTipText("");
  399. }
  400. }
  401. /**
  402. * Sets the Highlighting of the Selected Object
  403. */
  404. public void objectSelectionHighlighting() {
  405. if (tempCps != null) {
  406. selectRect.setBounds(tempCps.getPosition().x - (controller.getScale() / 20),
  407. tempCps.getPosition().y - (controller.getScale() / 20),
  408. controller.getScale() + ((controller.getScale() / 20) * 2),
  409. controller.getScale() + ((controller.getScale() / 20) * 2));
  410. controller.setSelectedObjectID(tempCps.getID());
  411. } else {
  412. controller.setSelectedObjectID(0);
  413. selectRect.setRect(0, 0, 0, 0);
  414. }
  415. }
  416. /**
  417. * Draws or Deletes an Edge
  418. */
  419. private void drawDeleteEdge() {
  420. boolean node = true;
  421. boolean newEdge = true;
  422. boolean onEdge = true;
  423. boolean deleteNode = false;
  424. CpsEdge e = null;
  425. CpsObject tempCPS = null;
  426. for (CpsObject cps : model.getObjectsOnCanvas()) {
  427. cx = cps.getPosition().x;
  428. cy = cps.getPosition().y;
  429. if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
  430. && cps != tempCps) {
  431. node = false;
  432. onEdge = false;
  433. for (CpsEdge p : tempCps.getConnections()) {
  434. if ((p.getA() == tempCps && p.getB() == cps) || (p.getB() == tempCps && p.getA() == cps)) {
  435. newEdge = false;
  436. e = p;
  437. }
  438. }
  439. if (!newEdge) {
  440. controller.removeEdgesOnCanvas(e);
  441. // Node ohne Edge?
  442. if (e.getA().getClass() == CpsNode.class && e.getA().getConnections().isEmpty()) {
  443. tempCps = e.getA();
  444. deleteNode = true;
  445. }
  446. if (e.getB().getClass() == CpsNode.class && e.getB().getConnections().isEmpty()) {
  447. tempCPS = e.getB();
  448. deleteNode = true;
  449. }
  450. }
  451. if (newEdge) {
  452. e = new CpsEdge(cps, tempCps, edgeCapacity);
  453. controller.AddEdgeOnCanvas(e);
  454. }
  455. }
  456. }
  457. // Edge auf eine Edge gezogen?
  458. if (onEdge) {
  459. CpsEdge p = mousePositionOnEdge(x, y);
  460. if (p != null) {
  461. CpsEdge e1 = null;
  462. CpsEdge e2 = null;
  463. node = false;
  464. CpsNode n = new CpsNode("Node");
  465. n.setID(idCounter.nextId());
  466. n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
  467. controller.addObjectCanvas(n);
  468. CpsObject r, k;
  469. r = p.getA();
  470. k = p.getB();
  471. e = new CpsEdge(n, tempCps, edgeCapacity);
  472. e1 = new CpsEdge(n, r, edgeCapacity);
  473. e2 = new CpsEdge(n, k, edgeCapacity);
  474. controller.removeEdgesOnCanvas(p);
  475. controller.AddEdgeOnCanvas(e);
  476. controller.AddEdgeOnCanvas(e1);
  477. controller.AddEdgeOnCanvas(e2);
  478. }
  479. }
  480. // ins leere Gedragged
  481. if (node) {
  482. CpsNode n = new CpsNode("Node");
  483. n.setID(idCounter.nextId());
  484. n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
  485. controller.addObjectCanvas(n);
  486. e = new CpsEdge(n, tempCps, edgeCapacity);
  487. controller.AddEdgeOnCanvas(e);
  488. System.out.println("node ID: " + n.getID());
  489. }
  490. // Wenn ein Node ohne Connections da ist
  491. if (deleteNode) {
  492. controller.delCanvasObject(tempCps);
  493. controller.delCanvasObject(tempCPS);
  494. tempCPS = null;
  495. tempCps = null;
  496. objectSelectionHighlighting();
  497. }
  498. }
  499. /**
  500. * Checks if the mouse is on an Edge
  501. *
  502. * @param x
  503. * Position of the Mouse
  504. * @param y
  505. * Position of the Mouse
  506. *
  507. * @return CpsEdge the Mouse is on, null if the mouse is not on an Edge
  508. */
  509. public CpsEdge mousePositionOnEdge(int x, int y) {
  510. int lx, ly, hx, hy;
  511. for (CpsEdge p : model.getEdgesOnCanvas()) {
  512. Line2D l = new Line2D.Float(p.getA().getPosition().x, p.getA().getPosition().y, p.getB().getPosition().x,
  513. p.getB().getPosition().y);
  514. if (p.getA().getPosition().x > p.getB().getPosition().x) {
  515. hx = p.getA().getPosition().x + model.getScaleDiv2() + 7;
  516. lx = p.getB().getPosition().x + model.getScaleDiv2() - 7;
  517. } else {
  518. lx = p.getA().getPosition().x + model.getScaleDiv2() - 7;
  519. hx = p.getB().getPosition().x + model.getScaleDiv2() + 7;
  520. }
  521. if (p.getA().getPosition().y > p.getB().getPosition().y) {
  522. hy = p.getA().getPosition().y + model.getScaleDiv2() + 7;
  523. ly = p.getB().getPosition().y + model.getScaleDiv2() - 7;
  524. } else {
  525. ly = p.getA().getPosition().y + model.getScaleDiv2() - 7;
  526. hy = p.getB().getPosition().y + model.getScaleDiv2() + 7;
  527. }
  528. // distance from a point to a line and between both Objects
  529. if (l.ptLineDistSq(x - model.getScaleDiv2(), y - model.getScaleDiv2()) < 20 && x > lx && x < hx && y > ly
  530. && y < hy) {
  531. return p;
  532. }
  533. }
  534. return null;
  535. }
  536. /**
  537. * Checks if a double click was made
  538. *
  539. * @return true if doublecklick, false if not
  540. */
  541. private boolean doubleClick() {
  542. if (click) {
  543. click = false;
  544. return true;
  545. } else {
  546. click = true;
  547. Timer t = new Timer("doubleclickTimer", false);
  548. t.schedule(new TimerTask() {
  549. @Override
  550. public void run() {
  551. click = false;
  552. }
  553. }, 500);
  554. }
  555. return false;
  556. }
  557. public void setEdgeCapacity(float cap) {
  558. edgeCapacity = cap;
  559. }
  560. }