The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

yEd::Edge - Base class for Edges

DESCRIPTION

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

SUPPORTED FEATURES

All Edge types are supported, these are:

The following features are currently not supported:

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

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

Support beyond yEd:

  • You may specify waypoints to be relative to previous waypoints / source Node (see relativeWaypoints property)

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

PROPERTIES

id

This property is read only and returns the Edge's ID.

See yEd::Document for details about object identifiers.

source

Type: yEd::Node

Default: ... must be provided at constructor

The source Node reference.

target

Type: yEd::Node

Default: ... must be provided at constructor

The target Node reference.

sx

Type: float

Default: 0

The x value for Edge connection to source Node (x=0 y=0 is center).

sy

Type: float

Default: 0

The y value for Edge connection to source Node (x=0 y=0 is center).

tx

Type: float

Default: 0

The x value for Edge connection to target Node (x=0 y=0 is center).

ty

Type: float

Default: 0

The y value for Edge connection to target Node (x=0 y=0 is center).

lineColor

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

Default: '#000000'

The line color.

lineType

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

Default: 'line'

The line type.

lineWidth

Type: ufloat

Default: 1

The line width.

sArrow

Type: descrete values ( standard | delta | white_delta | diamond | white_diamond | short | plain | concave | convex | circle | transparent_circle | dash | skewed_dash | t_shape | crows_foot_one_mandatory | crows_foot_many_mandatory | crows_foot_one_optional | crows_foot_many_optional | crows_foot_one | crows_foot_many | crows_foot_optional | none )

Default: 'none'

The arrow on source side of the Edge.

tArrow

Type: descrete values ( standard | delta | white_delta | diamond | white_diamond | short | plain | concave | convex | circle | transparent_circle | dash | skewed_dash | t_shape | crows_foot_one_mandatory | crows_foot_many_mandatory | crows_foot_one_optional | crows_foot_many_optional | crows_foot_one | crows_foot_many | crows_foot_optional | none )

Default: 'none'

The arrow on target side of the Edge.

relativeWaypoints

Type: bool

Default: false

If set to true the x and y coords of added waypoints are not considered to be absolute coords, but they will be relative to the previous waypoint. First waypoint will be relative to the source Node's coords. Note that the coords of a Node indicate its upper left corner, not the center, while the default anchor point of Edges is the center of a Node and is described as being (0,0) in the Node's local coordinate system. However the first (relative) waypoint WILL be calculated from the source's center modified by the anchor point by this package, so you don't have to care for such inconsistency here.

SUBROUTINES/METHODS

new

Creates a new instance of the corresponding Edge type.

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 addNewEdge() function of yEd::Document instead, it will take care of the IDs.

Second and third parameter must be references to yEd::Node type instances, which are the Edge's source and target Nodes (in this order).

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

EXAMPLE

    # connects to the lower left corner of $srcNode (and center of $trgNode)
    my $edge = yEd::Edge::GenericEdge->new('myid1', $srcNode, $trgNode, 'sx' => $srcNode->width() * -0.5 , 'sy' => $srcNode->height() * 0.5);

copy

Creates a copy of this Edge and returns it.

Also copies all attached Labels and waypoints, so unless relativeWaypoints was set you will most likely want to call clearWaypoints() on the copy.

An ID must be given as first parameter as described in the Edge class constructor, it will be applied to the copy.

Second and third parameter must be references to yEd::Node type instances, which are the copy's source and target Nodes (in this order).

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

EXAMPLE

    my $edge2 = $edge->copy('id2', $newSrcNode, $newTrgNode,  'relativeWaypoints' => 0);

getNodes

Returns an array of all Nodes connected to this Edge (This will always be 1 or 2 elements).

EXAMPLE

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

addWaypoint

Takes 2 parameters, a x and y coordinate for the waypoint. The waypoint is added at the end of the list. Waypoint order is interpreted as: first to last = source to target.

Note that source and target are not provided as waypoints, neither do the anchor point properties sx,sy,tx,ty describe waypoints. Waypoints describe anchor mid-points for an Edge and are absolute by default. However you can have them interpreted as being relative by using the relativeWaypoints property.

EXAMPLE

    $edge->addWaypoint(0,50);

waypoints

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

If an array of coordinates is provided (where each coordinate is an array of 2 elements (x,y)), this Edge's waypoints are replaced by the given ones.

EXAMPLE

    $edge->waypoints($edge2->waypoints());
    $edge->waypoints([0,50],[150,0]);

clearWaypoints

Removes all waypoints from this edge.

EXAMPLE

    $edge->clearWaypoints();

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 = $edge->addNewLabel('hello world', 'alignment' => 'left');

addLabel

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

EXAMPLE

    $edge->addLabel($label);

labels

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

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

EXAMPLE

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

clearLabels

Removes all Labels from this Edge.

EXAMPLE

    $edge->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 = $edge->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 Edges:

yEd::Edge::ArcEdge

yEd::Edge::BezierEdge

yEd::Edge::GenericEdge

yEd::Edge::PolyLineEdge

yEd::Edge::QuadCurveEdge

yEd::Edge::SplineEdge