Layout algorithms are developed as Eclipse Plug-in Projects. Let’s work through creating a new project using our wizard and what that project consists of.
Follow these steps to create a new plug-in:
From the File menu, select New - Project….
From the Plug-in Development category, select Plug-in Project and click Next.
Configure your project’s basic settings, in particular its name, and click Next.
Configure the project’s properties as you see fit and click Next.
Select the Layout Algorithm project template. This will cause your project to be initialized with all the necessary files for a simple layout algorithm.
The template requires a name for your layout algorithm. This will usually derive from your project’s name. Click Finish once you have settled on a name.
The Package Explorer now shows a new project for your plug-in.
The wizard creates the following things for your:
MANIFEST.MF file with the necessary dependencies to the Eclipse Layout Kernel so you can use our data structures.
A file called
ILayoutMetaDataProvider which registeres your new layout algorithm with ELK so it can be used.
.melk file which describes your layout algorithm and the options it supports (see this page for more information).
A sample implementation with a simple basic layout provider. Studying this implementation will teach you a lot about how to develop layout algorithms with ELK (see this page for more information).
Somewhat strangely, perhaps, the
ILayoutMetaDataProvider file is located in
/src/META-INF/services instead of
/META-INF/services. There is a reason for that. When we start a project in Eclipse, the non-Java content of its source folders is copied into a
bin folder, which is then put on the class path. Since
/META-INF is not part of a source folder, putting the service file there would mean that the service is not available when started from Eclipse. If you happen to despise this solution, simply define a separate top-level folder, configure it as a source folder, and move
/src/META-INF there. Whatever you do, however, you will always end up with two
META-INF folders in your project.