tesis-dynaware / graph-editor

Eclipse Public License 1.0
132 stars 42 forks source link

Node labels #26

Closed danielsabinasz closed 8 years ago

danielsabinasz commented 8 years ago

Hi there,

is it possible to add labels to the node? I didn't find any API functions to do this.

Instead, can I somehow add this functionality without forking the code?

Regards, Daniel

rmfisher commented 8 years ago

The dumbest / simplest way to do it is to cast the skin's root JavaFX-Node to a StackPane:

GNode node; // Some node that is part of the model currently set in the graph editor.
GNodeSkin skin = graphEditor.getSkinLookup().lookupNode(node); 
StackPane root = (StackPane) skin.getRoot(); // Assumes default skin implementation.
root.getChildren().add(new Label("Hello World"));

But it's better to create a custom node skin then you can add the label as the skin is being constructed. See the custom skins in the demo for examples.

Just FYI, this project is no longer actively maintained.