Organic Layout with Edge Labeling
This demo shows how to configure the Organic Layout for
automatic edge label placement.
Configuring label placement
Label models and their
parameters determine the position of a label. For
many interactive use cases, it makes sense to choose a model that restricts the available
positions in some way. However, for automatic label placement the opposite is true: Models
that do not impose restrictions on a label's position work best. For instance,
FreeEdgeLabelModel would be a good choice for integrated label placement.
PreferredPlacementDescriptors may be associated with labels to control
automatic placement. Such a descriptor determines if the algorithm will place a label
close to its owner edge's source or target node, next to or on the edge, or even rotate
the label. For better results when using Organic Layout,
both the side and angle of the labels has to be specified relative to the edge.
Note that self-loops and parallel edges are handled by SelfLoopRouter and
ParallelEdgeRouter respectively. Thus, labels of such edges are not
considered by the organic layout algorithm. To place the
labels of these edges, a generic labeling
algorithm has to be applied as a post-processing step.
Code Snippet
You can copy the code snippet to configure the layout from
GitHub.
Demos
See the Edge Label Placement Demo for a more elaborate example regarding
automatic edge label placement.
Documentation
The Labeling and
Automatic Label Placement sections in the Developer's
Guide contain in-depth discussions of the relevant concepts.
See the PreferredPlacementDescriptor API documentation for detailed
information on all available placement options.