Changes for page KIML
Last modified by Richard Kreissig on 2025/01/30 12:04
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -178,9 +178,9 @@ 178 178 179 179 {{code language="java"}} 180 180 progressMonitor.begin("Login_name layouter", 1); 181 -KShapeLayout parentLayout = layoutNode.getData(KShapeLayout.class);181 +KShapeLayout parentLayout = parentNode.getData(KShapeLayout.class); 182 182 183 -float objectSpacing = parentLayout.getP Roperty(LayoutOptions.SPACING);183 +float objectSpacing = parentLayout.getProperty(LayoutOptions.SPACING); 184 184 if (objectSpacing < 0) { 185 185 objectSpacing = DEFAULT_SPACING; 186 186 } ... ... @@ -195,79 +195,43 @@ 195 195 progressMonitor.done(); 196 196 {{/code}} 197 197 ))) 198 -1. ((( 199 -Put the following code at the end of the {{code language="none"}}doLayout(...){{/code}} method: 198 +1. It is now time to write the code that places the nodes. Here's two suggestions for how you can place them:\\ 199 +1*. The simplest way is to place nodes in a row, next to each other. To make this more interesting, you could also place the nodes along the graph of a Sine function. 200 +1*. Another way might be to place them in a square or a circle. You would have to think about how exactly to align the nodes, which may well vary in size. 200 200 201 -{{code language="java"}} 202 -progressMonitor.done(); 203 -{{/code}} 204 -))) 202 +{{info title="Tips"}} 203 +The following tips might come in handy... 205 205 206 - 205 +* Read the documentation of the [[KGraph>>doc:KIELER.KGraph Meta Model]] and [[KLayoutData>>doc:KIELER.KLayoutData Meta Model]] meta models. The input to the layout algorithm is a {{code language="none"}}KNode{{/code}} that has child {{code language="none"}}KNode{{/code}}s for every node in the graph. Iterate over these nodes by iterating over the {{code language="none"}}getChildren(){{/code}} list of the {{code language="none"}}parentNode{{/code}} argument. 206 +* ((( 207 +Retrieve the size of a node and set its position later using the following code: 207 207 208 -This exercise will introduce the usage of the Eclipse Plugin Development Environment for developing new layout algorithms to be used in Eclipse diagram editors. Replace each <login> by your own login name (e.g. msp), and each <Login> by your login name with capitalized first letter (e.g. Msp). For any questions contact msp. 209 +{{code language="java"}} 210 +KShapeLayout nodeLayout = node.getData(KShapeLayout.class); 209 209 210 -1. ((( 211 -Implement the layout provider class 212 -1. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)Add the following constant to the class: 213 -1. (% class="code" %) 214 -((( 215 -(% class="cm" style="color: rgb(153,153,136);" %)/~*~* default value for spacing between nodes. */(% class="kd" %)privatestaticfinal(% class="kt" style="color: rgb(68,85,136);" %)float(% class="o" %)=(% class="mf" style="color: rgb(0,153,153);" %)15.0f(% class="o" %); 212 +// Retrieving the size 213 +float width = nodeLayout.getWidth(); 214 +float height = nodeLayout.getHeight(); 216 216 217 -{{{ 218 - DEFAULT_SPACING 219 -}}} 216 +// Setting the position 217 +nodeLayout.setXpos(x); 218 +nodeLayout.setYpos(y); 219 +{{/code}} 220 220 ))) 221 -1. Write the following lines at the beginning of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %) 222 -((( 223 -(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)begin(% class="o" %)((% class="s" style="color: rgb(187,136,68);" %)"<Login> Layouter"(% class="o" %),(% class="mi" style="color: rgb(0,153,153);" %)1(% class="o" %));=.(% class="na" style="color: rgb(0,128,128);" %)getData(% class="o" %)(.(% class="na" style="color: rgb(0,128,128);" %)class(% class="o" %));(% class="kt" style="color: rgb(68,85,136);" %)float(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getProperty(% class="o" %)(.(% class="na" style="color: rgb(0,128,128);" %)SPACING(% class="o" %));(% class="k" %)if(% class="o" %)(<(% class="mi" style="color: rgb(0,153,153);" %)0(% class="o" %)){=;}(% class="kt" style="color: rgb(68,85,136);" %)float(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getProperty(% class="o" %)(.(% class="na" style="color: rgb(0,128,128);" %)BORDER_SPACING(% class="o" %));(% class="k" %)if(% class="o" %)(<(% class="mi" style="color: rgb(0,153,153);" %)0(% class="o" %)){=;} 221 +* {{code language="none"}}objectSpacing{{/code}} is the spacing to be left between each pair of nodes. 222 +* {{code language="none"}}borderSpacing{{/code}} is the spacing to be left to the borders of the drawing. The top left node's coordinates must therefore be at least {{code language="none"}}(borderSpacing, borderSpacing){{/code}}. 223 +* At the end of the method, set the width and height of {{code language="none"}}parentLayout{{/code}} such that it is large enough to hold the whole drawing, including borders. 224 +* A complete layout algorithm will of course also route the edges between the nodes. Ignore that for now – you will do this at a later step. 225 +{{/info}} 224 224 225 -{{{ progressMonitor 226 - KShapeLayout parentLayout layoutNodeKShapeLayout 227 - objectSpacing parentLayoutLayoutOptions 228 - objectSpacing 229 - objectSpacing DEFAULT_SPACING 230 - 231 - borderSpacing parentLayoutLayoutOptions 232 - borderSpacing 233 - borderSpacing DEFAULT_SPACING 234 - 235 -}}} 236 -))) 237 -1. Write the following line at the end of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %) 238 -((( 239 -(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)done(% class="o" %)(); 227 + 240 240 241 -{{{ progressMonitor 242 -}}} 243 -))) 244 -1. ((( 245 -Implement the rest of the layouter such that the nodes of the input graph are all put in a row. 246 -* See the [[KGraph>>doc:KIELER.KGraph Meta Model]] and [[KLayoutData>>doc:KIELER.KLayoutData Meta Model]] data structures: the input is a KNode and holds the nodes of the graph in its list of children 247 -* Iterate over the nodes in the {{code language="none"}}getChildren(){{/code}} list of the {{code language="none"}}layoutNode{{/code}} input 248 -* Retrieve the size of a node using the following code:(% class="code" %) 249 -((( 250 -(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getData(% class="o" %)(.(% class="na" style="color: rgb(0,128,128);" %)class(% class="o" %));(% class="kt" style="color: rgb(68,85,136);" %)float(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getWidth(% class="o" %)();(% class="kt" style="color: rgb(68,85,136);" %)float(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getHeight(% class="o" %)(); 229 + 251 251 252 -{{{ KShapeLayout nodeLayout nodeKShapeLayout 253 - width nodeLayout 254 - height nodeLayout 255 -}}} 256 -))) 257 -* Set the position (x, y) of a node's upper left corner using the following code:(% class="code" %) 258 -((( 259 -(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)setXpos(% class="o" %)();.(% class="na" style="color: rgb(0,128,128);" %)setYpos(% class="o" %)(); 231 + 260 260 261 -{{{ nodeLayoutx 262 - nodeLayouty 263 -}}} 264 -))) 265 -* {{code language="none"}}objectSpacing{{/code}} shall be the spacing to be left between each pair of nodes. 266 -* {{code language="none"}}borderSpacing{{/code}} shall be the spacing to be left to the borders of the drawing: the first node's coordinates shall be (borderSpacing, borderSpacing). 267 -* At the end of the method, set the width and height of {{code language="none"}}parentLayout{{/code}} so that it is large enough to hold the whole drawing, including borders. 268 -* Edges may be ignored for now. 269 -))) 270 -))) 233 +This exercise will introduce the usage of the Eclipse Plugin Development Environment for developing new layout algorithms to be used in Eclipse diagram editors. Replace each <login> by your own login name (e.g. msp), and each <Login> by your login name with capitalized first letter (e.g. Msp). For any questions contact msp. 234 + 271 271 1. Open the file META-INF/MANIFEST.MF //→// //Extensions// tab\\ 272 272 11. Add an extension for de.cau.cs.kieler.kiml.layout.layoutProviders 273 273 11. Right-click the extension //→// //New// //→// //layoutProvider//
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -616047 41 +6160476 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/616047 4/KIML1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/6160476/KIML