You can make use of the following features
for a label on a node:
Label string
The
label
property controls the string displayed by the node’s label.
You can set the label to the empty string (
""
) if you do not want to display any label on the node.
Multiline label
A label can have several lines. To define a multiline label,
simply put new line (‘
\n
’) characters in the value of the
label
property to separate the lines.
The alignment of multiline labels is controlled by the property
labelAlignment
, which can take the values
Left
(left-aligned),
Center
(centered), or
Right
(right-aligned).
The spacing between the lines of multiline labels is controlled
by the property
lineSpacing
.
Label position
The
labelPosition
property controls the placement of the label relative to the
shape. This property can take the values defined by the interface
IlvDirection. For example, setting
labelPosition
to
Top
places the label above the shape.
Center
places the label inside the shape. The default position is
Bottom
..
The spacing between the shape and the label is controlled by the
property
labelSpacing
.
Autowrap
If the
labelMode
property is set to
WORD_WRAP
, the label is automatically cut into several lines to fit into
the width of the shape.
You can choose the characters where a break due to word wrapping
is allowed by setting
wordWrapChars
. In autowrap mode, the new line characters contained in the
label are ignored.
The property
labelMargin
controls the margin to leave between the border of the shape and
the label when word wrapping is active:
- If the label is inside the shape, the label is kept narrower than the shape by two times the margin.
- If the label is outside the shape, the label is allowed to be wider than the shape by two times the margin.
Truncation
If the
labelMode
property is set to
TRUNCATE
, the label is automatically truncated to fit into the width of
the shape. This is different from autowrap mode: the label is not
cut into several lines, but simply truncated, and the truncated
label always has a single line.
The property
labelMargin
controls the margin to leave between the border of the shape and
the (truncated) label, as in
WORD_WRAP
mode.
The end of the label is replaced by the string "
...
" (You can change this suffix using the method
setTruncatedLabelSuffix
.
Zoom
If the
labelZoomable
property is set to
"true"
, the label grows when the view is zoomed in and shrinks when the
view is zoomed out. If the
labelZoomable
property is set to
"false"
, the label size stays constant.
You can choose to make the label invisible when the view is
zoomed in or out past a certain zoom level. The property
minLabelZoom
specifies the minimum zoom level past which the label will no
longer be visible when zooming out. The property
maxLabelZoom
specifies the maximum zoom level past which the label will no
longer be visible when zooming in.
The
labelScaleFactor
lets you apply a scale factor to the label.
Label font, color, and antialiasing
The properties
labelFont
and
labelColor
control the font and color of the label.
The property
labelAntialiasing
determines whether the label should be drawn using antialiasing
or not.