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
-
... ... @@ -2,15 +2,9 @@ 2 2 This tutorial is still being worked on. Don't start working on it just yet. 3 3 {{/warning}} 4 4 5 -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:5 +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. 6 6 7 - 8 - 9 9 {{warning title="ToDo"}} 10 -Insert screen shot of final application. 11 -{{/warning}} 12 - 13 -{{warning title="ToDo"}} 14 14 Insert link to presentation slides. 15 15 {{/warning}} 16 16 ... ... @@ -103,7 +103,7 @@ 103 103 1. Start Eclipse and create a new workspace. 104 104 1. Setup your workspace as explained in [[this guide>>doc:KIELER.Configuring Eclipse]]. 105 105 1. We will now make the two local clones of our Git repositories known to Eclipse. To that end, open the //Git Repository Exploring// perspective through //Window// -> //Open Perspective// -> //Other//. 106 -1. Click on //Add an existing local Git repository// and choose the location of the tutorial repository. Note that when you open the repository entry, the branch you previously checked out is marked as the current branch under //Branches// -> //Local//.100 +1. Click on //Add an existing local Git repository// and choose the location of the tutorial repository. 107 107 1. Add the KIML repository. 108 108 1. We will now import the projects required for KIML development to your workspace. Right-click on the KIML repository and choose //Import Projects//. 109 109 1. Choose //Import existing projects//, and select the //plugins// folder from the //Working Directory//. Then click //Next//. ... ... @@ -130,108 +130,91 @@ 130 130 131 131 == Adding a New Plug-in == 132 132 133 - Weneed to create a new plug-in to implement the layout algorithm in. Switch back to the Java or Plug-in Development perspective and follow these steps:127 + 134 134 135 -1. Click //File// > //New// > //Other...// > //Plug-in Development// > //Plug-in Project//. 136 -1. Enter {{code language="none"}}de.cau.cs.rtprak.login_name.tutorial2{{/code}} as the project name. Uncheck //Use default location// and use {{code language="none"}}tutorial_repository_path/de.cau.cs.rtprak.login_name.tutorial2{{/code}} as the location. Click //Next//. 137 -1. Set the version to {{code language="none"}}0.1.0.qualifier{{/code}}, vendor to {{code language="none"}}Christian-Albrechts-Universität zu Kiel{{/code}}, and execution environment to //J2SE-1.5//. (do this for all plug-ins that you create!) 138 -1. Uncheck all checkboxes in the //Options// group and click //Finish//. 139 -1. If Eclipse asks you whether the //Plug-in Development// perspective should be opened, choose either //Yes// or //No//. It doesn't make much of a difference anyway. 140 - 141 -You should now commit your new, empty project to the Git repository. We will do that from within Eclipse. 142 - 143 -1. Right-click your project in the //Package Explorer// and click //Team// > //Share Project...// 144 -1. As the repository type, select //Git// and click //Next//. 145 -1. Tell Eclipse what repository to add the project to. The repository you placed the project in is already preselected. Simply click //Finish//. 146 -1. Since Git support is now enabled for the project, right-click it again and click //Team// > //Commit...// 147 -1. Select all files, enter a (meaningful) commit message, and click //Commit//. 148 - 149 149 == Writing the Layout Algorithm == 150 150 151 - Whenwriting our layout algorithm, we are going to need to be able to access code defined in several other plug-ins. To do that, we need to add dependencies to those plug-ins:131 + 152 152 153 -1. In your new plug-in, open the file {{code language="none"}}META-INF/MANIFEST.MF{{/code}}. The plug-in manifest editor will open. Open its //Dependencies// tab. 154 -1. Add dependencies to the following plug-ins:\\ 155 -1*. {{code language="none"}}de.cau.cs.kieler.core{{/code}} 156 -1*. {{code language="none"}}de.cau.cs.kieler.core.kgraph{{/code}} 157 -1*. {{code language="none"}}de.cau.cs.kieler.kiml{{/code}} 158 -1. Save the editor. 133 + 159 159 160 - Layoutalgorithms interface with KIML by means of a layout provider class that has to be created and registered with KIML.135 + 161 161 162 -1. Right-click the source folder of your plug-in and click //New// > //Class//. 163 -1. Set the package to {{code language="none"}}de.cau.cs.rtprak.login_name.tutorial2{{/code}}, enter {{code language="none"}}Login_nameLayoutProvider{{/code}} as the class name, and select {{code language="none"}}de.cau.cs.kieler.kiml.AbstractLayoutProvider{{/code}} as the superclass. (This will only be available through the //Browse// dialog if you have saved the plug-in manifest editor; if you haven't, Eclipse won't know about the new dependencies yet.) 164 -1. Select //Generate comments// and click //Finish//. 137 +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. 165 165 166 -Implement the layout provider class: 167 - 139 +1. Create a new plugin\\ 140 +11. //File → New →// Other... //→// Plug-in Development //→// Plug-in Project 141 +11. Project name: de.cau.cs.rtprak.<login>.tutorial2 142 +11. //Next// //→// set version to //0.1.0.qualifier//, provider to //Christian-Albrechts-Universität zu Kiel//, and execution environment to //J2SE-1.5// (do this for all plugins that you create!) 143 +11. The checkboxes in the //Options// group can be deactivated -> //Finish// 144 +1. Commit the new plugin project ((% style="color: rgb(255,0,0);" %)TODO: describe steps to commit plugin projects(%%)) 145 +1. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)Open the file META-INF/MANIFEST.MF //→// //Dependencies// tab(%%)\\ 146 +1*. Add the plugins de.cau.cs.kieler.core and de.cau.cs.kieler.kiml to the list of dependencies, then save the file. 147 +1. Create a //layout provider// class with the //New →// Class wizard\\ 148 +1*. Package: de.cau.cs.rtprak.<login>.tutorial2 149 +1*. Name: <Login>LayoutProvider 150 +1*. Superclass: de.cau.cs.kieler.kiml.AbstractLayoutProvider 168 168 1. ((( 169 -Add the following constants: 152 +Implement the layout provider class 153 +1. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)Add the following constant to the class: 154 +1. (% class="code" %) 155 +((( 156 +(% 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" %); 170 170 171 -{{code language="java"}} 172 -/** default value for spacing between nodes. */ 173 -private static final float DEFAULT_SPACING = 15.0f; 174 -{{/code}} 158 +{{{ 159 + DEFAULT_SPACING 160 +}}} 175 175 ))) 176 -1. ((( 177 -Use the following code as the skeleton of the {{code language="none"}}doLayout(...){{/code}} method: 162 +1. Write the following lines at the beginning of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %) 163 +((( 164 +(% 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" %)){=;} 178 178 179 -{{code language="java"}} 180 -progressMonitor.begin("Login_name layouter", 1); 181 -KShapeLayout parentLayout = parentNode.getData(KShapeLayout.class); 166 +{{{ progressMonitor 167 + KShapeLayout parentLayout layoutNodeKShapeLayout 168 + objectSpacing parentLayoutLayoutOptions 169 + objectSpacing 170 + objectSpacing DEFAULT_SPACING 171 + 172 + borderSpacing parentLayoutLayoutOptions 173 + borderSpacing 174 + borderSpacing DEFAULT_SPACING 175 + 176 +}}} 177 +))) 178 +1. Write the following line at the end of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %) 179 +((( 180 +(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)done(% class="o" %)(); 182 182 183 -float objectSpacing = parentLayout.getProperty(LayoutOptions.SPACING); 184 -if (objectSpacing < 0) { 185 - objectSpacing = DEFAULT_SPACING; 186 -} 187 - 188 -float borderSpacing = parentLayout.getProperty(LayoutOptions.BORDER_SPACING); 189 -if (borderSpacing < 0) { 190 - borderSpacing = DEFAULT_SPACING; 191 -} 192 - 193 -// TODO: Insert actual layout code. 194 - 195 -progressMonitor.done(); 196 -{{/code}} 182 +{{{ progressMonitor 183 +}}} 197 197 ))) 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. 185 +1. ((( 186 +Implement the rest of the layouter such that the nodes of the input graph are all put in a row. 187 +* 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 188 +* Iterate over the nodes in the {{code language="none"}}getChildren(){{/code}} list of the {{code language="none"}}layoutNode{{/code}} input 189 +* Retrieve the size of a node using the following code:(% class="code" %) 190 +((( 191 +(% 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" %)(); 201 201 202 -{{info title="Tips"}} 203 -The following tips might come in handy... 204 - 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: 208 - 209 -{{code language="java"}} 210 -KShapeLayout nodeLayout = node.getData(KShapeLayout.class); 211 - 212 -// Retrieving the size 213 -float width = nodeLayout.getWidth(); 214 -float height = nodeLayout.getHeight(); 215 - 216 -// Setting the position 217 -nodeLayout.setXpos(x); 218 -nodeLayout.setYpos(y); 219 -{{/code}} 193 +{{{ KShapeLayout nodeLayout nodeKShapeLayout 194 + width nodeLayout 195 + height nodeLayout 196 +}}} 220 220 ))) 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}} 198 +* Set the position (x, y) of a node's upper left corner using the following code:(% class="code" %) 199 +((( 200 +(% class="o" %).(% class="na" style="color: rgb(0,128,128);" %)setXpos(% class="o" %)();.(% class="na" style="color: rgb(0,128,128);" %)setYpos(% class="o" %)(); 226 226 227 - 228 - 229 - 230 - 231 - 232 - 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 - 202 +{{{ nodeLayoutx 203 + nodeLayouty 204 +}}} 205 +))) 206 +* {{code language="none"}}objectSpacing{{/code}} shall be the spacing to be left between each pair of nodes. 207 +* {{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). 208 +* 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. 209 +* Edges may be ignored for now. 210 +))) 211 +))) 235 235 1. Open the file META-INF/MANIFEST.MF //→// //Extensions// tab\\ 236 236 11. Add an extension for de.cau.cs.kieler.kiml.layout.layoutProviders 237 237 11. Right-click the extension //→// //New// //→// //layoutProvider//
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -616047 61 +6160472 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/616047 6/KIML1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/6160472/KIML