Creating a New Project

Layout algorithms are developed as Eclipse Plug-in Projects. There’s a few things to setup to get your project ready, which is what we will work through here.

If you have nothing better to do…

This ticket is all about adding an ELK Project Wizard to the ELK SDK that will help people create new layout algorithm projects that are already perfectly setup. If you want to make people’s lifes better but don’t know how, here’s your chance!

Creating a New Plug-in

Follow these steps to create a new plug-in:

  1. From the File menu, select New - Project….
  2. From the Plug-in Development category, select Plug-in Project and click Next.
  3. Configure your project’s basic settings, in particular its name, and click Next.
  4. Configure your project’s content. The Properties should be somewhat sensible, but don’t really matter all that much. In the Options section, uncheck everything (layout algorithm projects normally don’t need an activator class, nor do they normally make contributions to the UI). Also, don’t create a rich client application. Click Finish.

Configuring a new layout algorithm project.

The Package Explorer now shows a new project for your plug-in which we will configure in the next section.

Setting Up Your Plug-in

Your plug-in needs to declare dependencies to ELK’s most important plug-ins: org.eclipse.elk.graph (which contains the graph model that will be the input to your layout algorithm) and org.eclipse.elk.core (which contains the core ELK code). Follow these steps to add the dependencies:

  1. Open the MANIFEST.MF file, located in your plug-in’s META_INF folder. The Plug-in Manifest Editor will open up, which is divided into several pages that you can switch between using the controls at the bottom of the editor.
  2. Open the editor’s Dependencies tab.
  3. Click the left Add… button to add a dependency. In the dialog that pops up, search for the org.eclipse.elk.graph plug-in and click OK.
  4. Repeat for ELK’s core plug-in, org.eclipse.elk.core.

Configuring a new layout algorithm project.

Creating a Layout Provider

While we will discuss the details of implementing the actual layout algorithm later, it is a good idea to already create its main class now for us to be able to reference it. Create a new Java class with the following properties:

  • The package should be your plug-in’s source package. That is, it should be named just like the plug-in. (This is not strictly necessary, but a common convention.)
  • Give it a name that ends in LayoutProvider.
  • Its superclass must be set to org.eclipse.elk.core.AbstractLayoutProvider.

Your class will look something like this:

package cds.layout.simple;

import org.eclipse.elk.core.AbstractLayoutProvider;
import org.eclipse.elk.core.util.IElkProgressMonitor;
import org.eclipse.elk.graph.ElkNode;

public class SimpleLayoutProvider extends AbstractLayoutProvider {

    @Override
    public void layout(ElkNode layoutGraph, IElkProgressMonitor progressMonitor) {
        // TODO Auto-generated method stub

    }

}