NAME

yEd::Node - Base class for Nodes

DESCRIPTION

This is the base class for Nodes. It may not be instanciated, instead use one of the specialized types as described in the "SUPPORTED FEATURES" section.

Have a look at the addNewNode() function of yEd::Document, it is the preferred way to create Nodes.

For saving Node templates see yEd::Document's addNewNodeTemplate(), addTemplateNode() and the related functions.

SUPPORTED FEATURES

The following Node types are currently supported:

The following types and features are currently not supported (and it's not sure they'll ever be):

  • Group/Folder type Nodes (e.g. group 'Group Nodes')

  • Table type Nodes (e.g. group "Swimlane Nodes and Tables")

  • SVG type Nodes (e.g. group "People")

  • Adding meta data to Nodes or edit the present ones (e.g. URL, description)

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

Support beyond yEd:

  • You may specify Nodes to be relative to other Nodes (see relative property)

  • You may add multiple Labels to a single Node (yEd will handle it properly)

PROPERTIES

layer

Type: uint

Default: 0

The drawing pane layer this Node is on.

See yEd::Document for details about using layers.

relative

Type: yEd::Node or 0 to erase relation

Default: 0

If a Node reference is set here, this Nodes x and y properties will be interpreted as being relative to the given Node.

See yEd::Document for details about relative objects.

id

This property is read only and returns the Nodes ID.

See yEd::Document for details about object identifiers.

x

Type: float

Default: 0

The x position (upper left corner).

y

Type: float

Default: 0

The y position (upper left corner).

height

Type: ufloat

Default: 30

The height of the Node.

width

Type: ufloat

Default: 30

The width of the Node.

fillColor

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

Default: '#ffcc00'

The background color.

fillColor2

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

Default: 'none'

The second background color (will be ignored if fillColor is 'none').

borderColor

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

Default: '#000000'

The color for the border line.

borderType

Type: descrete values ( line | dotted | dashed | dashed_dotted )

Default: 'line'

Linetype of the border.

borderWidth

Type: ufloat

Default: 1

The width of the border.

SUBROUTINES/METHODS

new

Creates a new instance of a Node.

An ID must be provided as first parameter. This value may be any string or number but must be unique among the whole yEd::Document. If you don't want to bother with IDs use the addNewNode() function of yEd::Document instead, it will take care of the IDs.

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

EXAMPLE

my $node = yEd::Node::GenericNode->new('myid1', 'x' => 500, 'y' => -33.7);

copy

Creates a copy of this Node and returns it.

Also copies all attached Labels.

An ID must be given as first parameter as described in the Node classes constructors, it will be applied to the copy.

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

If this Node is relative to another one you may want to set a new relation partner for the copy, change its relative position or make it absolute.

EXAMPLE

my $node2 = $node->copy('id2', 'x' => 89.5, 'y' => -33.7);

absX

Returns the absolute x value for this Node which equals $node->x() unless $node->relative($node2) was set. In this case $node->absX() is $node2->absX() + $node->x().

EXAMPLE

# before you do $node->relative(0) you may want to make coords absolute:
$node->x($node->absX());

absY

Returns the absolute y value for this Node which equals $node->y() unless $node->relative($node2) was set. In this case $node->absY() is $node2->absY() + $node->y().

EXAMPLE

# before you do $node->relative(0) you may want to make coords absolute:
$node->y($node->absY());

absCenter

Returns the absolute (x,y) values for this Node's center (as an array of 2 elements). Note that normal coords indicate the upper left corner of a Node.

EXAMPLE

my ($xc, $yc) = $node->absCenter();

getEdges

Returns an array of all Edges connected to this Node.

EXAMPLE

foreach my $edge ($node->getEdges()) { ...

addNewLabel

Takes a value for the text property of Labels followed by optional Label properties (property1 => value, property2 => value2, ...) and creates and adds a new Label from it.

Returns a ref to the Label object.

EXAMPLE

my $label = $node->addNewLabel('hello world', 'alignment' => 'left');

addLabel

Takes a yEd::Label::NodeLabel object and adds it.

EXAMPLE

$node->addLabel($label);

labels

Acts as a getter with no parameters provided and returns an array of all Labels attached to this Node.

If an array of NodeLabel objects is provided, this Node's Labels are replaced by the given Labels.

EXAMPLE

# this will make a copy of the array but not the Labels itself 
$node->labels($node2->labels());
# if you want a copy rather than shared refs use Label's copy() function:
$node->clearLabels(); # if there may be any
foreach my $l ($node2->labels()) {
    $node->addLabel($l->copy());
}

clearLabels

Removes all Labels from this Node.

EXAMPLE

$node->clearLabels();

getLabelsByProperties

Takes arguments of the form property1 => value, property2 => value2, ....

Returns a list of all Labels that matches the given filter.

EXAMPLE

my @bigfatlabels = $node->getLabelsByProperties('fontSize' => 20, 'fontStyle' => 'bold');

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

The specialized Nodes:

yEd::Node::ShapeNode

yEd::Node::GenericNode