Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Right-click the source folder of your plug-in and click New > Class.
  2. Set the package to de.cau.cs.kieler.simplelayout, enter SimpleLayoutProvider as the class name, and select deorg.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.)
  3. Select Generate comments and click Finish.

...

  1. Add the following constants:

    Code Block
    languagejava
    /** default value for spacing between nodes. */
    private static final float DEFAULT_SPACING = 15.0f;
  2. Use the following code as the skeleton of the doLayoutthe layout(...) method:

    Code Block
    languagejava
    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();
  3. Press CTRL+SHIFT+O or select Source > Organize Imports from the context menu to add all required imports.
  4. 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.

  1. Rickt-click the de.cau.cs.kieler.simplelayout package and select New > File.
  2. Create a file simple.elkm and double click it to open it.
  3. When asked whether you want to add the Xtext nature, select yes.
  4. Open the META-INF/MANIFEST.MF file again and switch to the Extensions tab.
  5. Add an extension for defor org.caueclipse.cselk.kielercore.kiml.layout.layoutProviders.
  6. Right-click the extension and click New > layoutAlgorithm provider.
  7. Set the name to Simple Test Layouter and the class to your layout provider class name (use the browse button and enter SimpleLayoutProvider).
  8. Right-click the new layoutAlgorithm and click New > knownOption. Set option to de.cau.cs.kieler.spacing.
  9. Add another knownOption for de.cau.cs.kieler.borderSpacing.
  10. Save the editor
  11. Your workspace should look similar to this

...