mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta name="generator" content= |
| 5 | "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org"> |
| 6 | <meta http-equiv="Content-Type" content= |
| 7 | "text/html; charset=us-ascii"> |
| 8 | <meta name="Generator" content="Microsoft Word 12 (filtered)"> |
| 9 | <title>Selection behavior</title> |
| 10 | <link rel="Stylesheet" type="text/css" media="all" href= |
| 11 | "../book.css"> |
| 12 | <style type="text/css"> |
| 13 | <!-- |
| 14 | /* Font Definitions */ |
| 15 | @font-face |
| 16 | {font-family:"Cambria Math"; |
| 17 | panose-1:2 4 5 3 5 4 6 3 2 4;} |
| 18 | @font-face |
| 19 | {font-family:Cambria; |
| 20 | panose-1:2 4 5 3 5 4 6 3 2 4;} |
| 21 | @font-face |
| 22 | {font-family:Tahoma; |
| 23 | panose-1:2 11 6 4 3 5 4 4 2 4;} |
| 24 | @font-face |
| 25 | {font-family:Consolas; |
| 26 | panose-1:2 11 6 9 2 2 4 3 2 4;} |
| 27 | /* Style Definitions */ |
| 28 | p.MsoNormal, li.MsoNormal, div.MsoNormal |
| 29 | {margin:0cm; |
| 30 | margin-bottom:.0001pt; |
| 31 | font-size:12.0pt; |
| 32 | font-family:"Times New Roman","serif";} |
| 33 | h1 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 34 | {mso-style-link:"Überschrift 1 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 35 | margin-top:12.0pt; |
| 36 | margin-right:0cm; |
| 37 | margin-bottom:3.0pt; |
| 38 | margin-left:0cm; |
| 39 | page-break-after:avoid; |
| 40 | font-size:16.0pt; |
| 41 | font-family:"Times New Roman","serif"; |
| 42 | font-weight:bold;} |
| 43 | h2 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 44 | {mso-style-link:"Überschrift 2 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 45 | margin-top:12.0pt; |
| 46 | margin-right:0cm; |
| 47 | margin-bottom:3.0pt; |
| 48 | margin-left:0cm; |
| 49 | page-break-after:avoid; |
| 50 | font-size:14.0pt; |
| 51 | font-family:"Times New Roman","serif"; |
| 52 | font-weight:bold; |
| 53 | font-style:italic;} |
| 54 | h3 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 55 | {mso-style-link:"Überschrift 3 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 56 | margin-top:12.0pt; |
| 57 | margin-right:0cm; |
| 58 | margin-bottom:3.0pt; |
| 59 | margin-left:0cm; |
| 60 | page-break-after:avoid; |
| 61 | font-size:13.0pt; |
| 62 | font-family:"Times New Roman","serif"; |
| 63 | font-weight:bold;} |
| 64 | h4 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 65 | {mso-style-link:"Überschrift 4 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 66 | margin-top:11.25pt; |
| 67 | margin-right:0cm; |
| 68 | margin-bottom:1.7pt; |
| 69 | margin-left:0cm; |
| 70 | font-size:12.0pt; |
| 71 | font-family:"Times New Roman","serif"; |
| 72 | font-weight:bold; |
| 73 | font-style:italic;} |
| 74 | h5 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 75 | {mso-style-link:"Überschrift 5 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 76 | margin-right:0cm; |
| 77 | margin-left:0cm; |
| 78 | font-size:10.0pt; |
| 79 | font-family:"Times New Roman","serif"; |
| 80 | font-weight:bold;} |
| 81 | h6 |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 82 | {mso-style-link:"Überschrift 6 Zchn"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 83 | margin-right:0cm; |
| 84 | margin-left:0cm; |
| 85 | font-size:7.5pt; |
| 86 | font-family:"Times New Roman","serif"; |
| 87 | font-weight:bold;} |
| 88 | p.MsoCaption, li.MsoCaption, div.MsoCaption |
| 89 | {margin-top:6.0pt; |
| 90 | margin-right:0cm; |
| 91 | margin-bottom:24.0pt; |
| 92 | margin-left:0cm; |
| 93 | text-align:justify; |
| 94 | font-size:10.0pt; |
| 95 | font-family:"Times New Roman","serif"; |
| 96 | font-weight:bold;} |
| 97 | a:link, span.MsoHyperlink |
| 98 | {color:blue; |
| 99 | text-decoration:underline;} |
| 100 | a:visited, span.MsoHyperlinkFollowed |
| 101 | {color:purple; |
| 102 | text-decoration:underline;} |
| 103 | p |
| 104 | {margin-top:5.65pt; |
| 105 | margin-right:0cm; |
| 106 | margin-bottom:5.65pt; |
| 107 | margin-left:0cm; |
| 108 | font-size:12.0pt; |
| 109 | font-family:"Times New Roman","serif";} |
| 110 | pre |
| 111 | {mso-style-link:"HTML Vorformatiert Zchn"; |
| 112 | margin-top:0cm; |
| 113 | margin-right:0cm; |
| 114 | margin-bottom:0cm; |
| 115 | margin-left:3.4pt; |
| 116 | margin-bottom:.0001pt; |
| 117 | font-size:11.0pt; |
| 118 | font-family:"Courier New";} |
| 119 | p.MsoAcetate, li.MsoAcetate, div.MsoAcetate |
| 120 | {mso-style-link:"Sprechblasentext Zchn"; |
| 121 | margin:0cm; |
| 122 | margin-bottom:.0001pt; |
| 123 | font-size:8.0pt; |
| 124 | font-family:"Tahoma","sans-serif";} |
| 125 | span.berschrift1Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 126 | {mso-style-name:"Überschrift 1 Zchn"; |
| 127 | mso-style-link:"Überschrift 1"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 128 | font-family:"Cambria","serif"; |
| 129 | color:#365F91; |
| 130 | font-weight:bold;} |
| 131 | span.berschrift2Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 132 | {mso-style-name:"Überschrift 2 Zchn"; |
| 133 | mso-style-link:"Überschrift 2"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 134 | font-family:"Cambria","serif"; |
| 135 | color:#4F81BD; |
| 136 | font-weight:bold;} |
| 137 | span.berschrift3Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 138 | {mso-style-name:"Überschrift 3 Zchn"; |
| 139 | mso-style-link:"Überschrift 3"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 140 | font-family:"Cambria","serif"; |
| 141 | color:#4F81BD; |
| 142 | font-weight:bold;} |
| 143 | span.berschrift4Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 144 | {mso-style-name:"Überschrift 4 Zchn"; |
| 145 | mso-style-link:"Überschrift 4"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 146 | font-family:"Cambria","serif"; |
| 147 | color:#4F81BD; |
| 148 | font-weight:bold; |
| 149 | font-style:italic;} |
| 150 | span.berschrift5Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 151 | {mso-style-name:"Überschrift 5 Zchn"; |
| 152 | mso-style-link:"Überschrift 5"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 153 | font-family:"Cambria","serif"; |
| 154 | color:#243F60;} |
| 155 | span.berschrift6Zchn |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 156 | {mso-style-name:"Überschrift 6 Zchn"; |
| 157 | mso-style-link:"Überschrift 6"; |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 158 | font-family:"Cambria","serif"; |
| 159 | color:#243F60; |
| 160 | font-style:italic;} |
| 161 | span.HTMLVorformatiertZchn |
| 162 | {mso-style-name:"HTML Vorformatiert Zchn"; |
| 163 | mso-style-link:"HTML Vorformatiert"; |
| 164 | font-family:Consolas;} |
| 165 | span.SprechblasentextZchn |
| 166 | {mso-style-name:"Sprechblasentext Zchn"; |
| 167 | mso-style-link:Sprechblasentext; |
| 168 | font-family:"Tahoma","sans-serif";} |
| 169 | p.code, li.code, div.code |
| 170 | {mso-style-name:code; |
| 171 | margin-top:0cm; |
| 172 | margin-right:0cm; |
| 173 | margin-bottom:0cm; |
| 174 | margin-left:15.0pt; |
| 175 | margin-bottom:.0001pt; |
| 176 | font-size:12.0pt; |
| 177 | font-family:"Times New Roman","serif";} |
| 178 | p.note, li.note, div.note |
| 179 | {mso-style-name:note; |
| 180 | margin-top:19.5pt; |
| 181 | margin-right:0cm; |
| 182 | margin-bottom:19.5pt; |
| 183 | margin-left:30.0pt; |
| 184 | font-size:13.0pt; |
| 185 | font-family:"Times New Roman","serif"; |
| 186 | font-style:italic;} |
| 187 | p.msochpdefault, li.msochpdefault, div.msochpdefault |
| 188 | {mso-style-name:msochpdefault; |
| 189 | margin-top:5.65pt; |
| 190 | margin-right:0cm; |
| 191 | margin-bottom:5.65pt; |
| 192 | margin-left:0cm; |
| 193 | font-size:10.0pt; |
| 194 | font-family:"Times New Roman","serif";} |
| 195 | span.code1 |
| 196 | {mso-style-name:code1; |
| 197 | font-style:italic;} |
| 198 | span.code0 |
| 199 | {mso-style-name:code0; |
| 200 | font-style:italic;} |
| 201 | .MsoChpDefault |
| 202 | {font-size:10.0pt;} |
| 203 | @page Section1 |
| 204 | {size:595.45pt 841.7pt; |
| 205 | margin:72.0pt 89.85pt 72.0pt 89.85pt;} |
| 206 | div.Section1 |
| 207 | {page:Section1;} |
| 208 | --> |
| 209 | </style> |
| 210 | </head> |
| 211 | <body bgcolor="white" lang="DE" link="blue" vlink="purple" style= |
| 212 | 'margin-bottom:12.0pt'> |
| 213 | <div class="Section1"> |
| 214 | <h1><span lang="EN-US">Selection Behavior</span></h1> |
| 215 | <p class="MsoNormal"><span lang="EN-US" style= |
| 216 | 'color:black'> </span></p> |
| 217 | <h2><span lang="EN-US">Introduction</span></h2> |
| 218 | <p class="MsoNormal"><span lang="EN-US" style= |
| 219 | 'color:black'> </span></p> |
| 220 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>In |
| 221 | most cases a graphical figure is depicted by one outer |
| 222 | ‘main’ graphics algorithm, inside which several other |
| 223 | graphics algorithms are located. The outer bounds of this outer |
| 224 | ‘main’ graphics algorithm also define the |
| 225 | selection-behavior of the graphical figure.</span></p> |
| 226 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>But |
| 227 | it is also possible to assemble a shape from overlapping or even |
| 228 | distributed graphics algorithms. In such a case it is not so |
| 229 | clear anymore, which bounds define the selection-behavior of the |
| 230 | graphical figure.</span></p> |
| 231 | <p class="MsoNormal"><span lang="EN-US" style= |
| 232 | 'color:black'> </span></p> |
| 233 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>For a |
| 234 | better understanding look at the following figure:</span></p> |
| 235 | <p class="MsoNormal"><span style='color:black'><img width="111" |
| 236 | height="71" src="visio/rendering-area-1a.gif" alt=""></span></p> |
| 237 | <p class="MsoCaption"><span class="code1"><span lang="EN-US" |
| 238 | style='font-style:normal'>Figure: Graphical figure with |
| 239 | distributed graphics algorithms (ellipse and |
| 240 | text)</span></span></p> |
| 241 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>This |
| 242 | graphical figure consists of an ellipse and a text. For technical |
| 243 | reasons there is still an outer invisible rectangle, which |
| 244 | contains the ellipse and text. But in this example it would seem |
| 245 | strange for the user, if this outer invisible rectangle would |
| 246 | define the selection-behavior, meaning that clicking on the |
| 247 | invisible rectangle would select it and show the |
| 248 | selection-handles along the bounds of the invisible |
| 249 | rectangle.</span></p> |
| 250 | <p class="MsoNormal"><span lang="EN-US" style= |
| 251 | 'color:black'>Instead the selection-behavior should work as can |
| 252 | be seen in the following figure:</span></p> |
| 253 | <p class="MsoNormal"><span style='color:black'><img width="111" |
| 254 | height="72" src="visio/rendering-area-1b.gif" alt=""></span></p> |
| 255 | <p class="MsoCaption"><span class="code1"><span lang="EN-US" |
| 256 | style='font-style:normal'>Figure: Selection area is smaller than |
| 257 | complete graphical figure</span></span></p> |
| 258 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>The |
| 259 | selection-handles appear only along the borders of the ellipse |
| 260 | and not along the borders of the larger invisible rectangle. It |
| 261 | is possible to move or resize the circle along these |
| 262 | selection-handles (which will implicitly move or resize the |
| 263 | complete graphical figure). This makes the ellipse the |
| 264 | ‘main’ graphics algorithm, although the ellipse is |
| 265 | technically not the outer graphics algorithm of the graphical |
| 266 | figure.</span></p> |
| 267 | <p class="MsoNormal"><span lang="EN-US" style= |
| 268 | 'color:black'>Another aspect of the selection-behavior is that |
| 269 | the graphical figure shall be selected when the mouse clicks on |
| 270 | either the ellipse or the text. When the mouse clicks the text |
| 271 | however, then the handle-bounds still appear around the ellipse |
| 272 | as described above, and not around the text. This means, that the |
| 273 | selection-handles can be shown around a different area, than the |
| 274 | area which reacts on the mouse clicks to select the graphical |
| 275 | figure.</span></p> |
| 276 | <p class="MsoNormal"><span lang="EN-US" style= |
| 277 | 'color:black'> </span></p> |
| 278 | <p class="MsoNormal"><span lang="EN-US" style= |
| 279 | 'color:black'> </span></p> |
| 280 | <h2><span lang="EN-US">Creating an Extended Rendering |
| 281 | Area</span></h2> |
| 282 | <p class="MsoNormal"><span lang="EN-US" style= |
| 283 | 'color:black'> </span></p> |
| 284 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>The |
| 285 | following example bases on the <a href="anchors.htm">box relative |
| 286 | anchor</a> we created previously. As you can see the box relative |
| 287 | anchor was located completely inside the bounds of the rectangle |
| 288 | depicting the EClass.</span></p> |
| 289 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>Now |
| 290 | we want to change the location of the box relative anchor, so |
| 291 | that it exceeds the bounds of the rectangle. This is actually |
| 292 | quite typical, that box relative anchors or fix point anchors |
| 293 | exceed the bounds of the graphical figure it belongs |
| 294 | to.</span></p> |
| 295 | <p class="MsoNormal"><span style='color:black'><img border="0" |
| 296 | width="121" height="71" src="visio/rendering-area-2a.gif" alt= |
| 297 | ""></span></p> |
| 298 | <p class="MsoCaption"><span class="code1"><span lang="EN-US" |
| 299 | style='font-style:normal'>Figure: Box relative anchor exceeds |
| 300 | bounds of graphical figure</span></span></p> |
| 301 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>As |
| 302 | already mentioned, for technical reasons a graphics algorithm can |
| 303 | never be painted outside the bounds of its parent graphics |
| 304 | algorithm. Although it is possible to set the bounds of a |
| 305 | graphics algorithm to exceed the bounds of its parent graphics |
| 306 | algorithm, it will just be clipped when painting.</span></p> |
| 307 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>You |
| 308 | can try that out by changing the bounds of the <a href= |
| 309 | "anchors.htm">box relative anchor</a> we created |
| 310 | previously:</span></p> |
| 311 | <p class="MsoNormal"><span lang="EN-US" style= |
| 312 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.<i>setLocationAndSizeOfGraphicsAlgorithm</i>(boxRect, |
| 313 | -8, -4,</span> <b>16</b><span style='color:black'>, |
| 314 | 8);</span></span></p> |
| 315 | <p class="MsoNormal"><span lang="EN-US" style= |
| 316 | 'color:black'> </span></p> |
| 317 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>As |
| 318 | this doesn’t work, we have to change the structure of the |
| 319 | graphics algorithms for the EClass. The outer graphics algorithm |
| 320 | shall be an invisible rectangle, which contains the rectangle |
| 321 | depicting the EClass. The size of the invisible rectangle equals |
| 322 | the size of the rectangle depicting the EClass, plus the space |
| 323 | needed for the box relative anchor at its right side. You can see |
| 324 | the bounds of the invisible rectangle when you select the |
| 325 | graphical figure:</span></p> |
| 326 | <p class="MsoNormal"><span style='color:black'><img border="0" |
| 327 | width="131" height="71" src="visio/rendering-area-2b.gif" alt= |
| 328 | ""></span><span lang="EN-US" style= |
| 329 | 'color:black'> </span></p> |
| 330 | <p class="MsoCaption"><span class="code1"><span lang="EN-US" |
| 331 | style='font-style:normal'>Figure: Selection-handles around the |
| 332 | invisible rectangle</span></span><span lang= |
| 333 | "EN-US"> </span></p> |
| 334 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>The |
| 335 | invisible rectangle has to be created in the add method of the |
| 336 | <a href="add-feature.htm">add feature</a><span class= |
| 337 | "code1"><span style='font-style:normal'>, as explained in the |
| 338 | following code snippet. Additionally the bounds of the box |
| 339 | relative anchor have to be set differently. Note, that the |
| 340 | expanded width of the invisible rectangle is set in a static |
| 341 | field, because it also has to be used in calculations outside |
| 342 | this class.</span></span></span></p> |
| 343 | <p class="MsoNormal"><span lang="EN-US"> </span></p> |
| 344 | <table class="MsoNormalTable" border="0" cellspacing="0" |
| 345 | cellpadding="0" width="851" style= |
| 346 | 'width:18.0cm;border-collapse:collapse'> |
| 347 | <tr> |
| 348 | <td width="851" valign="top" style= |
| 349 | 'width:18.0cm;border:solid windowtext 1.0pt; padding:0cm 5.4pt 0cm 5.4pt'> |
| 350 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 351 | "EN-US" style= |
| 352 | 'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span></p> |
| 353 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 354 | "EN-US" style= |
| 355 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 356 | <span lang="EN-US" style= |
| 357 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 358 | the additional size of the invisible rectangle at the right |
| 359 | border</span></p> |
| 360 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 361 | "EN-US" style= |
| 362 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 363 | <span lang="EN-US" style= |
| 364 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 365 | (this also equals the half width of the anchor to paint |
| 366 | there)</span></p> |
| 367 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 368 | "EN-US" style= |
| 369 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 370 | <b><span lang="EN-US" style= |
| 371 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>public</span></b> |
| 372 | <b><span lang="EN-US" style= |
| 373 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b> |
| 374 | <b><span lang="EN-US" style= |
| 375 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>final</span></b> |
| 376 | <b><span lang="EN-US" style= |
| 377 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b> |
| 378 | <i><span lang="EN-US" style= |
| 379 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>INVISIBLE_RECT_RIGHT</span></i> |
| 380 | <span lang="EN-US" style= |
| 381 | 'font-size:10.0pt;font-family:"Courier New";color:black'>= |
| 382 | 6;</span></p> |
| 383 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 384 | "EN-US" style= |
| 385 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 386 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 387 | "EN-US" style= |
| 388 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 389 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 390 | "EN-US" style= |
| 391 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 392 | <b><span lang="EN-US" style= |
| 393 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>public</span></b> |
| 394 | <span lang="EN-US" style= |
| 395 | 'font-size:10.0pt; font-family:"Courier New";color:black'>PictogramElement |
| 396 | add(IAddContext context) {</span></p> |
| 397 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 398 | "EN-US" style= |
| 399 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 400 | EClass addedClass = (EClass) context.getNewObject();</span></p> |
| 401 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 402 | "EN-US" style= |
| 403 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 404 | Diagram targetDiagram = (Diagram) |
| 405 | context.getTargetContainer();</span></p> |
| 406 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 407 | "EN-US" style= |
| 408 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 409 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 410 | "EN-US" style= |
| 411 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 412 | <span lang="EN-US" style= |
| 413 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 414 | CONTAINER SHAPE WITH ROUNDED RECTANGLE</span></p> |
| 415 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 416 | "EN-US" style= |
| 417 | 'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span> |
| 418 | <span lang="EN-US" style= |
| 419 | 'font-size:10.0pt;font-family:"Courier New"'>IPeCreateService |
| 420 | peCreateService = Graphiti.getPeCreateService();</span></p> |
| 421 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 422 | "EN-US" style= |
| 423 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 424 | ContainerShape containerShape =</span></p> |
| 425 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 426 | "EN-US" style= |
| 427 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 428 | <span lang="EN-US" style= |
| 429 | 'font-size:10.0pt;font-family:"Courier New"'>peCreateService<span style='color:black'>.createContainerShape(targetDiagram,</span> |
| 430 | <b><span style='color:#7F0055'>true</span></b><span style= |
| 431 | 'color:black'>);</span></span></p> |
| 432 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 433 | "EN-US" style= |
| 434 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 435 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 436 | "EN-US" style= |
| 437 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 438 | <span lang="EN-US" style= |
| 439 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 440 | check whether the context has a size (e.g. from a create |
| 441 | feature)</span></p> |
| 442 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 443 | "EN-US" style= |
| 444 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 445 | <span lang="EN-US" style= |
| 446 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 447 | otherwise define a default size for the shape</span></p> |
| 448 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 449 | "EN-US" style= |
| 450 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 451 | <b><span lang="EN-US" style= |
| 452 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>int</span></b> |
| 453 | <span lang="EN-US" style= |
| 454 | 'font-size:10.0pt; font-family:"Courier New";color:black'>width = |
| 455 | context.getWidth() <= 0 ? 100 : context.getWidth();</span></p> |
| 456 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 457 | "EN-US" style= |
| 458 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 459 | <b><span lang="EN-US" style= |
| 460 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>int</span></b> |
| 461 | <span lang="EN-US" style= |
| 462 | 'font-size:10.0pt; font-family:"Courier New";color:black'>height |
| 463 | = context.getHeight() <= 0 ? 50 : |
| 464 | context.getHeight();</span></p> |
| 465 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 466 | "EN-US" style= |
| 467 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 468 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 469 | "EN-US" style= |
| 470 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 471 | RoundedRectangle roundedRectangle;</span> <span lang="EN-US" |
| 472 | style= |
| 473 | 'font-size: 10.0pt;font-family:"Courier New";color:#3F7F5F'>// |
| 474 | need to access it later</span></p> |
| 475 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 476 | "EN-US" style= |
| 477 | 'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span> |
| 478 | <span lang="EN-US" style= |
| 479 | 'font-size:10.0pt;font-family:"Courier New"'> IGaService |
| 480 | gaService = Graphiti.getGaService();</span></p> |
| 481 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 482 | "EN-US" style= |
| 483 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 484 | {</span></p> |
| 485 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 486 | "EN-US" style= |
| 487 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 488 | <span lang="EN-US" style= |
| 489 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 490 | create invisible outer rectangle expanded by</span></p> |
| 491 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 492 | "EN-US" style= |
| 493 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 494 | <span lang="EN-US" style= |
| 495 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 496 | the width needed for the anchor</span></p> |
| 497 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 498 | "EN-US" style= |
| 499 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 500 | Rectangle invisibleRectangle =</span></p> |
| 501 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 502 | "EN-US" style= |
| 503 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 504 | <span lang="EN-US" style= |
| 505 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.createInvisibleRectangle(containerShape);</span></span></p> |
| 506 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 507 | "EN-US" style= |
| 508 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 509 | </span><span lang="EN-US" |
| 510 | style= |
| 511 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.setLocationAndSizeOfGraphicsAlgorithm(invisibleRectangle,</span></span></p> |
| 512 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 513 | "EN-US" style= |
| 514 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 515 | context.getX(), context.getY(), width +</span> <i><span lang= |
| 516 | "EN-US" style= |
| 517 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>INVISIBLE_RECT_RIGHT</span></i><span lang="EN-US" |
| 518 | style= |
| 519 | 'font-size:10.0pt;font-family:"Courier New";color:black'>,</span></p> |
| 520 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 521 | "EN-US" style= |
| 522 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 523 | height);</span></p> |
| 524 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 525 | "EN-US" style= |
| 526 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 527 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 528 | "EN-US" style= |
| 529 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 530 | <span lang="EN-US" style= |
| 531 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 532 | create and set visible rectangle inside invisible |
| 533 | rectangle</span></p> |
| 534 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 535 | "EN-US" style= |
| 536 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 537 | roundedRectangle |
| 538 | =</span></p> |
| 539 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 540 | "EN-US" style= |
| 541 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 542 | <span lang="EN-US" style= |
| 543 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.createRoundedRectangle(invisibleRectangle, |
| 544 | 5, 5);</span></span></p> |
| 545 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 546 | "EN-US" style= |
| 547 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 548 | roundedRectangle.setForeground(manageColor(</span><i><span lang= |
| 549 | "EN-US" style= |
| 550 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>CLASS_FOREGROUND</span></i><span lang="EN-US" |
| 551 | style= |
| 552 | 'font-size:10.0pt;font-family:"Courier New";color:black'>));</span></p> |
| 553 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 554 | "EN-US" style= |
| 555 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 556 | roundedRectangle.setBackground(manageColor(</span><i><span lang= |
| 557 | "EN-US" style= |
| 558 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>CLASS_BACKGROUND</span></i><span lang="EN-US" |
| 559 | style= |
| 560 | 'font-size:10.0pt;font-family:"Courier New";color:black'>));</span></p> |
| 561 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 562 | "EN-US" style= |
| 563 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 564 | roundedRectangle.setLineWidth(2);</span></p> |
| 565 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 566 | "EN-US" style= |
| 567 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 568 | <span lang="EN-US" style= |
| 569 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.setLocationAndSizeOfGraphicsAlgorithm(roundedRectangle, |
| 570 | 0,</span></span></p> |
| 571 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 572 | "EN-US" style= |
| 573 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 574 | 0, width, height);</span></p> |
| 575 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 576 | "EN-US" style= |
| 577 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 578 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 579 | "EN-US" style= |
| 580 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 581 | <span lang="EN-US" style= |
| 582 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 583 | create link and wire it</span></p> |
| 584 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 585 | "EN-US" style= |
| 586 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 587 | link(containerShape, addedClass);</span></p> |
| 588 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 589 | "EN-US" style= |
| 590 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 591 | }</span></p> |
| 592 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 593 | "EN-US" style= |
| 594 | 'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span></p> |
| 595 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 596 | "EN-US" style= |
| 597 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 598 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 599 | "EN-US" style= |
| 600 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 601 | <span lang="EN-US" style= |
| 602 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 603 | ... EXISTING CODING ...</span></p> |
| 604 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 605 | "EN-US" style= |
| 606 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 607 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 608 | "EN-US" style= |
| 609 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 610 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 611 | "EN-US" style= |
| 612 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 613 | <span lang="EN-US" style= |
| 614 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 615 | add a chopbox anchor to the shape</span></p> |
| 616 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 617 | "EN-US" style= |
| 618 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 619 | <span lang="EN-US" style= |
| 620 | 'font-size:10.0pt;font-family:"Courier New"'>peCreateService<span style='color:black'>.createChopboxAnchor(containerShape);</span></span></p> |
| 621 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 622 | "EN-US" style= |
| 623 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 624 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 625 | "EN-US" style= |
| 626 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 627 | <span lang="EN-US" style= |
| 628 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 629 | create an additional box relative anchor at |
| 630 | middle-right</span></p> |
| 631 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 632 | "EN-US" style= |
| 633 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 634 | BoxRelativeAnchor boxAnchor =</span></p> |
| 635 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 636 | "EN-US" style= |
| 637 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 638 | <span lang="EN-US" style= |
| 639 | 'font-size:10.0pt;font-family:"Courier New"'>peCreateService<span style='color:black'>.createBoxRelativeAnchor(containerShape);</span></span></p> |
| 640 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 641 | "EN-US" style= |
| 642 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 643 | boxAnchor.setRelativeWidth(1.0);</span></p> |
| 644 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 645 | "EN-US" style= |
| 646 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 647 | boxAnchor.setRelativeHeight(0.5);</span></p> |
| 648 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 649 | "EN-US" style= |
| 650 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 651 | <span lang="EN-US" style= |
| 652 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 653 | anchor references visible rectangle instead of invisible |
| 654 | rectangle</span></p> |
| 655 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 656 | "EN-US" style= |
| 657 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 658 | boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);</span></p> |
| 659 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 660 | "EN-US" style= |
| 661 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 662 | <span lang="EN-US" style= |
| 663 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 664 | assign a graphics algorithm for the box relative |
| 665 | anchor</span></p> |
| 666 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 667 | "EN-US" style= |
| 668 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 669 | Rectangle boxRect =</span> <span lang="EN-US" style= |
| 670 | 'font-size:10.0pt; font-family:"Courier New"'>gaService<span style='color:black'>.createRectangle(boxAnchor);</span></span></p> |
| 671 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 672 | "EN-US" style= |
| 673 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 674 | <span lang="EN-US" style= |
| 675 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 676 | anchor is located on the right border of the visible |
| 677 | rectangle</span></p> |
| 678 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 679 | "EN-US" style= |
| 680 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 681 | <span lang="EN-US" style= |
| 682 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 683 | and touches the border of the invisible rectangle</span></p> |
| 684 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 685 | "EN-US" style= |
| 686 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 687 | <b><span lang="EN-US" style= |
| 688 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>int</span></b> |
| 689 | <span lang="EN-US" style= |
| 690 | 'font-size:10.0pt; font-family:"Courier New";color:black'>w |
| 691 | =</span> <i><span lang="EN-US" style= |
| 692 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>INVISIBLE_RECT_RIGHT</span></i><span lang="EN-US" |
| 693 | style= |
| 694 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 695 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 696 | "EN-US" style= |
| 697 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 698 | <span lang="EN-US" style= |
| 699 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.setLocationAndSizeOfGraphicsAlgorithm(boxRect, |
| 700 | -w, -w, 2 * w,</span></span></p> |
| 701 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 702 | "EN-US" style= |
| 703 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 704 | 2 * w);</span></p> |
| 705 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 706 | "EN-US" style= |
| 707 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 708 | Color c =</span> <span lang="EN-US" style= |
| 709 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.manageColor(getDiagram(), |
| 710 | IColorConstant.</span><i><span style= |
| 711 | 'color:#0000C0'>DARK_BLUE</span></i><span style= |
| 712 | 'color:black'>);</span></span></p> |
| 713 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 714 | "EN-US" style= |
| 715 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 716 | boxRect.setBackground(c);</span></p> |
| 717 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 718 | "EN-US" style= |
| 719 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 720 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 721 | "EN-US" style= |
| 722 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 723 | <span lang="EN-US" style= |
| 724 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 725 | call the layout feature</span></p> |
| 726 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 727 | "EN-US" style= |
| 728 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 729 | <span style= |
| 730 | 'font-size:10.0pt;font-family:"Courier New";color:black'>layoutPictogramElement(containerShape);</span></p> |
| 731 | <p class="MsoNormal" style='text-autospace:none'><span style= |
| 732 | 'font-size:10.0pt; font-family:"Courier New"'> </span></p> |
| 733 | <p class="MsoNormal" style='text-autospace:none'><span style= |
| 734 | 'font-size:10.0pt; font-family:"Courier New";color:black'> </span> |
| 735 | <b><span style= |
| 736 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b> |
| 737 | <span style= |
| 738 | 'font-size:10.0pt;font-family:"Courier New";color:black'>containerShape;</span></p> |
| 739 | <p class="MsoNormal" style='text-autospace:none'><span style= |
| 740 | 'font-size:10.0pt; font-family:"Courier New";color:black'> |
| 741 | }</span></p> |
| 742 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 743 | "EN-US" style= |
| 744 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 745 | </td> |
| 746 | </tr> |
| 747 | </table> |
| 748 | <p class="MsoNormal"><span lang="EN-US" style= |
| 749 | 'color:black'> </span></p> |
| 750 | <p class="MsoNormal"><span lang="EN-US" style= |
| 751 | 'color:black'> </span></p> |
| 752 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>Next |
| 753 | we have to change the layout method of the <a href= |
| 754 | "layout-feature.htm">layout feature</a><span class= |
| 755 | "code1"><span style='font-style:normal'>. Previously it adjusted |
| 756 | the size of the inner graphics algorithms (line and text) in |
| 757 | relation to the container graphics algorithm (visible rectangle). |
| 758 | Now it has to adjust the size of the inner graphics algorithms |
| 759 | (visible rectangle, line and text) in relation to the container |
| 760 | graphics algorithm (invisible |
| 761 | rectangle).</span></span></span></p> |
| 762 | <p class="MsoNormal"><span class="code1"><span lang="EN-US" |
| 763 | style='color:black; font-style:normal'>The implementation can be |
| 764 | seen in the following code-snippet:</span></span></p> |
| 765 | <p class="MsoNormal"><span lang="EN-US" style= |
| 766 | 'color:black'> </span></p> |
| 767 | <table class="MsoNormalTable" border="0" cellspacing="0" |
| 768 | cellpadding="0" width="851" style= |
| 769 | 'width:18.0cm;border-collapse:collapse'> |
| 770 | <tr> |
| 771 | <td width="851" valign="top" style= |
| 772 | 'width:18.0cm;border:solid windowtext 1.0pt; padding:0cm 5.4pt 0cm 5.4pt'> |
| 773 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 774 | "EN-US" style='color:black'> </span></p> |
| 775 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 776 | "EN-US" style= |
| 777 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 778 | <b><span lang="EN-US" style= |
| 779 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>public</span></b> |
| 780 | <b><span lang="EN-US" style= |
| 781 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b> |
| 782 | <span lang="EN-US" style= |
| 783 | 'font-size:10.0pt;font-family:"Courier New";color:black'>layout(ILayoutContext |
| 784 | context) {</span></p> |
| 785 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 786 | "EN-US" style= |
| 787 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 788 | <b><span lang="EN-US" style= |
| 789 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>boolean</span></b> |
| 790 | <span lang="EN-US" style= |
| 791 | 'font-size:10.0pt; font-family:"Courier New";color:black'>anythingChanged |
| 792 | =</span> <b><span lang="EN-US" style= |
| 793 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span lang="EN-US" |
| 794 | style= |
| 795 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 796 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 797 | "EN-US" style= |
| 798 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 799 | ContainerShape containerShape =</span></p> |
| 800 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 801 | "EN-US" style= |
| 802 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 803 | (ContainerShape) context.getPictogramElement();</span></p> |
| 804 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 805 | "EN-US" style= |
| 806 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 807 | GraphicsAlgorithm containerGa = |
| 808 | containerShape.getGraphicsAlgorithm();</span></p> |
| 809 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 810 | "EN-US" style= |
| 811 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 812 | <span lang="EN-US" style= |
| 813 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 814 | the containerGa is the invisible rectangle</span></p> |
| 815 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 816 | "EN-US" style= |
| 817 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 818 | <span lang="EN-US" style= |
| 819 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 820 | containing the visible rectangle as its (first and only) |
| 821 | child</span></p> |
| 822 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 823 | "EN-US" style= |
| 824 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 825 | GraphicsAlgorithm rectangle =</span></p> |
| 826 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 827 | "EN-US" style= |
| 828 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 829 | containerGa.getGraphicsAlgorithmChildren().get(0);</span></p> |
| 830 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 831 | "EN-US" style= |
| 832 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 833 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 834 | "EN-US" style= |
| 835 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 836 | <span lang="EN-US" style= |
| 837 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 838 | height of invisible rectangle</span></p> |
| 839 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 840 | "EN-US" style= |
| 841 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 842 | <b><span lang="EN-US" style= |
| 843 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 844 | <span lang="EN-US" style= |
| 845 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(containerGa.getHeight() |
| 846 | <</span> <i><span lang="EN-US" style= |
| 847 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span lang="EN-US" |
| 848 | style='font-size:10.0pt;font-family:"Courier New";color:black'>) |
| 849 | {</span></p> |
| 850 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 851 | "EN-US" style= |
| 852 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 853 | containerGa.setHeight(</span><i><span lang="EN-US" style= |
| 854 | 'font-size:10.0pt; font-family:"Courier New";color:#0000C0'>MIN_HEIGHT</span></i><span lang="EN-US" |
| 855 | style= |
| 856 | 'font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| 857 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 858 | "EN-US" style= |
| 859 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 860 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 861 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 862 | style= |
| 863 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 864 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 865 | "EN-US" style= |
| 866 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 867 | }</span></p> |
| 868 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 869 | "EN-US" style= |
| 870 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 871 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 872 | "EN-US" style= |
| 873 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 874 | <span lang="EN-US" style= |
| 875 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 876 | height of visible rectangle (same as invisible |
| 877 | rectangle)</span></p> |
| 878 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 879 | "EN-US" style= |
| 880 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 881 | <b><span lang="EN-US" style= |
| 882 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 883 | <span lang="EN-US" style= |
| 884 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(rectangle.getHeight() |
| 885 | != containerGa.getHeight()) {</span></p> |
| 886 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 887 | "EN-US" style= |
| 888 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 889 | rectangle.setHeight(containerGa.getHeight());</span></p> |
| 890 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 891 | "EN-US" style= |
| 892 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 893 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 894 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 895 | style= |
| 896 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 897 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 898 | "EN-US" style= |
| 899 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 900 | }</span></p> |
| 901 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 902 | "EN-US" style= |
| 903 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 904 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 905 | "EN-US" style= |
| 906 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 907 | <span lang="EN-US" style= |
| 908 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 909 | width of invisible rectangle</span></p> |
| 910 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 911 | "EN-US" style= |
| 912 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 913 | <b><span lang="EN-US" style= |
| 914 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 915 | <span lang="EN-US" style= |
| 916 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(containerGa.getWidth() |
| 917 | <</span> <i><span lang="EN-US" style= |
| 918 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span lang="EN-US" |
| 919 | style='font-size:10.0pt;font-family:"Courier New";color:black'>) |
| 920 | {</span></p> |
| 921 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 922 | "EN-US" style= |
| 923 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 924 | containerGa.setWidth(</span><i><span lang="EN-US" |
| 925 | style= |
| 926 | 'font-size:10.0pt;font-family:"Courier New";color:#0000C0'>MIN_WIDTH</span></i><span lang="EN-US" |
| 927 | style= |
| 928 | 'font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| 929 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 930 | "EN-US" style= |
| 931 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 932 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 933 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 934 | style= |
| 935 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 936 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 937 | "EN-US" style= |
| 938 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 939 | }</span></p> |
| 940 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 941 | "EN-US" style= |
| 942 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 943 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 944 | "EN-US" style= |
| 945 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 946 | <span lang="EN-US" style= |
| 947 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 948 | width of visible rectangle (smaller than invisible |
| 949 | rectangle)</span></p> |
| 950 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 951 | "EN-US" style= |
| 952 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 953 | <b><span lang="EN-US" style= |
| 954 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>int</span></b> |
| 955 | <span lang="EN-US" style= |
| 956 | 'font-size:10.0pt; font-family:"Courier New";color:black'>rectangleWidth |
| 957 | =</span></p> |
| 958 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 959 | "EN-US" style= |
| 960 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 961 | containerGa.getWidth()</span></p> |
| 962 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 963 | "EN-US" style= |
| 964 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 965 | - TutorialEAddClassFeature.</span><i><span lang="EN-US" style= |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 966 | 'font-size:10.0pt; font-family:"Courier New";color:#0000C0'>INVISIBLE_RECT_RIGHT</span></i><span lang="EN-US" |
| 967 | style= |
| 968 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 969 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 970 | "EN-US" style= |
| 971 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 972 | <b><span lang="EN-US" style= |
| 973 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 974 | <span lang="EN-US" style= |
| 975 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(rectangle.getWidth() |
| 976 | != rectangleWidth) {</span></p> |
| 977 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 978 | "EN-US" style= |
| 979 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 980 | rectangle.setWidth(rectangleWidth);</span></p> |
| 981 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 982 | "EN-US" style= |
| 983 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 984 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 985 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 986 | style= |
| 987 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 988 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 989 | "EN-US" style= |
| 990 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 991 | }</span></p> |
| 992 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 993 | "EN-US" style= |
| 994 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 995 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 996 | "EN-US" style= |
| 997 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 998 | <span lang="EN-US" style= |
| 999 | 'font-size:10.0pt;font-family:"Courier New"; color:#3F7F5F'>// |
| 1000 | width of text and line (same as visible rectangle)</span></p> |
| 1001 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1002 | "EN-US" style= |
| 1003 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1004 | Iterator iter = |
| 1005 | containerShape.getChildren().iterator();</span></p> |
| 1006 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1007 | "EN-US" style= |
| 1008 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1009 | <b><span lang="EN-US" style= |
| 1010 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>while</span></b> |
| 1011 | <span lang="EN-US" style= |
| 1012 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(iter.hasNext()) |
| 1013 | {</span></p> |
| 1014 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1015 | "EN-US" style= |
| 1016 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1017 | Shape shape = (Shape) iter.next();</span></p> |
| 1018 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1019 | "EN-US" style= |
| 1020 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1021 | GraphicsAlgorithm graphicsAlgorithm = |
| 1022 | shape.getGraphicsAlgorithm();</span></p> |
| 1023 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1024 | "EN-US" style= |
| 1025 | 'font-size:10.0pt;font-family:"Courier New"'> |
| 1026 | IGaService gaService = Graphiti.getGaService();</span></p> |
| 1027 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1028 | "EN-US" style= |
| 1029 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1030 | IDimension size =</span></p> |
| 1031 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1032 | "EN-US" style= |
| 1033 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1034 | <span lang="EN-US" style= |
| 1035 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.<i>calculateSizeOfGraphicsAlgorithm</i>(graphicsAlgorithm);</span></span></p> |
| 1036 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1037 | "EN-US" style= |
| 1038 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1039 | <b><span lang="EN-US" style= |
| 1040 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 1041 | <span lang="EN-US" style= |
| 1042 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(rectangleWidth |
| 1043 | != size.getWidth()) {</span></p> |
| 1044 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1045 | "EN-US" style= |
| 1046 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1047 | <b><span lang="EN-US" style= |
| 1048 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 1049 | <span lang="EN-US" style= |
| 1050 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(graphicsAlgorithm</span> |
| 1051 | <b><span lang="EN-US" style= |
| 1052 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b> |
| 1053 | <span lang="EN-US" style= |
| 1054 | 'font-size:10.0pt;font-family:"Courier New";color:black'>Polyline) |
| 1055 | {</span></p> |
| 1056 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1057 | "EN-US" style= |
| 1058 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1059 | Polyline polyline = (Polyline) graphicsAlgorithm;</span></p> |
| 1060 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1061 | "EN-US" style= |
| 1062 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1063 | Point secondPoint = polyline.getPoints().get(1);</span></p> |
| 1064 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1065 | "EN-US" style= |
| 1066 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1067 | Point newSecondPoint =</span></p> |
| 1068 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1069 | "EN-US" style= |
| 1070 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1071 | <span lang="EN-US" style= |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 1072 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.<i>createPoint</i>(rectangleWidth,</span></span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1073 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1074 | "EN-US" style= |
| 1075 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1076 | secondPoint.getY());</span></p> |
| 1077 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1078 | "EN-US" style= |
| 1079 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1080 | polyline.getPoints().set(1, newSecondPoint);</span></p> |
| 1081 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1082 | "EN-US" style= |
| 1083 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1084 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 1085 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 1086 | style= |
| 1087 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 1088 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1089 | "EN-US" style= |
| 1090 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1091 | }</span> <b><span lang="EN-US" style= |
| 1092 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>else</span></b> |
| 1093 | <span lang="EN-US" style= |
| 1094 | 'font-size:10.0pt; font-family:"Courier New";color:black'>{</span></p> |
| 1095 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1096 | "EN-US" style= |
| 1097 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1098 | <span lang="EN-US" style= |
| 1099 | 'font-size:10.0pt;font-family:"Courier New"'>gaService<span style='color:black'>.<i>setWidthOfGraphicsAlgorithm</i>(graphicsAlgorithm,</span></span></p> |
| 1100 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1101 | "EN-US" style= |
| 1102 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1103 | rectangleWidth);</span></p> |
| 1104 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1105 | "EN-US" style= |
| 1106 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1107 | anythingChanged =</span> <b><span lang="EN-US" style= |
| 1108 | 'font-size:10.0pt; font-family:"Courier New";color:#7F0055'>true</span></b><span lang="EN-US" |
| 1109 | style= |
| 1110 | 'font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 1111 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1112 | "EN-US" style= |
| 1113 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1114 | }</span></p> |
| 1115 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1116 | "EN-US" style= |
| 1117 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1118 | }</span></p> |
| 1119 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1120 | "EN-US" style= |
| 1121 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1122 | }</span></p> |
| 1123 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1124 | "EN-US" style= |
| 1125 | 'font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 1126 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1127 | "EN-US" style= |
| 1128 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1129 | <b><span lang="EN-US" style= |
| 1130 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>return</span></b> |
| 1131 | <span lang="EN-US" style= |
| 1132 | 'font-size:10.0pt; font-family:"Courier New";color:black'>anythingChanged;</span></p> |
| 1133 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1134 | "EN-US" style= |
| 1135 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1136 | <span style= |
| 1137 | 'font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| 1138 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1139 | "EN-US" style= |
| 1140 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 1141 | </td> |
| 1142 | </tr> |
| 1143 | </table> |
| 1144 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1145 | 'color:black'> </span></p> |
| 1146 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1147 | 'color:black'> </span></p> |
| 1148 | <h2><span lang="EN-US">Test: Create a EClass with Extended |
| 1149 | Rendering Area</span></h2> |
| 1150 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1151 | 'color:black'> </span></p> |
| 1152 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>Start |
| 1153 | the editor and create a new EClass. Verify that the EClass and |
| 1154 | its selection-handles look similar to the figures |
| 1155 | above. </span></p> |
| 1156 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1157 | 'color:black'> </span></p> |
| 1158 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1159 | 'color:black'> </span></p> |
| 1160 | <h2><span lang="EN-US">Adjusting the Selection |
| 1161 | Behavior</span></h2> |
| 1162 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1163 | 'color:black'> </span></p> |
| 1164 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>As |
| 1165 | you can see above the selection-handles of the EClass are around |
| 1166 | the invisible rectangle.</span></p> |
| 1167 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>This |
| 1168 | is not a good selection-behavior, because the user considers the |
| 1169 | visible rectangle as the ‘main’ graphics algorithm |
| 1170 | and doesn’t care about the extra space needed to show the |
| 1171 | anchor. This also means that when resizing/moving the EClass, |
| 1172 | this should be done on the visible rectangle and not the |
| 1173 | invisible rectangle.</span></p> |
| 1174 | <p class="MsoNormal"><span lang="EN-US" style='color:black'>In |
| 1175 | the following we want to change the selection behavior in a way |
| 1176 | that the selection-handles appear directly around the visible |
| 1177 | rectangle, as you can see in the following figure:</span></p> |
| 1178 | <p class="MsoNormal"><span style='color:black'><img border="0" |
| 1179 | width="121" height="71" src="visio/rendering-area-2c.gif" alt= |
| 1180 | ""></span></p> |
| 1181 | <p class="MsoCaption"><span class="code1"><span lang="EN-US" |
| 1182 | style='font-style:normal'>Figure: Selection-handles around the |
| 1183 | visible rectangle</span></span><span lang= |
| 1184 | "EN-US"> </span></p> |
| 1185 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1186 | 'color:black'>Additionally we want to define the visible |
| 1187 | rectangle as the selection-area, which activates the selection |
| 1188 | when the mouse clicks into it. So a mouse click on the invisible |
| 1189 | rectangle outside the visible rectangle will no longer activate |
| 1190 | the selection. </span></p> |
| 1191 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1192 | 'color:black'> </span></p> |
| 1193 | <p class="MsoNormal"><span lang="EN-GB" style= |
| 1194 | 'color:black'>Selection areas are defined in the tool behavior |
| 1195 | provider.</span></p> |
| 1196 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>If |
| 1197 | you didn’t do so already you must <b>first create a tool |
| 1198 | behavior provider and add it to the diagram type provider as |
| 1199 | described <a href= |
| 1200 | "tool-behavior-provider.htm">here</a>.</b></span></p> |
| 1201 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>The |
| 1202 | following methods of the tool behavior provider must be |
| 1203 | overwritten:</span></p> |
| 1204 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>The |
| 1205 | method <a href= |
| 1206 | "file://///wdfd00184898a/../javadoc/com/sap/tc/emf/gfw/tb/IToolBehaviorProvider.html#getSelectionGraphicsAlgorithm(com.sap.tc.emf.gfw.mm.pictograms.PictogramElement)"> |
| 1207 | getSelectionGraphicsAlgorithm</a> has to return one graphics |
| 1208 | algorithm, which defines the selection-handle.</span></p> |
| 1209 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>The |
| 1210 | method <a href= |
| 1211 | "file://///wdfd00184898a/../javadoc/com/sap/tc/emf/gfw/tb/IToolBehaviorProvider.html#getSelectionArea(com.sap.tc.emf.gfw.mm.pictograms.PictogramElement)"> |
| 1212 | getSelectionArea</a> has to return multiple graphics algorithms, |
| 1213 | which union defines the selection-area inside which mouse-clicks |
| 1214 | activate the selection.</span></p> |
| 1215 | <p class="MsoNormal"><span lang="EN-GB" style= |
| 1216 | 'color:black'> </span></p> |
| 1217 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>In |
| 1218 | this example we want to return the visible rectangle in both |
| 1219 | methods. </span></p> |
| 1220 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1221 | 'color:black'> </span></p> |
| 1222 | <p class="MsoNormal"><span lang="EN-GB" style='color:black'>You |
| 1223 | can see the complete implementation of the selection area |
| 1224 | here:</span></p> |
| 1225 | <p class="MsoNormal"><span lang="EN-GB" style= |
| 1226 | 'color:black'> </span></p> |
| 1227 | <table class="MsoNormalTable" border="0" cellspacing="0" |
| 1228 | cellpadding="0" width="851" style= |
| 1229 | 'width:18.0cm;border-collapse:collapse'> |
| 1230 | <tr> |
| 1231 | <td width="851" valign="top" style= |
| 1232 | 'width:18.0cm;border:solid windowtext 1.0pt; padding:0cm 5.4pt 0cm 5.4pt'> |
| 1233 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1234 | "EN-US" style='color:black'> </span></p> |
| 1235 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1236 | "EN-US" style= |
| 1237 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1238 | <span lang="EN-US" style= |
| 1239 | 'font-size:10.0pt;font-family:"Courier New"; color:#646464'>@Override</span></p> |
| 1240 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1241 | "EN-US" style= |
| 1242 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1243 | <b><span lang="EN-US" style= |
| 1244 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>public</span></b> |
| 1245 | <span lang="EN-US" style= |
| 1246 | 'font-size:10.0pt; font-family:"Courier New";color:black'>GraphicsAlgorithm[] |
| 1247 | getSelectionArea(PictogramElement pe) {</span></p> |
| 1248 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1249 | "EN-US" style= |
| 1250 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1251 | IFeatureProvider featureProvider = |
| 1252 | getFeatureProvider();</span></p> |
| 1253 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1254 | "EN-US" style= |
| 1255 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1256 | Object bo = |
| 1257 | featureProvider.getBusinessObjectForPictogramElement(pe);</span></p> |
| 1258 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1259 | "EN-US" style= |
| 1260 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1261 | <b><span lang="EN-US" style= |
| 1262 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 1263 | <span lang="EN-US" style= |
| 1264 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(bo</span> |
| 1265 | <b><span lang="EN-US" style= |
| 1266 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b> |
| 1267 | <span lang="EN-US" style= |
| 1268 | 'font-size:10.0pt;font-family:"Courier New";color:black'>EClass) |
| 1269 | {</span></p> |
| 1270 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1271 | "EN-US" style= |
| 1272 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1273 | GraphicsAlgorithm invisible = |
| 1274 | pe.getGraphicsAlgorithm();</span></p> |
| 1275 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1276 | "EN-US" style= |
| 1277 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1278 | GraphicsAlgorithm rectangle =</span></p> |
| 1279 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1280 | "EN-US" style= |
| 1281 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1282 | invisible.getGraphicsAlgorithmChildren().get(0);</span></p> |
| 1283 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1284 | "EN-US" style= |
| 1285 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1286 | <b><span lang="EN-US" style= |
| 1287 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>return</span></b> |
| 1288 | <b><span lang="EN-US" style= |
| 1289 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b> |
| 1290 | <span lang="EN-US" style= |
| 1291 | 'font-size:10.0pt;font-family:"Courier New";color:black'>GraphicsAlgorithm[] |
| 1292 | { rectangle };</span></p> |
| 1293 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1294 | "EN-US" style= |
| 1295 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1296 | }</span></p> |
| 1297 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1298 | "EN-US" style= |
| 1299 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1300 | <b><span lang="EN-US" style= |
| 1301 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>return</span></b> |
| 1302 | <b><span lang="EN-US" style= |
| 1303 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span lang="EN-US" |
| 1304 | style= |
| 1305 | 'font-size:10.0pt;font-family:"Courier New";color:black'>.getSelectionArea(pe);</span></p> |
| 1306 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1307 | "EN-US" style= |
| 1308 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1309 | }</span></p> |
| 1310 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1311 | "EN-US" style= |
| 1312 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 1313 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1314 | "EN-US" style= |
| 1315 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1316 | <span lang="EN-US" style= |
| 1317 | 'font-size:10.0pt;font-family:"Courier New"; color:#646464'>@Override</span></p> |
| 1318 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1319 | "EN-US" style= |
| 1320 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1321 | <b><span lang="EN-US" style= |
| 1322 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>public</span></b> |
| 1323 | <span lang="EN-US" style= |
| 1324 | 'font-size:10.0pt; font-family:"Courier New";color:black'>GraphicsAlgorithm |
| 1325 | getSelectionGraphicsAlgorithm(</span></p> |
| 1326 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1327 | "EN-US" style= |
| 1328 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1329 | PictogramElement pe) {</span></p> |
| 1330 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1331 | "EN-US" style= |
| 1332 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1333 | IFeatureProvider featureProvider = |
| 1334 | getFeatureProvider();</span></p> |
| 1335 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1336 | "EN-US" style= |
| 1337 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1338 | Object bo = |
| 1339 | featureProvider.getBusinessObjectForPictogramElement(pe);</span></p> |
| 1340 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1341 | "EN-US" style= |
| 1342 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1343 | <b><span lang="EN-US" style= |
| 1344 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>if</span></b> |
| 1345 | <span lang="EN-US" style= |
| 1346 | 'font-size:10.0pt; font-family:"Courier New";color:black'>(bo</span> |
| 1347 | <b><span lang="EN-US" style= |
| 1348 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b> |
| 1349 | <span lang="EN-US" style= |
| 1350 | 'font-size:10.0pt;font-family:"Courier New";color:black'>EClass) |
| 1351 | {</span></p> |
| 1352 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1353 | "EN-US" style= |
| 1354 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1355 | GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();<br> |
| 1356 | |
| 1357 | EList<GraphicsAlgorithm> graphicsAlgorithmChildren =<br> |
| 1358 | |
| 1359 | invisible.getGraphicsAlgorithmChildren();</span></p> |
| 1360 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1361 | "EN-US" style= |
| 1362 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 1363 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1364 | "EN-US" style= |
| 1365 | 'font-size:10.0pt;font-family:"Courier New"'> |
| 1366 | <b><span style='color:purple'>if</span></b> |
| 1367 | (!graphicsAlgorithmChildren.isEmpty()) {<br> |
| 1368 | |
| 1369 | <b><span style='color:purple'>return</span></b> |
| 1370 | graphicsAlgorithmChildren.get(0);<br> |
| 1371 | |
| 1372 | }</span></p> |
| 1373 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1374 | "EN-US" style= |
| 1375 | 'font-size:10.0pt;font-family:"Courier New";color:black'> |
| 1376 | }</span></p> |
| 1377 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1378 | "EN-US" style= |
| 1379 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1380 | <b><span lang="EN-US" style= |
| 1381 | 'font-size:10.0pt;font-family:"Courier New"; color:#7F0055'>return</span></b> |
| 1382 | <b><span lang="EN-US" style= |
| 1383 | 'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span lang="EN-US" |
| 1384 | style= |
| 1385 | 'font-size:10.0pt;font-family:"Courier New";color:black'>.getSelectionGraphicsAlgorithm(pe);</span></p> |
| 1386 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1387 | "EN-US" style= |
| 1388 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span> |
| 1389 | <span style= |
| 1390 | 'font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| 1391 | <p class="MsoNormal" style='text-autospace:none'><span style= |
| 1392 | 'font-size:10.0pt; font-family:"Courier New"'> </span></p> |
| 1393 | <p class="MsoNormal" style='text-autospace:none'><span lang= |
| 1394 | "EN-US" style= |
| 1395 | 'font-size:10.0pt;font-family:"Courier New";color:black'> </span></p> |
| 1396 | </td> |
| 1397 | </tr> |
| 1398 | </table> |
| 1399 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1400 | 'color:black'> </span></p> |
| 1401 | <p class="MsoNormal"><span lang="EN-US" style= |
| 1402 | 'color:black'> </span></p> |
| 1403 | <h2><span lang="EN-US">Test: Verify the Adjusted Selection |
| 1404 | Behavior</span></h2> |
| 1405 | <p class="MsoNormal"><span lang="EN-US" style= |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 1406 | 'color:black'><i>Note</i>: This change is incompatible with diagrams created in earlier stages of the tutorial. You will get an exception, when opening these diagrams.</span></p> |
| 1407 | <p class="MsoNormal"><span lang="EN-US" style= |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1408 | 'color:black'> </span></p> |
jpasch | fa23971 | 2010-06-23 12:00:55 +0000 | [diff] [blame^] | 1409 | <p class="MsoNormal">S<span lang="EN-US" style='color:black'>tart |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1410 | the editor and create a new EClass. Click on the visible |
| 1411 | rectangle and verify that the selection-handles are only around |
| 1412 | the visible rectangle. Click slightly right of the visible |
| 1413 | rectangle on the invisible rectangle and verify that the EClass |
| 1414 | becomes deselected.</span></p> |
| 1415 | <p class="MsoNormal"><span lang="EN-US"> </span></p> |
| 1416 | <p class="MsoNormal"><span lang="EN-GB" style= |
| 1417 | 'color:black'> </span></p> |
| 1418 | </div> |
| 1419 | <hr> |
| 1420 | <a href="http://www.eclipse.org/legal/epl-v10.html" shape="rect">Copyright (c) SAP AG 2005, 2010.</a> |
| 1421 | </body> |
| 1422 | </html> |