...
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
doLayout(...)
method:Code Block language java progressMonitor.begin("Login_name layouter", 1); KShapeLayout parentLayout = parentNode.getData(KShapeLayout.class); float objectSpacing = parentLayout.getProperty(LayoutOptions.SPACING); if (objectSpacing < 0) { objectSpacing = DEFAULT_SPACING; } float borderSpacing = parentLayout.getProperty(LayoutOptions.BORDER_SPACING); if (borderSpacing < 0) { borderSpacing = DEFAULT_SPACING; } // TODO: Insert actual layout code. progressMonitor.done();
- It is now time to write the code that places the nodes. Here's two suggestions for how you can place them:
- The simplest way is to place nodes in a row, next to each other. To make this more interesting, you could also place the nodes along the graph of a Sine function. Another way might be to place them in a square or a circle. You would have to think about how exactly to align the nodes, which may well vary in sizeYour code should place them next to each other in a row, as seen in the screenshot at the beginning of the tutorial.
Info | |||||
---|---|---|---|---|---|
| |||||
The following tips might come in handy...
|
...