Page History
This page documents how KLay Layered implements label placement, port placement, and node sizing.
Note | ||
---|---|---|
| ||
Everything on this page is still subject to change – this is the bleeding edge of science! We're still working on this stuff, trying out different concepts, and moving things around, all for the benefit of mankind. You're welcome. |
Contents
Table of Contents |
---|
...
At first glance, label placement and node sizing are two separate problems. However, out of the three types of labels we currently support, two have considerable influence on the size of nodes (node labels and port labels, but you already figured this out yourself). Well, in fact, that's not completely true. It's not the labels that influence the size of nodes, it's the placement of labels. And if we didn't care for readability, the placement wouldn't influence node size at all. But we do. Take this simple example:
Warning | ||
---|---|---|
| ||
Insert an image here. Two nodes, each with one port on the western side and one port on the eastern side. Port labels are placed inside the nodes and are the same for both nodes. The left node is too narrow to avoid overlaps between the port labels, the right node is wide enough. |
The
The two nodes have two labeled labelled ports each. Let's assume port positions to be fixed, and labels to be placed inside the nodes. Clearly, the left node is While the port labels fit perfectly fine into Node 1, Node 2 is clearly too narrow for the port labels them to be placed without overlaps. If the labels are to be placed without overlaps, we need : we would have to increase the width of the node. Label placement influences node sizing.
Matters get more complicated if we allow port positions to be changed. If the western port is moved upwards and the eastern port downwards, the labels don't overlap anymoreany more. Thus, label placement also influences port placement.
...
The insets area is the part of the node where port and node labels are placed (if they are placed inside the node as opposed to outside the node). The child area is what is left of the node with the insets subtracted. With the SizeOptions.COMPUTE_INSETS
, KLay Layered can compute the child area and return it. This makes it easy to use in cases where the child area of the node is going to be used for displaying graphics or further text. If a minimum size is set on the node and the options SizeConstraint.MINIMUM_SIZE
and SizeOPTIONSSizeOptions.MINIMUM_SIZE_ACCOUNTS_FOR_INSETS
are set, the minimum size will effectively only apply to the child area. Thus, KLay Layered can be told to ensure that the child area of a node has at least a given size, whatever space the port labels and node labels require.
...
- More than one port label.More than one
- Different placements for each node label. More than one label can usually be combined into a single
KLabel
object if the labels are to be placed next to each other anywayAs of now, node labels are placed by arranging them in a vertical stack at the desired node label position.
General Approach
The general approach to solving label placement, port placement, and node sizing follows the following general pattern:
...
Option | Target | Description |
---|---|---|
LayoutOptions.NODE_LABEL_PLACEMENT | Node | Determines where node labels are placed. A valid set of values contains exactly one constant from each of the following sets of constants:
|
LayoutOptions.PORT_LABEL_PLACEMENT | Node | Determines where port labels are placed: inside or outside their node. |
LayoutOptions.LABEL_SPACING | Graph | Determines the amount of space left between labels and the objects they label. |
LayoutOptions.SIZE_CONSTRAINT | Node | The amount of freedom in determining the size of a node. |
LayoutOptions.SIZE_OPTIONS | Node | Options for node size calculation. |
LayoutOptions.MIN_WIDTH | Node | The minimal width of a node. If set, overrides the default minimal width. |
LayoutOptions.MIN_HEIGHT | Node | The minimal height of a node. If set, overrides the default minimal height. |
LayoutOptions.PORT_CONSTRAINTS | Node | Freedom in placing ports. |
Properties.PORT_SPACING | Node | How much space should be left between ports. |