GraphManager.java 19 KB

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