LayeredGraphNode.java 12 KB

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