...
- Right-click the source folder of your plug-in and click New > Class.
- Set the package to
, enterde.cau.cs.kieler.simplelayout
SimpleLayoutProvider
as the class name, and selectdeorg.caueclipse.cselk.kieler.kimlcore.AbstractLayoutProvider
as the superclass. (This will only be available through the Browse dialog if you have saved the plug-in manifest editor; if you haven't, Eclipse won't know about the new dependencies yet.) - Select Generate comments and click Finish.
...
Add the following constants:
Code Block language java /** default value for spacing between nodes. */ private static final float DEFAULT_SPACING = 15.0f;
Use the following code as the skeleton of the doLayoutthe
layout(...)
method:Code Block language java progressMonitor.begin("Simple layouter", 1); KShapeLayout parentLayout = parentNodelayoutGraph.getData(KShapeLayout.class); float objectSpacing = parentLayout.getProperty(LayoutOptionsCoreOptions.SPACING_NODE); if (objectSpacing < 0) { objectSpacing = DEFAULT_SPACING; } float borderSpacing = parentLayout.getProperty(LayoutOptionsCoreOptions.SPACING_BORDER_SPACING); if (borderSpacing < 0) { borderSpacing = DEFAULT_SPACING; } // TODO: Insert actual layout code. progressMonitor.done();
- Press CTRL+SHIFT+O or select Source > Organize Imports from the context menu to add all required imports.
- It is now time to write the code that places the nodes.Your code should place them next to each other in a row, as seen in the screenshot at the beginning of the tutorial.
...
Before you can test your layout code, you will have to register your new layout provider with KIML.
- Rickt-click the
package and select New > File.de.cau.cs.kieler.simplelayout
- Create a file simple.elkm and double click it to open it.
- When asked whether you want to add the Xtext nature, select yes.
- Open the
META-INF/MANIFEST.MF
file again and switch to the Extensions tab. - Add an extension for defor
org.caueclipse.cselk.kielercore.kiml.layout.layoutProviders
. - Right-click the extension and click New > layoutAlgorithm provider.
- Set the name to
Simple Test Layouter
and the class to your layout provider class name (use the browse button and enterSimpleLayoutProvider
). - Right-click the new layoutAlgorithm and click New > knownOption. Set option to
de.cau.cs.kieler.spacing
. - Add another knownOption for
de.cau.cs.kieler.borderSpacing
. - Save the editor
- Your workspace should look similar to this
...