blob: a46f8dcf924448f9bf1a0bb7f4633741a984f689 [file] [log] [blame]
mwenzb5dc2f92010-06-16 13:24:52 +00001<html>
2
3<head>
4<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
5<meta name=Generator content="Microsoft Word 12 (filtered)">
6<title>Providing layout functionality</title>
7<link rel=Stylesheet type="text/css" media=all href="../book.css">
8<style>
9<!--
10 /* Font Definitions */
11 @font-face
12 {font-family:"Cambria Math";
13 panose-1:2 4 5 3 5 4 6 3 2 4;}
14@font-face
15 {font-family:Cambria;
16 panose-1:2 4 5 3 5 4 6 3 2 4;}
17@font-face
18 {font-family:Tahoma;
19 panose-1:2 11 6 4 3 5 4 4 2 4;}
20@font-face
21 {font-family:Consolas;
22 panose-1:2 11 6 9 2 2 4 3 2 4;}
23 /* Style Definitions */
24 p.MsoNormal, li.MsoNormal, div.MsoNormal
25 {margin:0cm;
26 margin-bottom:.0001pt;
27 font-size:12.0pt;
28 font-family:"Times New Roman","serif";}
29h1
30 {mso-style-link:"Überschrift 1 Zchn";
31 margin-top:12.0pt;
32 margin-right:0cm;
33 margin-bottom:3.0pt;
34 margin-left:0cm;
35 page-break-after:avoid;
36 font-size:16.0pt;
37 font-family:"Times New Roman","serif";
38 font-weight:bold;}
39h2
40 {mso-style-link:"Überschrift 2 Zchn";
41 margin-top:12.0pt;
42 margin-right:0cm;
43 margin-bottom:3.0pt;
44 margin-left:0cm;
45 page-break-after:avoid;
46 font-size:14.0pt;
47 font-family:"Times New Roman","serif";
48 font-weight:bold;
49 font-style:italic;}
50h3
51 {mso-style-link:"Überschrift 3 Zchn";
52 margin-top:12.0pt;
53 margin-right:0cm;
54 margin-bottom:3.0pt;
55 margin-left:0cm;
56 page-break-after:avoid;
57 font-size:13.0pt;
58 font-family:"Times New Roman","serif";
59 font-weight:bold;}
60h4
61 {mso-style-link:"Überschrift 4 Zchn";
62 margin-top:11.25pt;
63 margin-right:0cm;
64 margin-bottom:1.7pt;
65 margin-left:0cm;
66 font-size:12.0pt;
67 font-family:"Times New Roman","serif";
68 font-weight:bold;
69 font-style:italic;}
70h5
71 {mso-style-link:"Überschrift 5 Zchn";
72 margin-right:0cm;
73 margin-left:0cm;
74 font-size:10.0pt;
75 font-family:"Times New Roman","serif";
76 font-weight:bold;}
77a:link, span.MsoHyperlink
78 {color:blue;
79 text-decoration:underline;}
80a:visited, span.MsoHyperlinkFollowed
81 {color:purple;
82 text-decoration:underline;}
83p.MsoDocumentMap, li.MsoDocumentMap, div.MsoDocumentMap
84 {mso-style-link:"Dokumentstruktur Zchn";
85 margin:0cm;
86 margin-bottom:.0001pt;
87 font-size:8.0pt;
88 font-family:"Tahoma","sans-serif";}
89p
90 {margin-top:5.65pt;
91 margin-right:0cm;
92 margin-bottom:5.65pt;
93 margin-left:0cm;
94 font-size:12.0pt;
95 font-family:"Times New Roman","serif";}
96pre
97 {mso-style-link:"HTML Vorformatiert Zchn";
98 margin-top:0cm;
99 margin-right:0cm;
100 margin-bottom:0cm;
101 margin-left:3.4pt;
102 margin-bottom:.0001pt;
103 font-size:11.0pt;
104 font-family:"Courier New";}
105p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
106 {mso-style-link:"Sprechblasentext Zchn";
107 margin:0cm;
108 margin-bottom:.0001pt;
109 font-size:8.0pt;
110 font-family:"Tahoma","sans-serif";}
111span.berschrift1Zchn
112 {mso-style-name:"Überschrift 1 Zchn";
113 mso-style-link:"Überschrift 1";
114 font-family:"Cambria","serif";
115 color:#365F91;
116 font-weight:bold;}
117span.berschrift2Zchn
118 {mso-style-name:"Überschrift 2 Zchn";
119 mso-style-link:"Überschrift 2";
120 font-family:"Cambria","serif";
121 color:#4F81BD;
122 font-weight:bold;}
123span.berschrift3Zchn
124 {mso-style-name:"Überschrift 3 Zchn";
125 mso-style-link:"Überschrift 3";
126 font-family:"Cambria","serif";
127 color:#4F81BD;
128 font-weight:bold;}
129span.berschrift4Zchn
130 {mso-style-name:"Überschrift 4 Zchn";
131 mso-style-link:"Überschrift 4";
132 font-family:"Cambria","serif";
133 color:#4F81BD;
134 font-weight:bold;
135 font-style:italic;}
136span.berschrift5Zchn
137 {mso-style-name:"Überschrift 5 Zchn";
138 mso-style-link:"Überschrift 5";
139 font-family:"Cambria","serif";
140 color:#243F60;}
141span.HTMLVorformatiertZchn
142 {mso-style-name:"HTML Vorformatiert Zchn";
143 mso-style-link:"HTML Vorformatiert";
144 font-family:Consolas;}
145span.DokumentstrukturZchn
146 {mso-style-name:"Dokumentstruktur Zchn";
147 mso-style-link:Dokumentstruktur;
148 font-family:"Tahoma","sans-serif";}
149span.SprechblasentextZchn
150 {mso-style-name:"Sprechblasentext Zchn";
151 mso-style-link:Sprechblasentext;
152 font-family:"Tahoma","sans-serif";}
153p.code, li.code, div.code
154 {mso-style-name:code;
155 margin-top:0cm;
156 margin-right:0cm;
157 margin-bottom:0cm;
158 margin-left:15.0pt;
159 margin-bottom:.0001pt;
160 font-size:12.0pt;
161 font-family:"Times New Roman","serif";}
162p.note, li.note, div.note
163 {mso-style-name:note;
164 margin-top:19.5pt;
165 margin-right:0cm;
166 margin-bottom:19.5pt;
167 margin-left:30.0pt;
168 font-size:13.0pt;
169 font-family:"Times New Roman","serif";
170 font-style:italic;}
171p.msochpdefault, li.msochpdefault, div.msochpdefault
172 {mso-style-name:msochpdefault;
173 margin-top:5.65pt;
174 margin-right:0cm;
175 margin-bottom:5.65pt;
176 margin-left:0cm;
177 font-size:10.0pt;
178 font-family:"Times New Roman","serif";}
179span.Heading1Char
180 {mso-style-name:"Heading 1 Char";
181 mso-style-link:"Heading 1";
182 font-family:"Cambria","serif";
183 color:#365F91;
184 font-weight:bold;}
185p.Heading1, li.Heading1, div.Heading1
186 {mso-style-name:"Heading 1";
187 mso-style-link:"Heading 1 Char";
188 margin:0cm;
189 margin-bottom:.0001pt;
190 font-size:12.0pt;
191 font-family:"Times New Roman","serif";}
192span.Heading2Char
193 {mso-style-name:"Heading 2 Char";
194 mso-style-link:"Heading 2";
195 font-family:"Cambria","serif";
196 color:#4F81BD;
197 font-weight:bold;}
198p.Heading2, li.Heading2, div.Heading2
199 {mso-style-name:"Heading 2";
200 mso-style-link:"Heading 2 Char";
201 margin:0cm;
202 margin-bottom:.0001pt;
203 font-size:12.0pt;
204 font-family:"Times New Roman","serif";}
205span.Heading3Char
206 {mso-style-name:"Heading 3 Char";
207 mso-style-link:"Heading 3";
208 font-family:"Cambria","serif";
209 color:#4F81BD;
210 font-weight:bold;}
211p.Heading3, li.Heading3, div.Heading3
212 {mso-style-name:"Heading 3";
213 mso-style-link:"Heading 3 Char";
214 margin:0cm;
215 margin-bottom:.0001pt;
216 font-size:12.0pt;
217 font-family:"Times New Roman","serif";}
218span.Heading4Char
219 {mso-style-name:"Heading 4 Char";
220 mso-style-link:"Heading 4";
221 font-family:"Cambria","serif";
222 color:#4F81BD;
223 font-weight:bold;
224 font-style:italic;}
225p.Heading4, li.Heading4, div.Heading4
226 {mso-style-name:"Heading 4";
227 mso-style-link:"Heading 4 Char";
228 margin:0cm;
229 margin-bottom:.0001pt;
230 font-size:12.0pt;
231 font-family:"Times New Roman","serif";}
232span.Heading5Char
233 {mso-style-name:"Heading 5 Char";
234 mso-style-link:"Heading 5";
235 font-family:"Cambria","serif";
236 color:#243F60;}
237p.Heading5, li.Heading5, div.Heading5
238 {mso-style-name:"Heading 5";
239 mso-style-link:"Heading 5 Char";
240 margin:0cm;
241 margin-bottom:.0001pt;
242 font-size:12.0pt;
243 font-family:"Times New Roman","serif";}
244span.HTMLPreformattedChar
245 {mso-style-name:"HTML Preformatted Char";
246 mso-style-link:"HTML Preformatted";
247 font-family:Consolas;}
248p.HTMLPreformatted, li.HTMLPreformatted, div.HTMLPreformatted
249 {mso-style-name:"HTML Preformatted";
250 mso-style-link:"HTML Preformatted Char";
251 margin:0cm;
252 margin-bottom:.0001pt;
253 font-size:12.0pt;
254 font-family:"Times New Roman","serif";}
255span.BalloonTextChar
256 {mso-style-name:"Balloon Text Char";
257 mso-style-link:"Balloon Text";
258 font-family:"Tahoma","sans-serif";}
259p.BalloonText, li.BalloonText, div.BalloonText
260 {mso-style-name:"Balloon Text";
261 mso-style-link:"Balloon Text Char";
262 margin:0cm;
263 margin-bottom:.0001pt;
264 font-size:12.0pt;
265 font-family:"Times New Roman","serif";}
jpascha7bd3842011-04-29 13:33:49 +0000266p.comment, li.comment, div.comment
267 {mso-style-name:comment;
268 margin-top:5.65pt;
269 margin-right:0cm;
270 margin-bottom:5.65pt;
271 margin-left:0cm;
272 font-size:12.0pt;
273 font-family:"Times New Roman","serif";
274 font-weight:bold;}
mwenzb5dc2f92010-06-16 13:24:52 +0000275span.code1
276 {mso-style-name:code1;
277 font-style:italic;}
278.MsoChpDefault
279 {font-size:10.0pt;}
jpascha7bd3842011-04-29 13:33:49 +0000280@page WordSection1
mwenzb5dc2f92010-06-16 13:24:52 +0000281 {size:595.45pt 841.7pt;
282 margin:72.0pt 89.85pt 72.0pt 89.85pt;}
jpascha7bd3842011-04-29 13:33:49 +0000283div.WordSection1
284 {page:WordSection1;}
mwenzb5dc2f92010-06-16 13:24:52 +0000285-->
286</style>
287
288</head>
289
290<body bgcolor=white lang=DE link=blue vlink=purple style='margin-bottom:12.0pt'>
291
jpascha7bd3842011-04-29 13:33:49 +0000292<div class=WordSection1>
mwenzb5dc2f92010-06-16 13:24:52 +0000293
294<h1><span lang=EN-GB>Providing Layout Functionality</span></h1>
295
296<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span><span
297lang=EN-GB>&nbsp;</span></p>
298
299<h2><span lang=EN-GB>Create a Layout Feature</span></h2>
300
301<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
302
303<p class=MsoNormal><span lang=EN-GB>If you already enlarged a EClass in the
jpascha7bd3842011-04-29 13:33:49 +0000304diagram, you may have observed that the shapes inside the rectangle kept their size
305(EClass name is not longer in the centre and the line separator is too short).
jpasch36ca9fd2010-06-17 14:53:34 +0000306Graphiti<span style='color:black'> provides the concept of layout features,
307which mainly supports the recalculation of positions and sizes inside the
308pictogram model. </span></span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000309
310<p class=MsoNormal><span lang=EN-GB style='color:black'>Theoretical such
311functionality could also be implemented by <a href="resize-feature.htm">providing
312resize functionality</a>, but using a layout feature for this is the
313recommended solution.</span></p>
314
315<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
316
317<p class=MsoNormal><span lang=EN-GB style='color:black'>A layout feature has to
318implement the interface </span><span class=code1><span lang=EN-US
319style='color:black'><a
jpasch0954c172010-09-09 13:14:43 +0000320href="../../../javadoc/org/eclipse/graphiti/features/ILayoutFeature.html"><span
mwenzb5dc2f92010-06-16 13:24:52 +0000321style='font-style:normal'>ILayoutFeature</span></a>.</span></span><span
322lang=EN-US style='color:black'> </span><span lang=EN-GB style='color:black'>Instead
323of implementing it directly you should extend one of the available base
324classes. In this example we extend the base class<span class=code1> </span></span><span
325class=code1><span lang=EN-US style='color:black'><a
jpasch0954c172010-09-09 13:14:43 +0000326href="../../../javadoc/org/eclipse/graphiti/features/impl/AbstractLayoutFeature.html"><span
mwenzb5dc2f92010-06-16 13:24:52 +0000327style='font-style:normal'>AbstractLayoutFeature</span></a></span></span><span
328lang=EN-GB style='color:black'>.</span></p>
329
330<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
331
332<p class=MsoNormal><span lang=EN-GB style='color:black'>In this case we have to
333implement/overwrite two methods:</span></p>
334
335<p class=MsoNormal><span lang=EN-GB style='color:black'>The method <a
jpasch0954c172010-09-09 13:14:43 +0000336href="../../../javadoc/org/eclipse/graphiti/func/ILayout.html#canLayout(org.eclipse.graphiti.features.context.ILayoutContext)">c<span
mwenzb5dc2f92010-06-16 13:24:52 +0000337lang=EN-US>anLayout</span></a> has to check whether the pictogram element of
338the given context can be layouted. </span></p>
339
340<p class=MsoNormal><span lang=EN-GB style='color:black'>The method </span><span
341class=code1><span lang=EN-US style='color:black'><a
jpasch0954c172010-09-09 13:14:43 +0000342href="../../../javadoc/org/eclipse/graphiti/func/ILayout.html#layout(org.eclipse.graphiti.features.context.ILayoutContext)"><span
mwenzb5dc2f92010-06-16 13:24:52 +0000343style='font-style:normal'>layout</span></a></span></span><span lang=EN-GB
344style='color:black'> has to recalculate and modify everything needed to layout
345the pictogram element given with the context. </span></p>
346
347<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
348
349<p class=MsoNormal><span lang=EN-GB style='color:black'>You can see the
350complete implementation of the move feature here:</span></p>
351
352<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
353
jpascha7bd3842011-04-29 13:33:49 +0000354<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680
mwenzb5dc2f92010-06-16 13:24:52 +0000355 style='width:18.0cm;border-collapse:collapse'>
356 <tr>
jpascha7bd3842011-04-29 13:33:49 +0000357 <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt;
mwenzb5dc2f92010-06-16 13:24:52 +0000358 padding:0cm 5.4pt 0cm 5.4pt'>
359 <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-GB
360 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>&nbsp;</span></b></p>
361 <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US
362 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>package</span></b><span
363 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
364 org.eclipse.graphiti.examples.tutorial.features;</span></p>
365 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
366 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
367 <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US
368 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span
369 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
370 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>class</span></b><span
jpascha7bd3842011-04-29 13:33:49 +0000371 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> TutorialLayoutEClassFeature
372 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
373 color:#7F0055'>extends</span></b><span lang=EN-US style='font-size:10.0pt;
374 font-family:"Courier New";color:black'> AbstractLayoutFeature {</span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000375 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
376 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
377 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
378 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
379 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
380 color:#7F0055'>private</span></b><span lang=EN-US style='font-size:10.0pt;
381 font-family:"Courier New";color:black'> </span><b><span lang=EN-US
382 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b><span
383 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
384 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>final</span></b><span
385 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
386 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span
387 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><i><span
388 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span
389 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> =
390 30;</span></p>
391 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
392 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
393 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
394 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
395 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
396 color:#7F0055'>private</span></b><span lang=EN-US style='font-size:10.0pt;
397 font-family:"Courier New";color:black'> </span><b><span lang=EN-US
398 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b><span
399 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
400 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>final</span></b><span
401 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
402 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span
403 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><i><span
404 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span
405 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> =
406 50;</span></p>
407 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
408 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
409 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
410 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
411 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
412 color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt;
413 font-family:"Courier New";color:black'>
414 TutorialLayoutEClassFeature(IFeatureProvider fp) {</span></p>
415 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
416 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
417 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
418 color:#7F0055'>super</span></b><span lang=EN-US style='font-size:10.0pt;
419 font-family:"Courier New";color:black'>(fp);</span></p>
420 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
421 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
422 }</span></p>
423 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
424 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
425 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
426 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
427 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
428 color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt;
429 font-family:"Courier New";color:black'> </span><b><span lang=EN-US
430 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span
431 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
432 canLayout(ILayoutContext context) {</span></p>
433 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
434 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span
435 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>//
436 return true, if pictogram element is linked to an EClass</span></p>
437 <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
438 PictogramElement pe = context.getPictogramElement();</span></p>
439 <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
440 "Courier New";color:#7F0055'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if</span></b><span
441 lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> (!(pe <b><span
442 style='color:#7F0055'>instanceof</span></b> ContainerShape))</span></p>
443 <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
444 "Courier New";color:#7F0055'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
445 return</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>
446 <b><span style='color:#7F0055'>false</span></b>;</span></p>
447 <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
448 EList&lt;EObject&gt; businessObjects = pe.getLink().getBusinessObjects();</span></p>
449 <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
450 "Courier New";color:#7F0055'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return</span></b><span
451 lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>
452 businessObjects.size() == 1 <br>
453 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
454 &amp;&amp; businessObjects.get(0) <b><span style='color:#7F0055'>instanceof</span></b>
455 EClass;</span></p>
456 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
457 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
458 }</span></p>
459 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
460 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
461 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
462 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
463 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
464 color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt;
465 font-family:"Courier New";color:black'> </span><b><span lang=EN-US
466 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span
467 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
468 layout(ILayoutContext context) {</span></p>
469 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
470 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
471 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
472 color:#7F0055'>boolean</span></b><span lang=EN-US style='font-size:10.0pt;
473 font-family:"Courier New";color:black'> anythingChanged = </span><b><span
474 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span
475 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p>
476 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
477 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
478 ContainerShape containerShape =</span></p>
479 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
480 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
481 (ContainerShape) context.getPictogramElement();</span></p>
482 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
483 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
484 GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();</span></p>
485 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
486 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
487 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
488 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
489 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
490 color:#3F7F5F'>// height</span></p>
491 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
492 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
493 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
494 color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;
495 font-family:"Courier New";color:black'> (containerGa.getHeight() &lt; </span><i><span
496 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span
497 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span></p>
498 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
499 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
500 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;containerGa.setHeight(</span><i><span
501 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span
502 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p>
503 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
504 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
505 anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt;
506 font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US
507 style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p>
508 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
509 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
510 }</span></p>
511 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
512 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
513 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
514 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
515 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
516 color:#3F7F5F'>// width</span></p>
517 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
518 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
519 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
520 color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;
521 font-family:"Courier New";color:black'> (containerGa.getWidth() &lt; </span><i><span
522 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span
523 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span></p>
524 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
525 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
526 containerGa.setWidth(</span><i><span lang=EN-US style='font-size:10.0pt;
527 font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span
528 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p>
529 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
530 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
531 anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt;
532 font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US
533 style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p>
534 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
535 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
536 }</span></p>
537 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
538 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
539 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
540 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
541 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
542 color:#7F0055'>int</span></b><span lang=EN-US style='font-size:10.0pt;
jpasch36ca9fd2010-06-17 14:53:34 +0000543 font-family:"Courier New";color:black'> containerWidth =
544 containerGa.getWidth();</span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000545 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
546 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
jpascha7bd3842011-04-29 13:33:49 +0000547 </span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000548 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
549 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
550 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
jpascha7bd3842011-04-29 13:33:49 +0000551 color:#7F0055'>for </span></b><span lang=EN-US style='font-size:10.0pt;
552 font-family:"Courier New"'>(Shape shape : containerShape.getChildren())</span><span
553 lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>{</span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000554 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
555 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
556 GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();</span><span
557 lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><br>
558 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IGaService
559 gaService = Graphiti.getGaService();</span></p>
560 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
561 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
562 IDimension size = <br>
jpasch36ca9fd2010-06-17 14:53:34 +0000563 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
564 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span
jpasche0a82422010-09-20 12:38:11 +0000565 style='color:black'>.calculateSize(graphicsAlgorithm);</span></span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000566 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
567 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
568 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
569 color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;
570 font-family:"Courier New";color:black'> (containerWidth != size.getWidth()) {</span></p>
571 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
572 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
573 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
574 color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;
575 font-family:"Courier New";color:black'> (graphicsAlgorithm </span><b><span
576 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span
577 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
578 Polyline) {</span></p>
579 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
580 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
581 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Polyline
582 polyline = (Polyline) graphicsAlgorithm;</span></p>
583 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
584 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
585 Point secondPoint = polyline.getPoints().get(1);</span></p>
586 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
587 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
588 Point newSecondPoint =</span></p>
jpasch36ca9fd2010-06-17 14:53:34 +0000589 <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
590 color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mwenzb5dc2f92010-06-16 13:24:52 +0000591 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span
jpasch36ca9fd2010-06-17 14:53:34 +0000592 style='color:black'>.createPoint(containerWidth,</span> secondPoint.getY());</span><span
593 lang=EN-US> </span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000594 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
595 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
596 polyline.getPoints().set(1, newSecondPoint);</span></p>
597 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
598 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
599 anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt;
600 font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US
601 style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p>
602 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
603 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
604 } </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
605 color:#7F0055'>else</span></b><span lang=EN-US style='font-size:10.0pt;
606 font-family:"Courier New";color:black'> {</span></p>
607 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
608 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
609 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span
jpasche0a82422010-09-20 12:38:11 +0000610 style='color:black'>.setWidth(graphicsAlgorithm,</span></span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000611 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
612 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
613 containerWidth);</span></p>
614 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
615 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
616 anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt;
617 font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US
618 style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p>
619 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
620 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
621 }</span></p>
622 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
623 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
624 }</span></p>
625 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
626 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
627 }</span></p>
628 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
629 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
630 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
631 color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt;
632 font-family:"Courier New";color:black'> anythingChanged;</span></p>
633 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
634 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
635 </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p>
636 <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
637 font-family:"Courier New";color:black'>}</span></p>
638 <p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
639 color:black'>&nbsp;</span></p>
640 </td>
641 </tr>
642</table>
643
644<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
645
jpascha7bd3842011-04-29 13:33:49 +0000646<p class=MsoNormal><span lang=EN-GB style='color:black'>Additionally the feature
647provider has to deliver our newly created feature (overwrite the method </span><span
648class=code1><span lang=EN-US style='color:black;font-style:normal'><a
jpasch0954c172010-09-09 13:14:43 +0000649href="../../../javadoc/org/eclipse/graphiti/features/IFeatureProvider.html#getLayoutFeature(org.eclipse.graphiti.features.context.ILayoutContext)">getLayoutFeature</a>)</span></span><i><span
mwenzb5dc2f92010-06-16 13:24:52 +0000650lang=EN-GB style='color:black'>.</span></i><span lang=EN-GB style='color:black'>
651</span></p>
652
653<p class=MsoNormal><span lang=EN-GB style='color:black'>This implementation can
654be seen here:</span></p>
655
656<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
657
jpascha7bd3842011-04-29 13:33:49 +0000658<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680
mwenzb5dc2f92010-06-16 13:24:52 +0000659 style='width:18.0cm;border-collapse:collapse'>
660 <tr>
jpascha7bd3842011-04-29 13:33:49 +0000661 <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt;
mwenzb5dc2f92010-06-16 13:24:52 +0000662 padding:0cm 5.4pt 0cm 5.4pt'>
663 <p class=MsoNormal style='text-autospace:none'><span lang=EN-GB
664 style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>&nbsp;</span></p>
665 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
666 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
667 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
668 color:#646464'>@Override</span></p>
669 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
670 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
671 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
672 color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt;
673 font-family:"Courier New";color:black'> ILayoutFeature
674 getLayoutFeature(ILayoutContext context) {</span></p>
675 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
676 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
677 PictogramElement pictogramElement = context.getPictogramElement();</span></p>
678 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
679 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
680 Object bo = getBusinessObjectForPictogramElement(pictogramElement);</span></p>
681 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
682 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
683 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
684 color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;
685 font-family:"Courier New";color:black'> (bo </span><b><span lang=EN-US
686 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span
687 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
688 EClass) {</span></p>
689 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
690 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
691 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
692 color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt;
693 font-family:"Courier New";color:black'> </span><b><span lang=EN-US
694 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span
695 lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>
696 TutorialLayoutEClassFeature(</span><b><span lang=EN-US style='font-size:10.0pt;
697 font-family:"Courier New";color:#7F0055'>this</span></b><span lang=EN-US
698 style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p>
699 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
700 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
701 </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p>
702 <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
703 font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
704 </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b><span
705 style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
706 style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span
707 style='font-size:10.0pt;font-family:"Courier New";color:black'>.getLayoutFeature(context);</span></p>
708 <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
709 font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; }</span></p>
710 <p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
711 </td>
712 </tr>
713</table>
714
715<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
716
717<p class=MsoNormal><span lang=EN-GB style='color:black'>Finally we have to call
718the layout feature at the end of the add method of the </span><span
719class=code1><span lang=EN-US style='color:black'>TutorialAddEClassFeature</span></span><span
jpascha7bd3842011-04-29 13:33:49 +0000720class=code1><span lang=EN-US style='color:black;font-style:normal'>, as shown
721in the following code snippet.</span></span></p>
mwenzb5dc2f92010-06-16 13:24:52 +0000722
723<p class=MsoNormal><span class=code1><span lang=EN-US style='color:black;
724font-style:normal'>This causes that the layout (especially the layout
725restrictions like minimum size) are applied after adding a EClass.</span></span></p>
726
727<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
728
jpascha7bd3842011-04-29 13:33:49 +0000729<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680
mwenzb5dc2f92010-06-16 13:24:52 +0000730 style='width:18.0cm;border-collapse:collapse'>
731 <tr>
jpascha7bd3842011-04-29 13:33:49 +0000732 <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt;
mwenzb5dc2f92010-06-16 13:24:52 +0000733 padding:0cm 5.4pt 0cm 5.4pt'>
734 <p class=MsoNormal style='text-autospace:none'><span lang=EN-GB
735 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;</span></p>
736 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
737 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
738 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
739 color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt;
740 font-family:"Courier New";color:black'> PictogramElement add(IAddContext
741 context) {</span></p>
742 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
743 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;</span></p>
744 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
745 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
746 </span></p>
747 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
748 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
749 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
750 color:#3F7F5F'>// ... EXiSTING CODING ...</span></p>
751 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
752 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
753 </span></p>
754 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
755 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
756 </span></p>
757 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
758 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
759 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
760 color:#3F7F5F'>// call the layout feature</span></p>
761 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
762 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
763 layoutPictogramElement(containerShape);</span></p>
764 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
765 style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></p>
766 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
767 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
768 </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
769 color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt;
770 font-family:"Courier New";color:black'> containerShape;</span></p>
771 <p class=MsoNormal style='text-autospace:none'><span lang=EN-US
772 style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;
773 </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span><span
774 lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;</span></p>
775 <p class=MsoNormal style='text-autospace:none'>&nbsp;</p>
776 </td>
777 </tr>
778</table>
779
780<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
781
782<p class=MsoNormal>&nbsp;</p>
783
784<h2><span lang=EN-GB>Test: Layout EClass after Resize</span></h2>
785
786<p class=MsoNormal><span lang=EN-GB style='color:black'>&nbsp;</span></p>
787
jpascha7bd3842011-04-29 13:33:49 +0000788<p class=MsoNormal><span lang=EN-GB style='color:black'>Now start the editor
789again and test it: Try to resize a EClass. You see that the class name stays in
790the centre and the line separator will be automatically extended.</span></p>
jpasch36ca9fd2010-06-17 14:53:34 +0000791
792<div class=MsoNormal align=center style='text-align:center'>
793
794<hr size=3 width="100%" align=center>
mwenzb5dc2f92010-06-16 13:24:52 +0000795
796</div>
jpasch36ca9fd2010-06-17 14:53:34 +0000797
798<p class=MsoNormal><a href="http://www.eclipse.org/legal/epl-v10.html"
799shape=rect>Copyright (c) SAP AG 2005, 2010.</a> </p>
800
801</div>
mwenzb5dc2f92010-06-16 13:24:52 +0000802
803</body>
804
805</html>