GraphManager.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. package de.tu_darmstadt.informatik.tk.scopviz.graphs;
  2. import java.util.Collection;
  3. import java.util.HashMap;
  4. import java.util.LinkedList;
  5. import org.graphstream.graph.Element;
  6. import org.graphstream.ui.swingViewer.ViewPanel;
  7. import org.graphstream.ui.view.Viewer;
  8. import org.graphstream.ui.view.ViewerPipe;
  9. import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
  10. import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
  11. import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
  12. import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
  13. import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
  14. import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
  15. import de.tu_darmstadt.informatik.tk.scopviz.ui.StylesheetManager;
  16. import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
  17. /**
  18. * Interface between GUI and internal Graph representation. Manages internal
  19. * representation of the Graph to accommodate creation and deletion of nodes and
  20. * edges.
  21. *
  22. * @author Jascha Bohne
  23. * @version 3.0.0.0
  24. *
  25. */
  26. public class GraphManager {
  27. /** String for the processing enabled type of node. */
  28. public static final String UI_CLASS_PROCESSING_ENABLED = "procEn";
  29. /** The Graph this instance of GraphManager manages. */
  30. protected MyGraph g;
  31. protected MyGraph activeSubGraph;
  32. /**
  33. * The Stylesheet for this Graph, excluding parts that can be set by
  34. * NodeGraphics.
  35. */
  36. protected String stylesheet = "";
  37. /** The last Node that was deleted. */
  38. protected MyNode deletedNode;
  39. /** The last Edge that was deleted. */
  40. protected LinkedList<MyEdge> deletedEdges = new LinkedList<>();
  41. /** The currently selected Node, mutually exclusive with selectedEdgeID. */
  42. protected String selectedNodeID = null;
  43. /** The currently selected Edge, mutually exclusive with selectedNodeID. */
  44. protected String selectedEdgeID = null;
  45. /** The ViewPanel the Graph is drawn in. */
  46. protected ViewPanel view;
  47. /** The Path on Disk the Graph will be saved to. */
  48. protected String currentPath;
  49. /** The Viewer the Graph provides, grants Access to Camera Manipulation. */
  50. protected Viewer viewer;
  51. /**
  52. * The Pipe that notifies the underlying Graph of any Changes within the
  53. * graphic Representation.
  54. */
  55. protected ViewerPipe fromViewer;
  56. /**
  57. * The Id of the Node that was last clicked.
  58. */
  59. protected String lastClickedID;
  60. /**
  61. * Creates a new Manager for the given graph.
  62. *
  63. * @param graph
  64. * the graph this visualizer should handle
  65. */
  66. public GraphManager(MyGraph graph) {
  67. g = graph;
  68. /* Viewer */ viewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
  69. view = viewer.addDefaultView(false);
  70. viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.EXIT);
  71. /* ViewerPipe */fromViewer = viewer.newViewerPipe();
  72. view.setMouseManager(new MyMouseManager(this));
  73. fromViewer.addSink(graph);
  74. fromViewer.removeElementSink(graph);
  75. }
  76. /**
  77. * Deletes the Node corresponding to the given ID from the Graph. The
  78. * referenced Graph is modified directly. Will throw an
  79. * ElementNotFoundException, when the Node is not Found Will also remove all
  80. * Edges connected to the given Node
  81. *
  82. * @param id
  83. * the ID of the node that will be removed
  84. */
  85. public void deleteNode(final String id) {
  86. deletedEdges.removeAll(deletedEdges);
  87. deletedNode = null;
  88. // Edges have to be deleted first because they clear deletedNode
  89. // and need the Node to still be in the Graph
  90. deleteEdgesOfNode(id);
  91. deletedNode = g.removeNode(id);
  92. }
  93. /**
  94. * Deletes the Edge corresponding to the given ID from the Graph. The
  95. * referenced Graph is modified directly. Will throw an
  96. * ElementNotFoundException, when the Edge is not Found
  97. *
  98. * @param id
  99. * the ID of the Edge that will be removed
  100. */
  101. public void deleteEdge(final String id) {
  102. deselect();
  103. deletedEdges.removeAll(deletedEdges);
  104. deletedNode = null;
  105. deletedEdges.add(g.removeEdge(id));
  106. }
  107. /**
  108. * Deletes all Edges connected to the given Node. The referenced Graph is
  109. * modified directly. Will throw an ElementNotFoundException if the Node is
  110. * not Found
  111. *
  112. * @param id
  113. * the Id of the Node, whose Edges shall be removed
  114. */
  115. protected void deleteEdgesOfNode(final String id) {
  116. deselect();
  117. MyNode node = g.getNode(id);
  118. deletedEdges.removeAll(deletedEdges);
  119. deletedNode = null;
  120. MyEdge[] temp = new MyEdge[0];
  121. temp = g.getEdgeSet().toArray(temp);
  122. for (MyEdge e : temp) {
  123. if (e.getSourceNode().equals(node) || e.getTargetNode().equals(node)) {
  124. // adds the Edge to the list of deleted Edges and remove sit
  125. // from the Graph
  126. deletedEdges.add(g.removeEdge(e));
  127. }
  128. }
  129. GraphHelper.propagateElementDeletion(g, deletedEdges);
  130. }
  131. /**
  132. * Undoes the last deleting operation on the given Graph. Deleting
  133. * operations are: deleteNode, deleteEdge and deleteEdgesOfNode. Only undoes
  134. * the last deleting operation even if that operation didn't change the
  135. * Graph
  136. */
  137. public void undelete() {
  138. String newId = "";
  139. HashMap<String, Object> attributes = new HashMap<String, Object>();
  140. if (deletedNode != null) {
  141. for (String s : deletedNode.getAttributeKeySet()) {
  142. attributes.put(s, deletedNode.getAttribute(s));
  143. }
  144. newId = Main.getInstance().getUnusedID();
  145. g.addNode(newId);
  146. g.getNode(newId).addAttributes(attributes);
  147. String origElement = GraphHelper.propagateElementUndeletion(g, deletedNode, null);
  148. if (origElement != null) {
  149. g.getNode(newId).addAttribute("originalElement", origElement);
  150. }
  151. }
  152. for (MyEdge e : deletedEdges) {
  153. String sourceId = null;
  154. String targetId = null;
  155. attributes = new HashMap<String, Object>();
  156. for (String s : e.getAttributeKeySet()) {
  157. attributes.put(s, e.getAttribute(s));
  158. }
  159. String id = Main.getInstance().getUnusedID();
  160. if (deletedNode != null) {
  161. sourceId = (e.getSourceNode().getId().equals(deletedNode.getId())) ? newId : e.getSourceNode().getId();
  162. targetId = (e.getTargetNode().getId().equals(deletedNode.getId())) ? newId : e.getTargetNode().getId();
  163. } else {
  164. sourceId = e.getSourceNode().getId();
  165. targetId = e.getTargetNode().getId();
  166. }
  167. g.addEdge(id, sourceId, targetId, e.isDirected());
  168. g.getEdge(id).addAttributes(attributes);
  169. String origElement = GraphHelper.propagateElementUndeletion(g, e,
  170. g.getNode(newId).getAttribute("originalElement"));
  171. if (origElement != null) {
  172. g.getEdge(id).addAttribute("originalElement", origElement);
  173. }
  174. }
  175. deletedEdges = new LinkedList<>();
  176. deletedNode = null;
  177. }
  178. /**
  179. * returns a View of the Graph. The View lives in the Swing Thread and the
  180. * Graph in the Main thread.
  181. *
  182. *
  183. * @return a View of the Graph, inheriting from JPanel
  184. */
  185. public ViewPanel getView() {
  186. return view;
  187. }
  188. /**
  189. * Returns the ID of the currently selected Node.
  190. *
  191. * @return the node's ID
  192. */
  193. public String getSelectedNodeID() {
  194. return selectedNodeID;
  195. }
  196. /**
  197. * Returns the ID of the currently selected Edge.
  198. *
  199. * @return the edge's ID
  200. */
  201. public String getSelectedEdgeID() {
  202. return selectedEdgeID;
  203. }
  204. /**
  205. * Selects the Node with the given ID, resets Edge selection.
  206. *
  207. * @param nodeID
  208. * the ID of the Node to select
  209. */
  210. public void selectNode(String nodeID) {
  211. if (nodeID != null && g.getNode(nodeID) != null) {
  212. deselect();
  213. this.selectedNodeID = nodeID;
  214. MyNode n = g.getNode(nodeID);
  215. // set selected node color to red
  216. if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
  217. || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  218. n.changeAttribute("ui.style", "fill-color : #F00; size: 15px;");
  219. PropertiesManager.setItemsProperties();
  220. }
  221. }
  222. }
  223. /**
  224. * Selects the Edge with the given ID, resets Node selection.
  225. *
  226. * @param edgeID
  227. * the ID of the Edge to select
  228. */
  229. public void selectEdge(String edgeID) {
  230. if (edgeID != null && g.getEdge(edgeID) != null) {
  231. deselect();
  232. this.selectedEdgeID = edgeID;
  233. addClass(edgeID, "selected");
  234. PropertiesManager.setItemsProperties();
  235. }
  236. }
  237. /**
  238. * Deselect any currently selected nodes or edges.
  239. */
  240. // TODO call this before save
  241. protected void deselect() {
  242. // Set last selected Edge Color to Black
  243. if (getSelectedEdgeID() != null && g.getEdge(getSelectedEdgeID()) != null) {
  244. removeClass(getSelectedEdgeID(), "selected");
  245. }
  246. // Set last selected Node color to black
  247. else if (getSelectedNodeID() != null && g.getNode(getSelectedNodeID()) != null) {
  248. MyNode n = g.getNode(getSelectedNodeID());
  249. if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
  250. || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  251. String nodeType = n.getAttribute("ui.class");
  252. n.removeAttribute("ui.style");
  253. n.changeAttribute("ui.style", "fill-color: #000000; size: 15px;");
  254. n.changeAttribute("ui.class", nodeType.split("_")[0]);
  255. }
  256. }
  257. this.selectedNodeID = null;
  258. this.selectedEdgeID = null;
  259. }
  260. /**
  261. * Returns a reference to the Graph object managed by this visualizer.
  262. *
  263. * @return the graph
  264. */
  265. public MyGraph getGraph() {
  266. return g;
  267. }
  268. /**
  269. * Zooms in the view of the graph by 5 percent.
  270. */
  271. public void zoomIn() {
  272. zoom(-0.05);
  273. }
  274. /**
  275. * Zooms out the view of the graph by 5 percent.
  276. */
  277. public void zoomOut() {
  278. zoom(0.05);
  279. }
  280. /**
  281. * Zooms the view by the given Amount, positive values zoom out, negative
  282. * values zoom in.
  283. *
  284. * @param amount
  285. * the amount of zoom, should usually be between -0.2 and 0.2 for
  286. * reasonable zoom.
  287. */
  288. public void zoom(double amount) {
  289. view.getCamera().setViewPercent(view.getCamera().getViewPercent() * (1 + amount));
  290. }
  291. /**
  292. * Pumps the Pipe from the graphical Representation to the underlying Graph,
  293. * propagating all Changes made.
  294. */
  295. public void pumpIt() {
  296. fromViewer.pump();
  297. }
  298. @Override
  299. public String toString() {
  300. return "Visualizer for Graph \"" + g.getId() + "\"";
  301. }
  302. /**
  303. * Returns the current Save Path on Disk for the Graph.
  304. *
  305. * @return the current Path
  306. */
  307. public String getCurrentPath() {
  308. return currentPath;
  309. }
  310. /**
  311. * Sets the Save Path.
  312. *
  313. * @param currentPath
  314. * the new Path to set
  315. */
  316. public void setCurrentPath(String currentPath) {
  317. this.currentPath = currentPath;
  318. }
  319. /**
  320. * Adds a <b>Copy</b> of the given Edge to the graph. The Copy retains the
  321. * ID and all attributes.
  322. *
  323. * @param e
  324. * the Edge to be added to the graph
  325. */
  326. public void addEdge(MyEdge e) {
  327. HashMap<String, Object> attributes = new HashMap<>();
  328. for (String s : e.getAttributeKeySet()) {
  329. attributes.put(s, e.getAttribute(s));
  330. }
  331. g.addEdge(e.getId(), (MyNode) e.getSourceNode(), (MyNode) e.getTargetNode(), e.isDirected());
  332. g.getEdge(e.getId()).addAttributes(attributes);
  333. if (activeSubGraph != null) {
  334. activeSubGraph.addEdge(e.getId(), (MyNode) e.getSourceNode(), (MyNode) e.getTargetNode(), e.isDirected());
  335. activeSubGraph.getEdge(e.getId()).addAttributes(attributes);
  336. g.getEdge(e.getId()).addAttribute("originalElement", activeSubGraph.getId() + "+#" + e.getId());
  337. }
  338. }
  339. /**
  340. * Adds a <b>Copy</b> of the given Node to the graph. The Copy retains the
  341. * ID and all attributes.
  342. *
  343. * @param n
  344. * the Node to be added to the graph
  345. */
  346. public void addNode(MyNode n) {
  347. HashMap<String, Object> attributes = new HashMap<>();
  348. for (String s : n.getAttributeKeySet()) {
  349. attributes.put(s, n.getAttribute(s));
  350. }
  351. g.addNode(n.getId());
  352. g.getNode(n.getId()).addAttributes(attributes);
  353. if (activeSubGraph != null) {
  354. activeSubGraph.addNode(n.getId());
  355. activeSubGraph.getNode(n.getId()).addAttributes(attributes);
  356. g.getNode(n.getId()).addAttribute("originalElement", activeSubGraph.getId() + "+#" + n.getId());
  357. }
  358. }
  359. /**
  360. * Returns the smallest X Coordinate of any Node in the Graph.
  361. *
  362. * @return the smallest X Coordinate in the Graph
  363. */
  364. public double getMinX() {
  365. return g.getMinX();
  366. }
  367. /**
  368. * Returns the biggest X Coordinate of any Node in the Graph.
  369. *
  370. * @return the biggest X Coordinate in the Graph
  371. */
  372. public double getMaxX() {
  373. return g.getMaxX();
  374. }
  375. /**
  376. * Returns the smallest Y Coordinate of any Node in the Graph.
  377. *
  378. * @return the smallest Y Coordinate in the Graph
  379. */
  380. public double getMinY() {
  381. return g.getMinY();
  382. }
  383. /**
  384. * Returns the biggest Y Coordinate of any Node in the Graph.
  385. *
  386. * @return the biggest Y Coordinate in the Graph
  387. */
  388. public double getMaxY() {
  389. return g.getMaxY();
  390. }
  391. /**
  392. * Returns the Stylesheet used by the Graph.
  393. *
  394. * @return the Stylesheet in use
  395. */
  396. public String getStylesheet() {
  397. return stylesheet;
  398. }
  399. /**
  400. * Sets the Stylesheet to be used by the Graph.
  401. *
  402. * @param stylesheet
  403. * the new stylesheet to use
  404. */
  405. public void setStylesheet(String stylesheet) {
  406. this.stylesheet = stylesheet;
  407. g.removeAttribute("ui.stylesheet");
  408. String completeStylesheet = stylesheet;
  409. completeStylesheet = completeStylesheet.concat(StylesheetManager.getNodeStylesheet());
  410. completeStylesheet = completeStylesheet
  411. .concat(StylesheetManager.getLayerStyle((Layer) g.getAttribute("layer")));
  412. g.addAttribute("ui.stylesheet", completeStylesheet);
  413. }
  414. /**
  415. * adds the given listener to the underlying graph the listener will be
  416. * notified, when an Edge is added.
  417. *
  418. * @param e
  419. * the EdgeCreatedListener
  420. */
  421. public void addEdgeCreatedListener(EdgeCreatedListener e) {
  422. ((MyGraph) g).addEdgeCreatedListener(e);
  423. }
  424. /**
  425. * adds the given listener to the underlying graph the listener will be
  426. * notified, when a Node is added.
  427. *
  428. * @param n
  429. * the NodeCreatedListener
  430. */
  431. public void addNodeCreatedListener(NodeCreatedListener n) {
  432. ((MyGraph) g).addNodeCreatedListener(n);
  433. }
  434. /**
  435. * Updates the Stylesheet, causing any changes to it to come into effect.
  436. */
  437. public void updateStylesheet() {
  438. setStylesheet(this.stylesheet);
  439. }
  440. /**
  441. * Sets typeofNode as the ui.class of all Nodes.
  442. *
  443. */
  444. public void convertUiClass() {
  445. Collection<MyNode> allNodes = g.getNodeSet();
  446. for (MyNode n : allNodes) {
  447. if (n.hasAttribute("typeofNode")) {
  448. n.addAttribute("ui.class", n.getAttribute("typeofNode").toString());
  449. }
  450. }
  451. }
  452. /**
  453. * Create Edges based on CreateMode.
  454. *
  455. * @param id
  456. * The ID for the newly created Edge
  457. */
  458. public void createEdges(String id) {
  459. switch (Main.getInstance().getCreationMode()) {
  460. case CREATE_DIRECTED_EDGE:
  461. case CREATE_UNDIRECTED_EDGE:
  462. if (lastClickedID == null) {
  463. lastClickedID = id;
  464. if (!selectNodeForEdgeCreation(lastClickedID)) {
  465. lastClickedID = null;
  466. }
  467. } else if (id.equals(lastClickedID) || createEdge(id, lastClickedID)) {
  468. deselectNodesAfterEdgeCreation(lastClickedID);
  469. lastClickedID = null;
  470. }
  471. break;
  472. default:
  473. break;
  474. }
  475. PropertiesManager.setItemsProperties();
  476. }
  477. /**
  478. * creates a edge between two nodes.
  479. *
  480. * @author MW
  481. * @param to
  482. * ID of the destination node
  483. * @param from
  484. * ID of the origin node
  485. * @return true if the edge was created. false otherwise
  486. */
  487. protected boolean createEdge(String to, String from) {
  488. if (getGraph().getNode(from).hasEdgeBetween(to))
  489. return false;
  490. String newID = Main.getInstance().getUnusedID();
  491. if (Main.getInstance().getCreationMode() == CreationMode.CREATE_DIRECTED_EDGE) {
  492. getGraph().addEdge(newID, from, to, true);
  493. Debug.out("Created an directed edge with Id " + newID + " between " + from + " and " + to);
  494. } else {
  495. getGraph().addEdge(newID, from, to);
  496. Debug.out("Created an undirected edge with Id " + newID + " between " + from + " and " + to);
  497. }
  498. selectEdge(newID);
  499. return true;
  500. }
  501. /**
  502. * Selects a Node as the starting point for creating a new Edge.
  503. *
  504. * @param nodeID
  505. * the ID of the Node to select
  506. */
  507. protected boolean selectNodeForEdgeCreation(String nodeID) {
  508. deselect();
  509. MyNode n = getGraph().getNode(nodeID);
  510. if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED) || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  511. n.changeAttribute("ui.style", "fill-color:green; size: 15px;");
  512. }
  513. return true;
  514. }
  515. /**
  516. * Reset the Selection of the Node after Edge has been successfully created.
  517. *
  518. * @param nodeID
  519. * the Id of the node to deselect.
  520. */
  521. protected void deselectNodesAfterEdgeCreation(String nodeID) {
  522. MyNode n = getGraph().getNode(nodeID);
  523. if (n == null) {
  524. return;
  525. }
  526. if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED) || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  527. n.removeAttribute("ui.style");
  528. n.changeAttribute("ui.style", "fill-color: #000000; size: 15px;");
  529. }
  530. }
  531. /**
  532. * Resets the selction of the Node for Edge selection
  533. */
  534. public void deselectEdgeCreationNodes() {
  535. if (lastClickedID != null)
  536. deselectNodesAfterEdgeCreation(lastClickedID);
  537. lastClickedID = null;
  538. }
  539. public void setActiveSubGraph(String id) {
  540. for (MyGraph subGraph : g.getAllSubGraphs()) {
  541. if (subGraph.getId().equals(id)) {
  542. activeSubGraph = subGraph;
  543. return;
  544. }
  545. }
  546. }
  547. protected boolean addClass(String id, String className) {
  548. Element e = getGraph().getEdge(id);
  549. if (e == null)
  550. e = getGraph().getNode(id);
  551. if (e == null)
  552. return false;
  553. String eClass = e.getAttribute("ui.class");
  554. if (eClass == null || eClass.equals(""))
  555. eClass = className;
  556. else if (!(eClass.equals(className) || eClass.startsWith(className.concat(", "))
  557. || eClass.contains(", ".concat(className))))
  558. eClass = className.concat(", ").concat(eClass);
  559. e.addAttribute("ui.class", eClass);
  560. Debug.out("added " + className + ": " + eClass);
  561. return true;
  562. }
  563. protected boolean removeClass(String id, String className) {
  564. Element e = getGraph().getEdge(id);
  565. if (e == null)
  566. e = getGraph().getNode(id);
  567. if (e == null)
  568. return false;
  569. String eClass = e.getAttribute("ui.class");
  570. if (eClass == null || eClass.equals(className))
  571. eClass = "";
  572. else
  573. eClass = eClass.replace(className.concat(", "), "").replace(", ".concat(className), "");
  574. e.addAttribute("ui.class", eClass);
  575. Debug.out("removed " + className + ": " + eClass);
  576. return true;
  577. }
  578. protected boolean toggleClass(String id, String className) {
  579. Element e = getGraph().getEdge(id);
  580. if (e == null)
  581. e = getGraph().getNode(id);
  582. if (e == null)
  583. return false;
  584. String eClass = e.getAttribute("ui.class");
  585. if (eClass == null || !(eClass.equals(className) || eClass.startsWith(className.concat(", "))
  586. || eClass.contains(", ".concat(className))))
  587. return addClass(id, className);
  588. return removeClass(id, className);
  589. }
  590. protected boolean hasClass(String id, String className) {
  591. Element e = getGraph().getEdge(id);
  592. if (e == null)
  593. e = getGraph().getNode(id);
  594. if (e == null)
  595. return false;
  596. String eClass = e.getAttribute("ui.class");
  597. return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
  598. || eClass.contains(", ".concat(className))));
  599. }
  600. protected boolean hasClass(MyEdge e, String className) {
  601. if (e == null)
  602. return false;
  603. String eClass = e.getAttribute("ui.class");
  604. return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
  605. || eClass.contains(", ".concat(className))));
  606. }
  607. protected boolean hasClass(MyNode n, String className) {
  608. if (n == null)
  609. return false;
  610. String nClass = n.getAttribute("ui.class");
  611. /*
  612. * TODO: nochmal angucken, wenn CSS Manager steht, ist gerade gehackt
  613. * damit, Vorführung läuft. return (nClass != null &&
  614. * (nClass.equals(className) ||
  615. * nClass.startsWith(className.concat(", ")) ||
  616. * nClass.contains(", ".concat(className))));
  617. */
  618. return (nClass != null && nClass.contains(className));
  619. }
  620. }