Layout Service Example
This guide describes the Layout Service example in the SDK. This example demonstrates a
how to create a custom provider for the Layout Service which can be
invoked from with-in a diagram editor.
This plug-in is named org.eclipse.gmf.examples.runtime.diagram.layout.
The purpose of the
plug-in is provide an action that
invokes a custom layout. 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.
The algorithm for this custom layout is defined inside a provider
called 'SquareLayoutProvider'. To register this provider,
an extension for the org.eclipse.gmf.runtime.diagram.ui.layoutProviders
extension point must be added to the plugin.xml file.
If we examine the 'SquareLayoutProvider' 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 ILayoutNodesOperation is of type
check is necessary because we only want to invoke this layout when
our specific action is called, not when a default arrange action is
(?) routine is where the actual computation
takes place. It returns
a 'Runnable' that performs the
execution of the layout.
Refer to this example if you need:
- How to create a manipulate shapes positions
- How to create a custom layout provider that can be invoked
through a specific action
(c) 2000,2005 IBM Corporation and others. All Rights