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
-
... ... @@ -1,10 +1,16 @@ 1 +{{warning title="Work in Progress"}} 2 +This tutorial is still being worked on. Don't start working on it just yet. 3 +{{/warning}} 4 + 1 1 Welcome to the second tutorial! We will work our way through installing a proper Eclipse setup and developing a first very basic layout algorithm. The layout algorithm will integrate with KIML (KIELER Infrastructure for Meta-Layout), our very own framework that connects graphical editors with layout algorithms. Once you're finished, you should be able to create new Eclipse plug-ins and know how to write layout algorithms for KIML. And you should have a running Eclipse-based application that should look something like this: 2 2 3 -[[image:attach:le_app_formidable.png]] 4 - 5 5 6 6 7 7 {{warning title="ToDo"}} 10 +Insert screen shot of final application. 11 +{{/warning}} 12 + 13 +{{warning title="ToDo"}} 8 8 Insert link to presentation slides. 9 9 {{/warning}} 10 10 ... ... @@ -218,83 +218,75 @@ 218 218 * 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. 219 219 {{/info}} 220 220 221 - Beforeyou can test your layout code, you will have to register your new layout provider with KIML.227 + 222 222 223 -1. Open the {{code language="none"}}META-INF/MANIFEST.MF{{/code}} file again and switch to the //Extensions// tab. 224 -1. Add an extension for {{code language="none"}}de.cau.cs.kieler.kiml.layout.layoutProviders{{/code}}. 225 -1. Right-click the extension and click //New// > //layoutAlgorithm//. 226 -1. Set the name to {{code language="none"}}Login_name Test Layouter{{/code}} and the class to your layout provider class name. 227 -1. Right-click the new //layoutAlgorithm// and click //New// > //knownOption//. Set option to {{code language="none"}}de.cau.cs.kieler.spacing{{/code}}. 228 -1. Add another //knownOption// for {{code language="none"}}de.cau.cs.kieler.borderSpacing{{/code}}. 229 -1. Save the editor. 229 + 230 230 231 - Wewill now have to add a new run configuration that will start an Eclipse instance with your layout code loaded into the application, ready to be used.231 + 232 232 233 -1. Click //Run// > //Debug Configurations...// 234 -1. Right-click //Eclipse Application// and click //New//. Set the configuration's name to {{code language="none"}}Layout Test{{/code}}. 235 -1. In the //Arguments// tab, make sure the the program arguments include {{code language="none"}}-debug{{/code}} and {{code language="none"}}-consoleLog{{/code}}. 236 -1. On the //Plug-ins// tab, set //Launch with// to //plug-ins selected below only//. Click //Deselect All//, check the //Workspace// item in the tree, and click //Add Required Plug-ins//. 237 -1. Click //Apply// to save your changes and then //Debug// to start an Eclipse instance to test with. 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. 238 238 239 -Test the layouter in your new Eclipse instance: 240 - 241 -1. Click //New// > //Project...// > //General// > //Project// and set the project name to something like {{code language="none"}}Test{{/code}}. 242 -1. Right-click the new project and click //New// > //Empty KEG Graph//. Enter a meaningful name and click //Finish//. 243 -1. Put a few nodes into the diagram. To properly test your code, you will want to vary the sizes of the nodes. It may also be a good idea to get into the habit of giving each node a different name, such as N1, N2, etc. This will help you later if you have to debug your algorithm. 244 -1. Open the //Layout// view through //Window// > //Show View// > //Other...// > //KIELER Layout// > //Layout//. 245 -1. With your KEG diagram selected, set the //Layout Algorithm// option in the //Layout// view to your new algorithm. 246 -1. Save your KEG diagram. 247 -1. Trigger automatic layout by clicking the layout button in the toolbar, or by hitting Ctrl+R L (first Ctrl+R, then L). 248 - 249 -{{info title="Tip"}} 250 -You can see the direct output of your algorithm and the time it took to run it through the //Layout Graph// and //Layout Time// views. The views are available through the {{code language="none"}}de.cau.cs.kieler.kiml.debug{{/code}} plug-in, which can be found in the plugins-dev folder of the KIML repository. You will learn more about debugging layout algorithms in a layout tutorial or presentation. 251 -{{/info}} 252 - 253 -Once you're satisfied with your node placement code, it's time to take care of edge routing. 254 - 235 +1. Open the file META-INF/MANIFEST.MF //→// //Extensions// tab\\ 236 +11. Add an extension for de.cau.cs.kieler.kiml.layout.layoutProviders 237 +11. Right-click the extension //→// //New// //→// //layoutProvider// 238 +11. Set //name// to //<Login> Test Layouter//, //class// to de.cau.cs.rtprak.<login>.tutorial2.<Login>LayoutProvider 239 +11. Right-click the new //layoutProvider// //→// //New// //→// //knownOption//, set //option// to de.cau.cs.kieler.spacing 240 +11. Add another //knownOption//, set to de.cau.cs.kieler.borderSpacing 241 +1. //Run// //→// //Run Configurations...// //→// right-click //Eclipse Application// //→// //New//\\ 242 +11. Name: //Layout// 243 +11. For testing the layouter, a new workspace location will be created; you may configure its destination in //Workspace Data// //→// //Location// 244 +11. Add the program arguments {{code language="none"}}-debug -consoleLog{{/code}} in the //Arguments// tab. 245 +11. Go to //Plug-ins// tab, select //Launch with: plug-ins selected below only// 246 +11. //Deselect All//, activate //Workspace// checkbox, //Add Required Plug-ins//, //Apply//, //Run// 247 +1. Test the layouter in the new Eclipse instance:\\ 248 +11. //New// //→// //Project...// //→// //General// //→// //Project//, name //test// 249 +11. Right-click test project //→// //New// //→// //Other...// //→// //KEG Diagram// ((% style="color: rgb(255,0,0);" %)TODO: if graphs shall be created in another way, describe it here(%%)) 250 +11. Create a graph using the palette on the right. 251 +11. //Window// //→// //Show View// //→// //Other...// //→// //KIELER// //→// //Layout// 252 +11. While the graph diagram is open, set //Layout Provider or Type// in the //Layout// view to //<Login> Test Layouter.// 253 +11. Open the additional views //Layout Graph// and //Layout Time.// 254 +11. Trigger layout with the //KIELER Layout// button in the toolbar or Ctrl+R L (first Ctrl+R, then L). 255 +11. See the direct input and output of your algorithm in the //Layout Graph// view. 256 +11. See the execution time analysis in the //Layout Time// view. 255 255 1. ((( 256 -Add a new method that will implement the edge routing using the following skeleton code: 258 +Implement another class //EdgeRouter//. 259 +1. Add the following method:(% class="code" %) 260 +((( 257 257 258 -{{code language="java"}} 259 -/** 260 - * Routes the edges connecting the nodes in the given graph. 261 - * 262 - * @param parentNode the graph whose edges to route. 263 - * @param yStart y coordinate of the start of the edge routing area. 264 - * @param objectSpacing the object spacing. 265 - * @return height used for edge routing. 266 - */ 267 -private float routeEdges(final KNode parentNode, final float yStart, final float objectSpacing) { 268 - // TODO: Implement edge routing 262 +\\\\\\\\\\\\\\ 269 269 270 - return 0; 271 -} 272 -{{/code}} 264 +{{{ /** * Route the edges that are connected with the children of the given node. * @param parentNode the parent node of the input graph */ public void routeEdges(final KNode parentNode) { getMonitor().begin("Edge Routing", 1); getMonitor().done(); }}}} 273 273 ))) 274 -1. Add a call to {{code language="none"}}routeEdges(...){{/code}} in your {{code language="none"}}doLayout(...){{/code}} method and implement the latter. 266 +1. Add the following code to the end of the {{code language="none"}}doLayout{{/code}} method in your layout provider:(% class="code" %) 267 +((( 268 +(% class="o" %)=(% class="k" %)new(% class="o" %)();.(% class="na" style="color: rgb(0,128,128);" %)routeEdges(% class="o" %)(); 275 275 276 -{{info title="Tips"}} 277 -Here's a few tips for implementing the edge routing: 270 +{{{ EdgeRouter edgeRouter EdgeRouter 271 + edgeRouterlayoutNode 272 +}}} 273 +))) 274 +1. ((( 275 +Implement the {{code language="none"}}routeEdges{{/code}} method: 276 +* Each edge shall be drawn with three line segments: one vertical segment starting below the source node, one horizonzal segment, and another vertical segment ending below the target node. 277 +* The horizontal segments of two different edges shall not have the same y-coordinate; for consecutive edges, the distance between their horizontal segments shall equal {{code language="none"}}objectSpacing{{/code}}. 278 +* See the attached image [[attach:test-drawing.png]] for an example. 279 +* Find the edges using {{code language="none"}}getOutgoingEdges(){{/code}} or {{code language="none"}}getIncomingEdges(){{/code}} on a node. 280 +* Get the edge layout of an edge to set bend points using this code:(% class="code" %) 281 +((( 282 +(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)getData(% class="o" %)(.(% class="na" style="color: rgb(0,128,128);" %)class(% class="o" %)); 278 278 279 -* Each edge shall be drawn with three orthogonal line segments: one vertical segment below the start node, one vertical segment below the target node, and a horizontal segment that connects the two. 280 -* The horizontal segments of two different edges shall not have the same y-coordinate. Two neighboring horizontal segments shall be placed at a distance of objectSpacing. 281 -* See the screenshot at the top of the tutorial for an example. 282 -* Find the edges in a graph by calling {{code language="none"}}getOutgoingEdges(){{/code}} or {{code language="none"}}getIncomingEdges(){{/code}} on the nodes. 283 -* ((( 284 -You can add bend points to edges through the edge's edge layout: 285 - 286 -{{code language="java"}} 287 -KEdgeLayout edgeLayout = edge.getData(KEdgeLayout.class); 288 -KPoint bendPoint = KLayoutDataFactory.eINSTANCE.createKPoint(); 289 -edgeLayout.getBendPoints().add(bendPoint); 290 -{{/code}} 284 +{{{ KEdgeLayout edgeLayout edgeKEdgeLayout 285 +}}} 291 291 ))) 292 -* You will want to clear the list of bend points of each edge layout before adding bend points to it. This will remove all bend points the edge had prior to invoking your layout algorithm. 293 -* Set the values of the points returned by {{code language="none"}}getSourcePoint(){{/code}} and {{code language="none"}}getTargetPoint(){{/code}} according to the positions where an edge leaves its source node and reaches its target node. 294 -* If you want, you can improve the edge routing code by allowing horizontal segments to share the same y-coordinate if that doesn't make them overlap. Your goal could be to produce an edge routing that uses as little space as possible. 295 -* If that's not enough yet: can you find a way to find an order of the horizontal segments such that as few edge crossings as possible are produced? 296 -{{/info}} 287 +* Create a bend point using this code:(% class="code" %) 288 +((( 289 +(% class="o" %)=.(% class="na" style="color: rgb(0,128,128);" %)eINSTANCE(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)createKPoint(% class="o" %)(); 297 297 298 -Once you're done implementing the edge routing code, test it by running your debug configuration again, as before. 299 - 300 - 291 +{{{ KPoint point KLayoutDataFactory 292 +}}} 293 +))) 294 +* Use the {{code language="none"}}getBendPoints(){{/code}} list on the {{code language="none"}}edgeLayout{{/code}} to add bend points (clear the list first to remove points from the previous layout). 295 +* Set the values of the points returned by {{code language="none"}}getSourcePoint(){{/code}} and {{code language="none"}}getTargetPoint(){{/code}} according to the positions where the edge leaves its source node and reches its target node. 296 +))) 297 +))) 298 +1. Use your previous run configuration to test the edge router.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -61604 811 +6160476 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/61604 81/KIML1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/6160476/KIML