Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Node autosizing



This article presents how to customize the autosizing of nodes.

Autosizing on yEd

yEd allows to fit a node to its label by using the "Fit Node to Label" option after selecting a node:
fitnodetolabel
However, this autosizing is not automatic, and you must perform it node by node after selecting a node[1]
Or by selecting several nodes at the same time
.

Autosizing handling on the GraphML library

The GraphML library allows to perform the autosizing automatically. If the GraphMLNode.setAutosized(boolean) is set to true, then the node size will be fit to adapt to its label size. The ShapeNode.getWidthPadding() and ShapeNode.getHeightPadding() will be used to fit the node size around the label.
autosized
It is also possible to do this automatically on all nodes by setting the autosized property of the diagram defaults For example:
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramlDefaults defaults = diagram.getDefaults();
      defaults.autosized = true;
      defaults.padWidth = 10;
      defaults.padHeight = 10;

      GraphMLNode node = diagram.addNode();
      NodeLabel label = node.setLabel("The Label"); // the node size will use the label size plus the pad

Note that the defaults.autosized property works with labels on several lines too.

Notes

  1. ^ Or by selecting several nodes at the same time

See also


Categories: general | nodes

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