LayeredGraphNode.java 10 KB

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