mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1 | <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";} |
| 29 | h1 |
| 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;} |
| 39 | h2 |
| 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;} |
| 50 | h3 |
| 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;} |
| 60 | h4 |
| 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;} |
| 70 | h5 |
| 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;} |
| 77 | a:link, span.MsoHyperlink |
| 78 | {color:blue; |
| 79 | text-decoration:underline;} |
| 80 | a:visited, span.MsoHyperlinkFollowed |
| 81 | {color:purple; |
| 82 | text-decoration:underline;} |
| 83 | p.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";} |
| 89 | p |
| 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";} |
| 96 | pre |
| 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";} |
| 105 | p.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";} |
| 111 | span.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;} |
| 117 | span.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;} |
| 123 | span.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;} |
| 129 | span.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;} |
| 136 | span.berschrift5Zchn |
| 137 | {mso-style-name:"Überschrift 5 Zchn"; |
| 138 | mso-style-link:"Überschrift 5"; |
| 139 | font-family:"Cambria","serif"; |
| 140 | color:#243F60;} |
| 141 | span.HTMLVorformatiertZchn |
| 142 | {mso-style-name:"HTML Vorformatiert Zchn"; |
| 143 | mso-style-link:"HTML Vorformatiert"; |
| 144 | font-family:Consolas;} |
| 145 | span.DokumentstrukturZchn |
| 146 | {mso-style-name:"Dokumentstruktur Zchn"; |
| 147 | mso-style-link:Dokumentstruktur; |
| 148 | font-family:"Tahoma","sans-serif";} |
| 149 | span.SprechblasentextZchn |
| 150 | {mso-style-name:"Sprechblasentext Zchn"; |
| 151 | mso-style-link:Sprechblasentext; |
| 152 | font-family:"Tahoma","sans-serif";} |
| 153 | p.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";} |
| 162 | p.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;} |
| 171 | p.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";} |
| 179 | span.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;} |
| 185 | p.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";} |
| 192 | span.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;} |
| 198 | p.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";} |
| 205 | span.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;} |
| 211 | p.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";} |
| 218 | span.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;} |
| 225 | p.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";} |
| 232 | span.Heading5Char |
| 233 | {mso-style-name:"Heading 5 Char"; |
| 234 | mso-style-link:"Heading 5"; |
| 235 | font-family:"Cambria","serif"; |
| 236 | color:#243F60;} |
| 237 | p.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";} |
| 244 | span.HTMLPreformattedChar |
| 245 | {mso-style-name:"HTML Preformatted Char"; |
| 246 | mso-style-link:"HTML Preformatted"; |
| 247 | font-family:Consolas;} |
| 248 | p.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";} |
| 255 | span.BalloonTextChar |
| 256 | {mso-style-name:"Balloon Text Char"; |
| 257 | mso-style-link:"Balloon Text"; |
| 258 | font-family:"Tahoma","sans-serif";} |
| 259 | p.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";} |
| 266 | span.code1 |
| 267 | {mso-style-name:code1; |
| 268 | font-style:italic;} |
| 269 | .MsoChpDefault |
| 270 | {font-size:10.0pt;} |
| 271 | @page Section1 |
| 272 | {size:595.45pt 841.7pt; |
| 273 | margin:72.0pt 89.85pt 72.0pt 89.85pt;} |
| 274 | div.Section1 |
| 275 | {page:Section1;} |
| 276 | --> |
| 277 | </style> |
| 278 | |
| 279 | </head> |
| 280 | |
| 281 | <body bgcolor=white lang=DE link=blue vlink=purple style='margin-bottom:12.0pt'> |
| 282 | |
| 283 | <div class=Section1> |
| 284 | |
| 285 | <h1><span lang=EN-GB>Providing Layout Functionality</span></h1> |
| 286 | |
| 287 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span><span |
| 288 | lang=EN-GB> </span></p> |
| 289 | |
| 290 | <h2><span lang=EN-GB>Create a Layout Feature</span></h2> |
| 291 | |
| 292 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 293 | |
| 294 | <p class=MsoNormal><span lang=EN-GB>If you already enlarged a EClass in the |
| 295 | diagram, you may have observed that the shapes inside the rectangle kept their |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 296 | size (EClass name is not longer in the centre and the line separator is too short). |
| 297 | Graphiti<span style='color:black'> provides the concept of layout features, |
| 298 | which mainly supports the recalculation of positions and sizes inside the |
| 299 | pictogram model. </span></span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 300 | |
| 301 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Theoretical such |
| 302 | functionality could also be implemented by <a href="resize-feature.htm">providing |
| 303 | resize functionality</a>, but using a layout feature for this is the |
| 304 | recommended solution.</span></p> |
| 305 | |
| 306 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 307 | |
| 308 | <p class=MsoNormal><span lang=EN-GB style='color:black'>A layout feature has to |
| 309 | implement the interface </span><span class=code1><span lang=EN-US |
| 310 | style='color:black'><a |
jpasch | 0954c17 | 2010-09-09 13:14:43 +0000 | [diff] [blame] | 311 | href="../../../javadoc/org/eclipse/graphiti/features/ILayoutFeature.html"><span |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 312 | style='font-style:normal'>ILayoutFeature</span></a>.</span></span><span |
| 313 | lang=EN-US style='color:black'> </span><span lang=EN-GB style='color:black'>Instead |
| 314 | of implementing it directly you should extend one of the available base |
| 315 | classes. In this example we extend the base class<span class=code1> </span></span><span |
| 316 | class=code1><span lang=EN-US style='color:black'><a |
jpasch | 0954c17 | 2010-09-09 13:14:43 +0000 | [diff] [blame] | 317 | href="../../../javadoc/org/eclipse/graphiti/features/impl/AbstractLayoutFeature.html"><span |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 318 | style='font-style:normal'>AbstractLayoutFeature</span></a></span></span><span |
| 319 | lang=EN-GB style='color:black'>.</span></p> |
| 320 | |
| 321 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 322 | |
| 323 | <p class=MsoNormal><span lang=EN-GB style='color:black'>In this case we have to |
| 324 | implement/overwrite two methods:</span></p> |
| 325 | |
| 326 | <p class=MsoNormal><span lang=EN-GB style='color:black'>The method <a |
jpasch | 0954c17 | 2010-09-09 13:14:43 +0000 | [diff] [blame] | 327 | href="../../../javadoc/org/eclipse/graphiti/func/ILayout.html#canLayout(org.eclipse.graphiti.features.context.ILayoutContext)">c<span |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 328 | lang=EN-US>anLayout</span></a> has to check whether the pictogram element of |
| 329 | the given context can be layouted. </span></p> |
| 330 | |
| 331 | <p class=MsoNormal><span lang=EN-GB style='color:black'>The method </span><span |
| 332 | class=code1><span lang=EN-US style='color:black'><a |
jpasch | 0954c17 | 2010-09-09 13:14:43 +0000 | [diff] [blame] | 333 | href="../../../javadoc/org/eclipse/graphiti/func/ILayout.html#layout(org.eclipse.graphiti.features.context.ILayoutContext)"><span |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 334 | style='font-style:normal'>layout</span></a></span></span><span lang=EN-GB |
| 335 | style='color:black'> has to recalculate and modify everything needed to layout |
| 336 | the pictogram element given with the context. </span></p> |
| 337 | |
| 338 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 339 | |
| 340 | <p class=MsoNormal><span lang=EN-GB style='color:black'>You can see the |
| 341 | complete implementation of the move feature here:</span></p> |
| 342 | |
| 343 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 344 | |
| 345 | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=851 |
| 346 | style='width:18.0cm;border-collapse:collapse'> |
| 347 | <tr> |
| 348 | <td width=851 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| 349 | padding:0cm 5.4pt 0cm 5.4pt'> |
| 350 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-GB |
| 351 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'> </span></b></p> |
| 352 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 353 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>package</span></b><span |
| 354 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 355 | org.eclipse.graphiti.examples.tutorial.features;</span></p> |
| 356 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 357 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 358 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 359 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span |
| 360 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 361 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>class</span></b><span |
| 362 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 363 | TutorialLayoutEClassFeature </span><b><span lang=EN-US style='font-size:10.0pt; |
| 364 | font-family:"Courier New";color:#7F0055'>extends</span></b><span lang=EN-US |
| 365 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 366 | AbstractLayoutFeature {</span></p> |
| 367 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 368 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 369 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 370 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 371 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 372 | color:#7F0055'>private</span></b><span lang=EN-US style='font-size:10.0pt; |
| 373 | font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| 374 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b><span |
| 375 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 376 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>final</span></b><span |
| 377 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 378 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span |
| 379 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><i><span |
| 380 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span |
| 381 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> = |
| 382 | 30;</span></p> |
| 383 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 384 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 385 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 386 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 387 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 388 | color:#7F0055'>private</span></b><span lang=EN-US style='font-size:10.0pt; |
| 389 | font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| 390 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b><span |
| 391 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 392 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>final</span></b><span |
| 393 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 394 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span |
| 395 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><i><span |
| 396 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span |
| 397 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> = |
| 398 | 50;</span></p> |
| 399 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 400 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 401 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 402 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 403 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 404 | color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| 405 | font-family:"Courier New";color:black'> |
| 406 | TutorialLayoutEClassFeature(IFeatureProvider fp) {</span></p> |
| 407 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 408 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 409 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 410 | color:#7F0055'>super</span></b><span lang=EN-US style='font-size:10.0pt; |
| 411 | font-family:"Courier New";color:black'>(fp);</span></p> |
| 412 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 413 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 414 | }</span></p> |
| 415 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 416 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 417 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 418 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 419 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 420 | color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| 421 | font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| 422 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span |
| 423 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 424 | canLayout(ILayoutContext context) {</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'> </span><span |
| 427 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// |
| 428 | return true, if pictogram element is linked to an EClass</span></p> |
| 429 | <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> |
| 430 | PictogramElement pe = context.getPictogramElement();</span></p> |
| 431 | <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family: |
| 432 | "Courier New";color:#7F0055'> if</span></b><span |
| 433 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> (!(pe <b><span |
| 434 | style='color:#7F0055'>instanceof</span></b> ContainerShape))</span></p> |
| 435 | <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family: |
| 436 | "Courier New";color:#7F0055'> |
| 437 | return</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> |
| 438 | <b><span style='color:#7F0055'>false</span></b>;</span></p> |
| 439 | <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> |
| 440 | EList<EObject> businessObjects = pe.getLink().getBusinessObjects();</span></p> |
| 441 | <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family: |
| 442 | "Courier New";color:#7F0055'> return</span></b><span |
| 443 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> |
| 444 | businessObjects.size() == 1 <br> |
| 445 | |
| 446 | && businessObjects.get(0) <b><span style='color:#7F0055'>instanceof</span></b> |
| 447 | EClass;</span></p> |
| 448 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 449 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 450 | }</span></p> |
| 451 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 452 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 453 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 454 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 455 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 456 | color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| 457 | font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| 458 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span |
| 459 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 460 | layout(ILayoutContext context) {</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'> |
| 463 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 464 | color:#7F0055'>boolean</span></b><span lang=EN-US style='font-size:10.0pt; |
| 465 | font-family:"Courier New";color:black'> anythingChanged = </span><b><span |
| 466 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span |
| 467 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 468 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 469 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 470 | ContainerShape containerShape =</span></p> |
| 471 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 472 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 473 | (ContainerShape) context.getPictogramElement();</span></p> |
| 474 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 475 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 476 | GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();</span></p> |
| 477 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 478 | style='font-size:10.0pt;font-family:"Courier New"'> </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'> |
| 481 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 482 | color:#3F7F5F'>// height</span></p> |
| 483 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 484 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 485 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 486 | color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| 487 | font-family:"Courier New";color:black'> (containerGa.getHeight() < </span><i><span |
| 488 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span |
| 489 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span></p> |
| 490 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 491 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 492 | containerGa.setHeight(</span><i><span |
| 493 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span |
| 494 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| 495 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 496 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 497 | anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt; |
| 498 | font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US |
| 499 | style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 500 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 501 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 502 | }</span></p> |
| 503 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 504 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 505 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 506 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 507 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 508 | color:#3F7F5F'>// width</span></p> |
| 509 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 510 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 511 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 512 | color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| 513 | font-family:"Courier New";color:black'> (containerGa.getWidth() < </span><i><span |
| 514 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span |
| 515 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span></p> |
| 516 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 517 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 518 | containerGa.setWidth(</span><i><span lang=EN-US style='font-size:10.0pt; |
| 519 | font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span |
| 520 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| 521 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 522 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 523 | anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt; |
| 524 | font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US |
| 525 | style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 526 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 527 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 528 | }</span></p> |
| 529 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 530 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 531 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 532 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 533 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 534 | color:#7F0055'>int</span></b><span lang=EN-US style='font-size:10.0pt; |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 535 | font-family:"Courier New";color:black'> containerWidth = |
| 536 | containerGa.getWidth();</span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 537 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 538 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 539 | Iterator iter = containerShape.getChildren().iterator();</span></p> |
| 540 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 541 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 542 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 543 | color:#7F0055'>while</span></b><span lang=EN-US style='font-size:10.0pt; |
| 544 | font-family:"Courier New";color:black'> (iter.hasNext()) {</span></p> |
| 545 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 546 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 547 | Shape shape = (Shape) iter.next();</span></p> |
| 548 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 549 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 550 | GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();</span><span |
| 551 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><br> |
| 552 | IGaService |
| 553 | gaService = Graphiti.getGaService();</span></p> |
| 554 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 555 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 556 | IDimension size = <br> |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 557 | |
| 558 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span |
jpasch | e0a8242 | 2010-09-20 12:38:11 +0000 | [diff] [blame] | 559 | style='color:black'>.calculateSize(graphicsAlgorithm);</span></span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 560 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 561 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 562 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 563 | color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| 564 | font-family:"Courier New";color:black'> (containerWidth != size.getWidth()) {</span></p> |
| 565 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 566 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 567 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 568 | color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| 569 | font-family:"Courier New";color:black'> (graphicsAlgorithm </span><b><span |
| 570 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span |
| 571 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 572 | Polyline) {</span></p> |
| 573 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 574 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 575 | Polyline |
| 576 | polyline = (Polyline) graphicsAlgorithm;</span></p> |
| 577 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 578 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 579 | Point secondPoint = polyline.getPoints().get(1);</span></p> |
| 580 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 581 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 582 | Point newSecondPoint =</span></p> |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 583 | <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 584 | color:black'> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 585 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 586 | style='color:black'>.createPoint(containerWidth,</span> secondPoint.getY());</span><span |
| 587 | lang=EN-US> </span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 588 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 589 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 590 | polyline.getPoints().set(1, newSecondPoint);</span></p> |
| 591 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 592 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 593 | anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt; |
| 594 | font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US |
| 595 | style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 596 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 597 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 598 | } </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 599 | color:#7F0055'>else</span></b><span lang=EN-US style='font-size:10.0pt; |
| 600 | font-family:"Courier New";color:black'> {</span></p> |
| 601 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 602 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 603 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>gaService<span |
jpasch | e0a8242 | 2010-09-20 12:38:11 +0000 | [diff] [blame] | 604 | style='color:black'>.setWidth(graphicsAlgorithm,</span></span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 605 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 606 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 607 | containerWidth);</span></p> |
| 608 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 609 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 610 | anythingChanged = </span><b><span lang=EN-US style='font-size:10.0pt; |
| 611 | font-family:"Courier New";color:#7F0055'>true</span></b><span lang=EN-US |
| 612 | style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 613 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 614 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 615 | }</span></p> |
| 616 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 617 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 618 | }</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'> |
| 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'> |
| 624 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 625 | color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| 626 | font-family:"Courier New";color:black'> anythingChanged;</span></p> |
| 627 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 628 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 629 | </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| 630 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 631 | font-family:"Courier New";color:black'>}</span></p> |
| 632 | <p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"; |
| 633 | color:black'> </span></p> |
| 634 | </td> |
| 635 | </tr> |
| 636 | </table> |
| 637 | |
| 638 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 639 | |
| 640 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Additionally the |
| 641 | feature provider has to deliver our newly created feature (overwrite the method |
| 642 | </span><span class=code1><span lang=EN-US style='color:black;font-style:normal'><a |
jpasch | 0954c17 | 2010-09-09 13:14:43 +0000 | [diff] [blame] | 643 | href="../../../javadoc/org/eclipse/graphiti/features/IFeatureProvider.html#getLayoutFeature(org.eclipse.graphiti.features.context.ILayoutContext)">getLayoutFeature</a>)</span></span><i><span |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 644 | lang=EN-GB style='color:black'>.</span></i><span lang=EN-GB style='color:black'> |
| 645 | </span></p> |
| 646 | |
| 647 | <p class=MsoNormal><span lang=EN-GB style='color:black'>This implementation can |
| 648 | be seen here:</span></p> |
| 649 | |
| 650 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 651 | |
| 652 | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=851 |
| 653 | style='width:18.0cm;border-collapse:collapse'> |
| 654 | <tr> |
| 655 | <td width=851 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| 656 | padding:0cm 5.4pt 0cm 5.4pt'> |
| 657 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-GB |
| 658 | style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span></p> |
| 659 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 660 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 661 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 662 | color:#646464'>@Override</span></p> |
| 663 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 664 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 665 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 666 | color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| 667 | font-family:"Courier New";color:black'> ILayoutFeature |
| 668 | getLayoutFeature(ILayoutContext context) {</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'> |
| 671 | PictogramElement pictogramElement = context.getPictogramElement();</span></p> |
| 672 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 673 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 674 | Object bo = getBusinessObjectForPictogramElement(pictogramElement);</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'> |
| 677 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 678 | color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| 679 | font-family:"Courier New";color:black'> (bo </span><b><span lang=EN-US |
| 680 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span |
| 681 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 682 | EClass) {</span></p> |
| 683 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 684 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 685 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 686 | color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| 687 | font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| 688 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span |
| 689 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 690 | TutorialLayoutEClassFeature(</span><b><span lang=EN-US style='font-size:10.0pt; |
| 691 | font-family:"Courier New";color:#7F0055'>this</span></b><span lang=EN-US |
| 692 | style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| 693 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 694 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 695 | </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| 696 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 697 | font-family:"Courier New";color:black'> |
| 698 | </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b><span |
| 699 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 700 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span |
| 701 | style='font-size:10.0pt;font-family:"Courier New";color:black'>.getLayoutFeature(context);</span></p> |
| 702 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 703 | font-family:"Courier New";color:black'> }</span></p> |
| 704 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 705 | </td> |
| 706 | </tr> |
| 707 | </table> |
| 708 | |
| 709 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 710 | |
| 711 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Finally we have to call |
| 712 | the layout feature at the end of the add method of the </span><span |
| 713 | class=code1><span lang=EN-US style='color:black'>TutorialAddEClassFeature</span></span><span |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 714 | class=code1><span lang=EN-US style='color:black;font-style:normal'>, as shown in |
| 715 | the following code snippet.</span></span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 716 | |
| 717 | <p class=MsoNormal><span class=code1><span lang=EN-US style='color:black; |
| 718 | font-style:normal'>This causes that the layout (especially the layout |
| 719 | restrictions like minimum size) are applied after adding a EClass.</span></span></p> |
| 720 | |
| 721 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 722 | |
| 723 | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=851 |
| 724 | style='width:18.0cm;border-collapse:collapse'> |
| 725 | <tr> |
| 726 | <td width=851 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| 727 | padding:0cm 5.4pt 0cm 5.4pt'> |
| 728 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-GB |
| 729 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 730 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 731 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 732 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 733 | color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| 734 | font-family:"Courier New";color:black'> PictogramElement add(IAddContext |
| 735 | context) {</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'> </span></p> |
| 738 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 739 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 740 | </span></p> |
| 741 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 742 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 743 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 744 | color:#3F7F5F'>// ... EXiSTING CODING ...</span></p> |
| 745 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 746 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 747 | </span></p> |
| 748 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 749 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 750 | </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'> |
| 753 | </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 754 | color:#3F7F5F'>// call the layout feature</span></p> |
| 755 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 756 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 757 | layoutPictogramElement(containerShape);</span></p> |
| 758 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 759 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 760 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 761 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 762 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 763 | color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| 764 | font-family:"Courier New";color:black'> containerShape;</span></p> |
| 765 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 766 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 767 | </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span><span |
| 768 | lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 769 | <p class=MsoNormal style='text-autospace:none'> </p> |
| 770 | </td> |
| 771 | </tr> |
| 772 | </table> |
| 773 | |
| 774 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 775 | |
| 776 | <p class=MsoNormal> </p> |
| 777 | |
| 778 | <h2><span lang=EN-GB>Test: Layout EClass after Resize</span></h2> |
| 779 | |
| 780 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 781 | |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 782 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Now start the editor again |
| 783 | and test it: Try to resize a EClass. You see that the class name stays in the |
| 784 | centre and the line separator will be automatically extended.</span></p> |
| 785 | |
| 786 | <div class=MsoNormal align=center style='text-align:center'> |
| 787 | |
| 788 | <hr size=3 width="100%" align=center> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 789 | |
| 790 | </div> |
jpasch | 36ca9fd | 2010-06-17 14:53:34 +0000 | [diff] [blame] | 791 | |
| 792 | <p class=MsoNormal><a href="http://www.eclipse.org/legal/epl-v10.html" |
| 793 | shape=rect>Copyright (c) SAP AG 2005, 2010.</a> </p> |
| 794 | |
| 795 | </div> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 796 | |
| 797 | </body> |
| 798 | |
| 799 | </html> |