LayeredGraphNode.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. package graph;
  2. import java.awt.Color;
  3. import java.util.ArrayList;
  4. import org.eclipse.elk.graph.ElkEdge;
  5. import org.eclipse.elk.graph.ElkNode;
  6. import bk.LayoutType;
  7. /**
  8. * Ein Interface, welches die Methoden eines Knotens aus einem gelayerten
  9. * Graphen beschreibt (Ein Knoten kann dabei auch einen weiteren Graphen
  10. * beinhalten)
  11. *
  12. * @author kolja
  13. *
  14. */
  15. public interface LayeredGraphNode {
  16. /**
  17. * Gibt den originalen Elk Knoten zur�ck
  18. *
  19. * @return den originalen Elk Knoten
  20. */
  21. public ElkNode getOriginalNode();
  22. /**
  23. * setter for the field mouseOver
  24. * @param mouseOver the new value
  25. */
  26. public void setMouseOver( boolean mouseOver );
  27. /**
  28. * getter for the field mouseOver
  29. * @return current value of the field
  30. */
  31. public boolean isMouseOver();
  32. /**
  33. * set the shift of this node to the given value in the given layout
  34. * or in all layouts if the argument is null.
  35. *
  36. * @param shift
  37. * the value to set to
  38. * @param layout
  39. * the layout
  40. */
  41. public void setShift(double shift, LayoutType layout);
  42. /**
  43. * get the shift of this node in the given layout
  44. *
  45. * @param layout
  46. * the layout
  47. * @return the shift
  48. */
  49. public double getShift(LayoutType layout);
  50. /**
  51. * set the sink of this node in the given layout
  52. * or in all layouts if the argument is null.
  53. *
  54. * @param sink
  55. * the sink
  56. * @param layout
  57. * the layout
  58. */
  59. public void setSink(LayeredGraphNode sink, LayoutType layout);
  60. /**
  61. * get the sink of this node in the given layout
  62. *
  63. * @param layout
  64. * the layout
  65. * @return the sink
  66. */
  67. public LayeredGraphNode getSink(LayoutType layout);
  68. /**
  69. * checks if the x coordinate of the node is defined in the given layout
  70. *
  71. * @param layout
  72. * the layout
  73. * @return true iff the x coordinate is undefined
  74. */
  75. public boolean isXUndefined(LayoutType layout);
  76. /**
  77. * sets the align-attribute (the next node in the block) in the given layout
  78. * or in all layouts if the argument is null.
  79. *
  80. * @param align
  81. * the next node in the block
  82. * @param layout
  83. * the layout
  84. */
  85. public void setAlign(LayeredGraphNode align, LayoutType layout);
  86. /**
  87. * get the next node in the block of this node (in the given layout)
  88. *
  89. * @param layout
  90. * the layout
  91. * @return the next node
  92. */
  93. public LayeredGraphNode getAlign(LayoutType layout);
  94. /**
  95. * sets the root node of this node in the given layout which identifies the
  96. * block that it belongs to
  97. * or in all layouts if the argument is null.
  98. *
  99. * @param root
  100. * the new root node
  101. * @param layout
  102. * the layout
  103. */
  104. public void setRoot(LayeredGraphNode root, LayoutType layout);
  105. /**
  106. * get the root node of this node in the given layout which identifies the
  107. * block that it belongs to
  108. *
  109. * @param layout
  110. * the layout
  111. * @return the root node
  112. */
  113. public LayeredGraphNode getRoot(LayoutType layout);
  114. /**
  115. * set the name of this node
  116. *
  117. * @param name
  118. * the name
  119. */
  120. public void setName(String name);
  121. /**
  122. * get the name of this node
  123. *
  124. * @return the name
  125. */
  126. public String getName();
  127. /**
  128. * set the display color of this node in the given layout
  129. * or in all layouts if the argument is null.
  130. *
  131. * @param c
  132. * the color
  133. * @param layout
  134. * the layout
  135. */
  136. public void setColor(Color c, LayoutType layout);
  137. /**
  138. * check the display color of this node in the given layout.
  139. * @param layout the layout
  140. * @return the color
  141. */
  142. public Color getColor(LayoutType layout);
  143. /**
  144. * check the color of this nodes class in the given layout
  145. * or in all layouts if the argument is null.
  146. * @param layout the layout
  147. * @return the color
  148. */
  149. public Color getClassColor( LayoutType layout );
  150. /**
  151. * mark the node as "selected" in the given layout
  152. * or in all layouts if the argument is null.
  153. * @param layout the layout
  154. */
  155. public void setSelected(LayoutType layout);
  156. /**
  157. * checks if the node is selected in the given layout
  158. * @param layout the layout
  159. * @return true, iff it is selected
  160. */
  161. public boolean isSelected(LayoutType layout);
  162. /**
  163. * sets whether this node is a dummy node
  164. * @param dummy is it?
  165. */
  166. public void setDummyNode(boolean dummy);
  167. /**
  168. * checks whether this node is a dummy node
  169. * @return is it?
  170. */
  171. public boolean isDummyNode();
  172. /**
  173. * unselects recursively all contained nodes in all subgraphs of this node
  174. */
  175. public void unselectGraph();
  176. /**
  177. * Setzt den Index des Layers, zu dem der Knoten geh�ren soll
  178. *
  179. * @param index
  180. * Der Index mit 0 beginnend
  181. */
  182. public void setLayer(int index);
  183. /**
  184. * Gibt den Index des Layers zur�ck, dem dieser Knoten angeh�rt
  185. *
  186. * @return Der Index des Layers mit 0 beginnend
  187. */
  188. public int getLayer();
  189. /**
  190. * Entfernt den Knoten aus dem Graphen
  191. */
  192. public void remove();
  193. /**
  194. * Ermittelt eine Liste von Kanten, die an diesem Knoten beginnen
  195. *
  196. * @return Liste mit Kanten
  197. */
  198. public ArrayList<LayeredGraphEdge> getOutgoingEdges();
  199. /**
  200. * Ermittelt eine Liste von Kanten, die an diesem Knoten enden
  201. *
  202. * @return Liste mit Kanten
  203. */
  204. public ArrayList<LayeredGraphEdge> getIncomingEdges();
  205. /**
  206. * Ermittelt eine Liste von Kanten, die an diesem Knoten beginnen
  207. *
  208. * @return Liste mit Kanten sortiert nach den positionen der Endknoten in
  209. * ihrem layer
  210. */
  211. public ArrayList<LayeredGraphEdge> getSortedOutgoingEdges();
  212. /**
  213. * Ermittelt eine Liste von Kanten, die an diesem Knoten enden
  214. *
  215. * @return Liste mit Kanten sortiert nach den positionen der Startknoten in
  216. * ihrem layer
  217. */
  218. public ArrayList<LayeredGraphEdge> getSortedIncomingEdges();
  219. /**
  220. * Gibt den Knoten zur�ck, zu dessen Subgraph dieser Knoten geh�rt
  221. *
  222. * @return Der Elternknoten
  223. */
  224. public LayeredGraphNode parent();
  225. /**
  226. * Legt den Knoten fest, zu dessen Subgraph dieser Knoten geh�rt
  227. *
  228. * @param parent
  229. * Der Elternknoten
  230. */
  231. public void setParent(LayeredGraphNode parent);
  232. /**
  233. * Legt die X Koordinate des Knotens fest
  234. *
  235. * @param x
  236. * die X Koordinate in Pixeln
  237. */
  238. public void setX(double x, boolean def, LayoutType layout);
  239. /**
  240. * Legt die Y Koordinate des Knotens Fest
  241. *
  242. * @param y
  243. * die Y Koordinate in Pixeln
  244. */
  245. public void setY(double y, LayoutType layout);
  246. /**
  247. * Gibt die X Koordinate zur�ck
  248. *
  249. * @return die X Koordinate in Pixeln zur�ck
  250. */
  251. public double getX(LayoutType layout);
  252. /**
  253. * Gibt die Y Koordinate zur�ck
  254. *
  255. * @return die Y Koordinate in Pixeln zur�ck
  256. */
  257. public double getY(LayoutType layout);
  258. /**
  259. * Gibt die Breite des Knotens zur�ck
  260. *
  261. * @return die Breite in Pixeln
  262. */
  263. public double getWidth(LayoutType layout);
  264. /**
  265. * Gibt die H�he des Knotens zur�ck
  266. *
  267. * @return die H�he in Pixeln
  268. */
  269. public double getHeight(LayoutType layout);
  270. public void setWidth(double w, LayoutType layout);
  271. public void setHeight(double h, LayoutType layout);
  272. // for subgraph
  273. /**
  274. * Ermittelt den Index des Layers, dem ein Knoten angeh�rt
  275. *
  276. * @param n
  277. * der Knoten, zu dem der Layerindex gesucht wird
  278. * @return der Index des Layers mit 0 beginnend
  279. */
  280. public int getNodeLayer(LayeredGraphNode n);
  281. /**
  282. * Sortiert einen Layer nach bestimmten Gewichten Die Knoten mit dem
  283. * geringsten Gewicht kommen vor den Knoten mit gr��erem Gewicht
  284. *
  285. * @param indizes
  286. * Eine Liste mit einem Gewicht f�r jeden Knoten
  287. * @param layerIndex
  288. * Der Index des Layers, der sortiert werden soll
  289. */
  290. public void setOrderedLayer(ArrayList<Double> indizes, int layerIndex);
  291. /**
  292. * Legt fest zu welchem Layer ein bestimmter Knoten geh�rt
  293. *
  294. * @param n
  295. * Der Knoten
  296. * @param index
  297. * Der Index des Layers
  298. */
  299. public void setNodeLayer(LayeredGraphNode n, int index);
  300. /**
  301. * @return Eine Liste mit allen Kanten des Subgraphen
  302. */
  303. public ArrayList<LayeredGraphEdge> getContainedEdges();
  304. /**
  305. * @return Eine Liste mit allen Knoten des Subgraphen
  306. */
  307. public ArrayList<LayeredGraphNode> getContainedNodes();
  308. /**
  309. * @return Eine Liste mit allen Knoten des Subgraphen sortiert nach Layern und
  310. * Positionen
  311. */
  312. public ArrayList<LayeredGraphNode> getSortedContainedNodes();
  313. /**
  314. * @return Eine Liste mit allen Layern des Subgraphen
  315. */
  316. public ArrayList<ArrayList<LayeredGraphNode>> getContainedLayers();
  317. /**
  318. * Entfernt eine Kante aus dem Subgraph
  319. *
  320. * @param e
  321. * die Kante, die entfernt werden soll
  322. */
  323. public void removeEdge(LayeredGraphEdge e);
  324. /**
  325. * Entfernt einen Knoten aus dem Subgraph
  326. *
  327. * @param n
  328. * der Knoten, die entfernt werden soll
  329. */
  330. public void removeNode(LayeredGraphNode n);
  331. /**
  332. * Ermittelt eine Liste von ausgehenden Kanten eines Knotens
  333. *
  334. * @param n
  335. * Der Knoten
  336. * @return Die Liste mit Kanten
  337. */
  338. public ArrayList<LayeredGraphEdge> getOutgoingEdges(LayeredGraphNode n);
  339. /**
  340. * Ermittelt eine Liste von ausgehenden Kanten eines Knotens
  341. *
  342. * @param n
  343. * Der Knoten
  344. * @return Die Liste mit Kanten sortiert nach den positionen der Endknoten in
  345. * ihren Layern
  346. */
  347. public ArrayList<LayeredGraphEdge> getSortedOutgoingEdges(LayeredGraphNode n);
  348. /**
  349. * Ermittelt eine Liste von eingehenden Kanten eines Knotens
  350. *
  351. * @param n
  352. * Der Knoten
  353. * @return Die Liste mit Kanten
  354. */
  355. public ArrayList<LayeredGraphEdge> getIncomingEdges(LayeredGraphNode n);
  356. /**
  357. * Ermittelt eine Liste von eingehenden Kanten eines Knotens
  358. *
  359. * @param n
  360. * Der Knoten
  361. * @return Die Liste mit Kanten sortiert nach den positionen der Startknoten
  362. * in ihren Layern
  363. */
  364. public ArrayList<LayeredGraphEdge> getSortedIncomingEdges(LayeredGraphNode n);
  365. /**
  366. * Ermittelt die Kante zwischen zwei Knoten
  367. * @param source Der Source Knoten der Kante
  368. * @param target Der Target Knoten der Kante
  369. * @return noll, falls die Kante nicht existiert. Sonst die Kante von source nach target
  370. */
  371. public LayeredGraphEdge findEdgeBetween( LayeredGraphNode source, LayeredGraphNode target );
  372. /**
  373. * F�gt einen neuen Knoten zum Subgraph hinzu
  374. *
  375. * @param original
  376. * Der originale Elk Knoten
  377. * @return Der neu erzeugte Knoten
  378. */
  379. public LayeredGraphNode createNode(ElkNode original);
  380. /**
  381. * F�gt eine neue Kante zum Subgraph hinzu
  382. *
  383. * @param original
  384. * Die Originale Elk Kante
  385. * @param sources
  386. * Eine Liste mit Startknoten
  387. * @param targets
  388. * Eine Liste mit Endknoten
  389. * @return Die neue Kante
  390. */
  391. public LayeredGraphEdge createEdge(ElkEdge original, ArrayList<LayeredGraphNode> sources,
  392. ArrayList<LayeredGraphNode> targets);
  393. /**
  394. * F�gt eine neue Kante zum Subgraph hinzu
  395. *
  396. * @param original
  397. * Die Originale Elk Kante
  398. * @param source
  399. * Der Startknoten
  400. * @param target
  401. * Der Endknoten
  402. * @return Die neue Kante
  403. */
  404. public LayeredGraphEdge createSimpleEdge(ElkEdge original, LayeredGraphNode source,
  405. LayeredGraphNode target);
  406. /**
  407. * Findet zu einer Originalen Kante eine Layered Kante
  408. *
  409. * @param original
  410. * die originale Kante
  411. * @return die layered Kante
  412. */
  413. public LayeredGraphEdge findEdgeFromOriginal(Object original);
  414. /**
  415. * Findet zu einem Originalen Knoten einen Layered Knoten
  416. *
  417. * @param original
  418. * der originale Knoten
  419. * @return der layered Knoten
  420. */
  421. public LayeredGraphNode findNodeFromOriginal(Object original);
  422. /**
  423. * Find a node with a given name whose parent node is this node.
  424. * @param name the name to search for
  425. * @return the node or {@code null} if no node was found.
  426. */
  427. public LayeredGraphNode findNodeByName(String name);
  428. /**
  429. * F�gt einen Knoten zum Subgraphen hinzu
  430. *
  431. * @param n
  432. * Der neue Knoten
  433. */
  434. public void addNode(LayeredGraphNode n);
  435. /**
  436. * F�gt eine Kante zum Subgraphen hinzu
  437. *
  438. * @param e
  439. * Die neue Kante
  440. */
  441. public void addEdge(LayeredGraphEdge e);
  442. }