Text in Shape Nodes
A ShapeNode can display text within its outlines. Text layout and alignment depend on the value specified through setTextFormat. The text is painted with the color set in setTextBrush. Even more useful formatting attributes can be enabled by setEnableStyledText.
Layout Text in Arbitrary Shapes
ShapeNode instances can have various shapes, as specified through
setShape and
setShapeOrientation methods.
JDiagram uses a formatting algorithm that fits exactly each line of the node's text within the width of a line inside a polygonal shape. If a shape node has curved outlines, the formatting algorithm approximates them the polylines.
Supplementary Node Labels
Apart from main text content, the
NodeLabel class lets you display additional labels and pin them to node's edges or corners. Call the
addLabel method to create such supplementary labels, and use
NodeLabel (and base
ItemLabel) properties and methods to customize their appearance and position.
Text in Tables
A
TableNode can display text in its caption bar and inside each cell. The caption text is specified by
setCaption and its color and alignment are specified through
setCaptionBrush and
setCaptionFormat. The text in individual cells is specified by a call to the
setText method and its color and format are set through
setTextColor and
setTextFormat respectively. Calling the
setEnableStyledText method can enable the use of formatting tags in the text.
Styled Text
The
ShapeNode.setEnableStyledText method for shape nodes and
TableNode.setEnableStyledText method of tables respectively enable or disable styled text rendering. Styled text can have various attributes applied to the characters it contains. The attributes are specified using HTML-like formatting tags embedded in the raw text.
The following table lists the currently supported style tags:
Tag | Description |
---|
<i> text </i> | Italic text |
<b> text </b> | Bold text |
<u> text </u> | Underlined text |
<sub> text </sub> | Subscript |
<sup> text </sup> | Superscript |
<color=#RRGGBB> text </color> | Changes the color of the text. The red, green and blue color channels are specified as hexadecimal numbers. |
Link Labels
The text of a DiagramLink is specified by setText. The setTextColor and setTextStyle methods can be used to specify the color and position of the text.
Apart from main text content, the LinkLabel class lets you display additional labels and pin them to link's points or segments. Call the addLabel method to create such supplementary labels, and use LinkLabel (and base ItemLabel) properties and methods to customize their appearance and position. Labels can automatically avoid overlapping nodes or other labels when their AutoArrange property is set.
Fonts
All items provide a setFont method that allows getting or setting the font used for rendering their text.