NAME

yEd::Label - Textlabels for Nodes and Edges

DESCRIPTION

This is the base class for Labels. It may not be instanciated, instead use one of the specialized types:

Have a look at the addNewLabel() function of yEd::Node and yEd::Edge, it is the preferred way to create Labels.

For saving Label templates see yEd::Document's addNewLabelTemplate(), getTemplateLabel() and the related functions.

SUPPORTED FEATURES

Labels are supported for both, Nodes and Edges. However there are some features which are currently not supported:

  • Smart Label positioning: Because it offers few advantages over the other positioning modells and is much more complex to implement.

  • configuration of the Preferred Placement Descriptors: As they seem to only have an effect on Smart Labels (and do only exist for Labels on Edges).

  • SVG content (icons) for Labels

All other features of Labels (yEd Version 3.13) are supported.

For the available positioning modells see the documentation of the specialized Labels.

Other than in yEd itself you may add more than one Label to a single Node or Edge, regardless of its type. In fact some special Nodes in yEd have multiple Labels per default (e.g. tables), so yEd will handle this correctly.

PROPERTIES

text

Type: anything

Default: ... must be supplied

The text to be displayed by the Label.

If it is a blessed ref it will try to find a toString() or to_string() method with the fallback of standard perl stringification.

If it is an array ref each entry will be treated as a line of text.

If it is a hash ref its content will be formated like so:

key1:        value
key2:        val2
another key: val3

Use a monospace font and left alignment (e.g. 'alignment' => 'left', 'fontFamily' => 'Monospaced') for hashes. Output will be sorted by keys, you can make your keys like _01_keyfirst , _02_keysecond, ... to order them (the ^_\d+_ portion will be removed for printing).

Also see the getTextString() function which returns this property as the printed text.

visible

Type: bool

Default: true

Whether the Label is visible or not (rather useless).

x

Type: float

Default: 0

The x position of the Label (ignored in most positioning modells).

y

Type: float

Default: 0

The y position of the Label (ignored in most positioning modells).

height

Type: ufloat

Default: 20

The height of the Label (mostly ignored depending on autoSizePolicy).

width

Type: ufloat

Default: 30

The width of the Label (mostly ignored depending on autoSizePolicy).

backgroundColor

Type: '#0000fa' (rgb) or '#000000cc' (rgb + transparency) java.awt.Color hex form or 'none'

Default: 'none'

The background color of the Label.

lineColor

Type: '#0000fa' (rgb) or '#000000cc' (rgb + transparency) java.awt.Color hex form or 'none'

Default: 'none'

The border color of the Label.

bottomInset

Type: uint

Default: 0

The bottom inset between Label border and text.

topInset

Type: uint

Default: 0

The top inset between Label border and text.

leftInset

Type: uint

Default: 0

The left inset between Label border and text.

rightInset

Type: uint

Default: 0

The right inset between Label border and text.

rotationAngle

Type: float

Default: 0

Rotation of the whole Label.

alignment

Type: descrete values ( center | right | left )

Default: 'center'

The text alignment.

fontFamily

Type: Fontstring

Default: 'Dialog'

The font for the Label text.

As fonts differ on systems and platforms, this is not a descrete values property, be sure to choose a proper value (e.g. look into a yEd created graphml). The default font 'Dialog' seems to be always present.

fontSize

Type: uint

Default: 12

The font size.

fontStyle

Type: descrete values ( plain | bold | italic | bolditalic )

Default: 'plain'

The font style.

textColor

Type: '#0000fa' (rgb) or '#000000cc' (rgb + transparency) java.awt.Color hex form or 'none'

Default: '#000000'

The text color.

underlinedText

Type: bool

Default: false

Whether the text is underlined or not.

SUBROUTINES/METHODS

new

Creates a new instance of a Label typ type.

A value for the text property must be provided as first parameter.

Further parameters to set properties are optional (property1 => value, property2 => value2, ...).

EXAMPLE

my $label = yEd::Label::NodeLabel->new('hello world', 'underlinedText' => 1, 'textColor' => '#ff0000');

copy

Creates a copy of this Label and returns it.

You may optionally specify properties in the form property1 => value, property2 => value2, ... to change these properties for the returned copy.

EXAMPLE

my $newlabel = $label->copy();
my $newlabel2 = $label->copy('text' => 'my new text');

getTextString

While the text property will return the set value (which may be a ref), this will return the text form of the property as it will be shown in yEd.

Have a look at the text property description for details.

EXAMPLE

print $label->getTextString();

allInsets

This is an alternative setter for the inset... properties.

It takes one or two parameters, where the first one will set bottom and top (or all insets if there is no second parameter) and the second will set left and right.

EXAMPLE

$label->allInsets(10);
$label->allInsets(4, 8);

setProperties getProperties hasProperties

As described at yEd::PropertyBasedObject

SEE ALSO

yEd::Document for further informations about the whole package

yEd::PropertyBasedObject for further basic information about properties and their additional functions

yEd::Label::EdgeLabel for information about specialized Label elements for Edges

yEd::Label::NodeLabel for information about specialized Label elements for Nodes