Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Node labels



A node can have one label.

For example:
      GraphMLNode node = diagram.addNode();
      node.setLabel("The Label");

Settings the label

Main Article: Labels

To set the label of a node, you can use one of the following methods: For example:
      GraphMLNode node = diagram.addNode();
      node.setLabel("The Label");
By default the text color is black, and the label has no background and no border. However it is possible to set the text color of the label. For example:
      NodeLabel label = node.setLabel("The Label");
      label.setTextColor(Color.RED);

Node label placement

Main Article: Node label position

To customize the position of the label on the node, you must access the label placement through the AbstractLabel.createLabelPlacement(). The resulting LabelPlacement class allows to customize the position of the label relative to the box of the node.

For example, to have the label on the top of the node, you can use:
      GraphMLNode node = diagram.addNode();
      node.setLabel("The Label");
      LabelPlacement placement = label.createLabelPlacement();
      placement.setPlacementModel(LabelPlacement.MODEL_INTERNAL);
      placement.setPlacement(LabelPlacement.PLACEMENT_TOP);
The result will be:
nodelabeltop

Adding an icon to the label

Main Article: Node label icons

It is possible to add an icon to a node label with one of the following methods: Additional methods allow to set the scale of the image representation on the node:

See also


Categories: edges | general | nodes

Copyright 2021 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence