| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta name="generator" content="HTML Tidy, see www.w3.org" /> |
| <meta http-equiv="Content-Type" |
| content="text/html; charset=iso-8859-1" /> |
| <title>Layout Service Example</title> |
| </head> |
| <body> |
| <h2>Layout Service Example</h2> |
| |
| <h3>Introduction</h3> |
| |
| <p>This guide describes the Layout Service example in the SDK.<span |
| style="mso-spacerun:yes"> </span> This example demonstrates a |
| how to create a custom provider for the Layout Service which can be |
| invoked from with-in a diagram editor.</p> |
| |
| <h3>Description</h3> |
| |
| <p>This plug-in is named <span |
| class="SpellE">org.eclipse.gmf.examples.runtime.diagram.layout</span>. |
| <span style="mso-spacerun:yes"> </span>The purpose of the |
| plug-in is <span class="GramE">provide</span> an action that |
| invokes a custom layout.<span |
| style="mso-spacerun:yes"> </span> In this case the custom |
| layout is called a 'Square' layout which will calculate a square |
| area based on the number of shapes and arrange the shapes in a grid |
| with-in the calculated square.<br /> |
| <br /> |
| The algorithm for this custom layout is defined inside a provider |
| called '<span class="SpellE">SquareLayoutProvider</span>'.<span |
| style="mso-spacerun:yes"> </span> To register this provider, |
| an extension for the <span |
| class="SpellE">org.eclipse.gmf.runtime.diagram.ui.layoutProviders</span> |
| extension point must be added to the <span |
| class="SpellE">plugin.xml</span> file.</p> |
| |
| <p class="MsoNormal"><span class="GramE">i.e.</span></p> |
| |
| <p class="MsoNormal" |
| style="line-height:normal;mso-pagination:widow-orphan; mso-layout-grid-align:none;text-autospace:none"> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> <span |
| style="font-size:10.0pt; font-family:" |
| courier="courier"><extension</span><br /> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> |
| <span class="GramE"><span style="font-size:10.0pt;font-family:" |
| courier="courier">point</span></span><span |
| style="font-size:10.0pt; font-family:" |
| courier="courier">=</span><span |
| style="font-size:10.0pt;font-family:" courier="courier">"<span |
| class="SpellE">org.eclipse.gmf.runtime.diagram.ui.layoutProviders</span>"</span><span |
| style="font-size:10.0pt;font-family:" |
| courier="courier">></span><br /> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><<span |
| class="SpellE">layoutProvider</span></span><span |
| style="font-size:10.0pt; font-family:" courier="courier"><span |
| style="mso-spacerun:yes"> |
| </span></span><span |
| class="GramE"><span style="font-size:10.0pt;font-family:" |
| courier="courier">class</span></span><span |
| style="font-size:10.0pt; font-family:" |
| courier="courier">=</span><span |
| style="font-size:10.0pt;font-family:" |
| courier="courier">"org.eclipse.gmf.examples.runtime.diagram.layout.provider.SquareLayoutProvider"</span><span |
| style="font-size:10.0pt;font-family:" |
| courier="courier">></span><span |
| style="font-size:10.0pt; font-family:" courier="courier"><span |
| style="mso-spacerun:yes"><br /> |
| </span></span> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><Priority</span><br /> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> |
| <span class="GramE"><span style="font-size:10.0pt;font-family:" |
| courier="courier">name</span></span><span |
| style="font-size:10.0pt; font-family:" |
| courier="courier">=</span><span |
| style="font-size:10.0pt;font-family:" |
| courier="courier">"Medium"</span><span |
| style="font-size:10.0pt; font-family:" |
| courier="courier">></span><br /> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"></Priority></span><br /> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> |
| <span style="font-size:10.0pt; font-family:" |
| courier="courier"></<span |
| class="SpellE">layoutProvider</span>></span><br /> |
| <span style="font-size:10.0pt;font-family:" courier="courier"><span |
| style="mso-spacerun:yes"> </span></span> <span |
| style="font-size:10.0pt; font-family:" |
| courier="courier"></extension></span><br /> |
| <br /> |
| If we examine the '<span |
| class="SpellE">SquareLayoutProvider</span>' java class, in the |
| provides() routine, it is merely checking to see if the nodes on |
| the diagram can be laid-out according to the algorithm and also |
| verifying that the layout type being passed through the <span |
| class="SpellE">ILayoutNodesOperation</span> is of type |
| 'SQUARE_LAYOUT'.<span style="mso-spacerun:yes"> </span> This |
| check is necessary because we only want to invoke this layout when |
| our specific action is called, not when a default arrange action is |
| invoked.<br /> |
| <br /> |
| The <span class="SpellE"><span |
| class="GramE">layoutNodes</span></span><span |
| class="GramE">(</span>?) routine is where the actual computation |
| takes place.<span style="mso-spacerun:yes"> </span> It returns |
| a '<span class="SpellE">Runnable</span>' that performs the |
| execution of the layout.<br /> |
| <br /> |
| <img border="0" src="image004.gif" width="852" height="466" /></p> |
| |
| <h3>Usage</h3> |
| |
| <p>Refer to this example if you need:</p> |
| |
| <ol> |
| <li>How to create a manipulate shapes positions |
| programmatically</li> |
| |
| <li>How to create a custom layout provider that can be invoked |
| through a specific action</li> |
| </ol> |
| |
| <br /> |
| <br /> |
| <hr /> |
| <p><a href="http://www.eclipse.org/legal/epl-v10.html">Copyright |
| (c) 2000,2005 IBM Corporation and others. All Rights |
| Reserved.</a></p> |
| |
| <br /> |
| <br /> |
| </body> |
| </html> |
| |