05_developer_tutorials:02_extending_groimp:creating-node-class
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 05_developer_tutorials:02_extending_groimp:creating-node-class [2025/01/31 14:13] – removed - external edit (Unknown date) 127.0.0.1 | 05_developer_tutorials:02_extending_groimp:creating-node-class [2025/11/21 16:43] (current) – gaetan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== How to create a node class ===== | ||
| + | Creating an own Java node class is not difficult. The new class, say Cube, has to be a subclass of _de.grogra.graph.impl.Node_ or one of its subclasses. So we have to write something like | ||
| + | |||
| + | |||
| + | <code java> | ||
| + | import de.grogra.graph.impl.Node; | ||
| + | |||
| + | public class Cube extends Node | ||
| + | { | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | However, we also would like our new cube to have a width-attribute. We add this in the usual way: | ||
| + | |||
| + | <code java> | ||
| + | public class Cube extends Node | ||
| + | { | ||
| + | float width = 1; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | So far, this attribute is not registered with the UI and persistence mechanism of GroIMP. It will not be shown in the GUI, and it will not be saved or restored when a cube is written to or read from a data stream. We have to add special " | ||
| + | |||
| + | <code java> | ||
| + | public class Cube extends Node | ||
| + | { | ||
| + | float width = 1; | ||
| + | //enh:field getter setter | ||
| + | |||
| + | // | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The // | ||
| + | |||
| + | === Calling the code enhancer with Maven === | ||
| + | |||
| + | Project compiled with maven will automatically call the code enhancer and update the sources files. | ||
| + | |||
| + | === With ant === | ||
| + | |||
| + | The Perl script is invoked by the target // | ||
| + | |||
| + | <code xml> | ||
| + | <target name=" | ||
| + | <antcall target=" | ||
| + | </ | ||
| + | </ | ||
