Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

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:
If you want the label to be at the top or bottom of the icon, you should set the text vertical position by using the AbstractLabel.setVerticalTextPosition(short) method.

Example

The following code sets the icon on a node label:
      GraphMLFactory factory = GraphMLFactory.getInstance();
      GraphMLDiagram diagram = factory.newDiagram();
   
      GraphMLNode node = diagram.addNode();
      node.setHasFillColor(false);
      node.setHasBorderColor(false);   
   
      NodeLabel label = node.setLabel("The Label");
      label.setVerticalTextPosition(LabelStyle.VERTICALPOS_BOTTOM);
   
      File iconFile = context.getPath("hand.png");   
      label.setIcon(iconFile);
      label.setIconScaleX(0.2f);
      label.setIconScaleY(0.2f);
The result is:
nodeicon

See also


Categories: edges | nodes

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