<
From version < 11.1 >
edited by cds
on 2013/04/11 14:08
To version < 8.1 >
edited by msp
on 2013/04/09 10:14
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.cds
1 +XWiki.msp
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  
... ... @@ -102,136 +102,102 @@
102 102  
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 -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//.
107 -1. Add the KIML repository.
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 -1. Choose //Import existing projects//, and select the //plugins// folder from the //Working Directory//. Then click //Next//.
110 -1. Import the following plug-ins. This consitutes a basic configuration for the development of layout algorithms.\\
111 -1*. de.cau.cs.kieler.core
112 -1*. de.cau.cs.kieler.core.kgraph
113 -1*. de.cau.cs.kieler.kiml
114 -1*. de.cau.cs.kieler.kiml.gmf
115 -1*. de.cau.cs.kieler.kiml.service
116 -1*. de.cau.cs.kieler.kiml.ui
117 -1*. de.cau.cs.kieler.klay.layered
118 -1. To actually test your layout algorithms, you will need some kind of simple graph editor. The following plug-ins will add our KEG editor to your installation, which is just that.\\
119 -1*. de.cau.cs.kieler.core.annotations
120 -1*. de.cau.cs.kieler.core.kgraph.edit
121 -1*. de.cau.cs.kieler.core.kivi
122 -1*. de.cau.cs.kieler.core.model
123 -1*. de.cau.cs.kieler.core.model.gmf
124 -1*. de.cau.cs.kieler.core.ui
125 -1*. de.cau.cs.kieler.karma
126 -1*. de.cau.cs.kieler.keg
127 -1*. de.cau.cs.kieler.keg.diagram
128 -1*. de.cau.cs.kieler.keg.diagram.custom
129 -1*. de.cau.cs.kieler.keg.edit
130 130  
131 131  == Adding a New Plug-in ==
132 132  
133 -We need 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:
102 +
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 -When writing 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:
106 +
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.
108 +
159 159  
160 -Layout algorithms interface with KIML by means of a layout provider class that has to be created and registered with KIML.
110 +
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//.
112 +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 -
114 +1. Install and set up Eclipse ((% style="color: rgb(255,0,0);" %)TODO: describe steps to install and set up Eclipse(%%))
115 +1. Import the following KIELER plugins: ((% style="color: rgb(255,0,0);" %)TODO: describe steps to access and import the KIELER plugins and update the list(%%))\\
116 +1*. de.cau.cs.kieler.core
117 +1*. de.cau.cs.kieler.core.kgraph
118 +1*. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)de.cau.cs.kieler.kiml
119 +1*. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)de.cau.cs.kieler.kiml.service
120 +1*. de.cau.cs.kieler.kiml.ui
121 +1*. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)de.cau.cs.kieler.klay.layered
122 +1. Create a new plugin\\
123 +11. //File → New →// Other... //→// Plug-in Development //→// Plug-in Project
124 +11. Project name: de.cau.cs.rtprak.<login>.tutorial2
125 +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!)
126 +11. The checkboxes in the //Options// group can be deactivated -> //Finish//
127 +1. Commit the new plugin project ((% style="color: rgb(255,0,0);" %)TODO: describe steps to commit plugin projects(%%))
128 +1. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)Open the file META-INF/MANIFEST.MF //→// //Dependencies// tab(%%)\\
129 +1*. Add the plugins de.cau.cs.kieler.core and de.cau.cs.kieler.kiml to the list of dependencies, then save the file.
130 +1. Create a //layout provider// class with the //New →// Class wizard\\
131 +1*. Package: de.cau.cs.rtprak.<login>.tutorial2
132 +1*. Name: <Login>LayoutProvider
133 +1*. Superclass: de.cau.cs.kieler.kiml.AbstractLayoutProvider
168 168  1. (((
169 -Add the following constants:
135 +Implement the layout provider class
136 +1. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)Add the following constant to the class:
137 +1. (% class="code" %)
138 +(((
139 +(% 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}}
141 +{{{
142 + DEFAULT_SPACING
143 +}}}
175 175  )))
176 -1. (((
177 -Use the following code as the skeleton of the {{code language="none"}}doLayout(...){{/code}} method:
145 +1. Write the following lines at the beginning of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %)
146 +(((
147 +(% 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);
149 +{{{ progressMonitor
150 + KShapeLayout parentLayout layoutNodeKShapeLayout
151 + objectSpacing parentLayoutLayoutOptions
152 + objectSpacing
153 + objectSpacing DEFAULT_SPACING
154 +
155 + borderSpacing parentLayoutLayoutOptions
156 + borderSpacing
157 + borderSpacing DEFAULT_SPACING
158 +
159 +}}}
160 +)))
161 +1. Write the following line at the end of the {{code language="none"}}doLayout{{/code}} method:(% class="code" %)
162 +(((
163 +(% 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}}
165 +{{{ progressMonitor
166 +}}}
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.
168 +1. (((
169 +Implement the rest of the layouter such that the nodes of the input graph are all put in a row.
170 +* 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
171 +* Iterate over the nodes in the {{code language="none"}}getChildren(){{/code}} list of the {{code language="none"}}layoutNode{{/code}} input
172 +* Retrieve the size of a node using the following code:(% class="code" %)
173 +(((
174 +(% 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}}
176 +{{{ KShapeLayout nodeLayout nodeKShapeLayout
177 + width nodeLayout
178 + height nodeLayout
179 +}}}
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}}
181 +* Set the position (x, y) of a node's upper left corner using the following code:(% class="code" %)
182 +(((
183 +(% 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 -
185 +{{{ nodeLayoutx
186 + nodeLayouty
187 +}}}
188 +)))
189 +* {{code language="none"}}objectSpacing{{/code}} shall be the spacing to be left between each pair of nodes.
190 +* {{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).
191 +* 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.
192 +* Edges may be ignored for now.
193 +)))
194 +)))
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 -6160476
1 +6160470
URL
... ... @@ -1,1 +1,1 @@
1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/6160476/KIML
1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS13LayPract/pages/6160470/KIML