yEd::Edge - Base class for Edges
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.
All Edge types are supported, these are:
yEd::Edge::ArcEdge
yEd::Edge::BezierEdge
yEd::Edge::GenericEdge
yEd::Edge::PolyLineEdge
yEd::Edge::QuadCurveEdge
yEd::Edge::SplineEdge
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)
relativeWaypoints
You may add multiple Labels to a single Edge (yEd will handle it properly)
This property is read only and returns the Edge's ID.
See yEd::Document for details about object identifiers.
Type: yEd::Node
Default: ... must be provided at constructor
The source Node reference.
The target Node reference.
Type: float
Default: 0
The x value for Edge connection to source Node (x=0 y=0 is center).
The y value for Edge connection to source Node (x=0 y=0 is center).
The x value for Edge connection to target Node (x=0 y=0 is center).
The y value for Edge connection to target Node (x=0 y=0 is center).
Type: '#0000fa' (rgb) or '#000000cc' (rgb + transparency) java.awt.Color hex form or 'none'
Default: '#000000'
The line color.
Type: descrete values ( line | dotted | dashed | dashed_dotted )
Default: 'line'
The line type.
Type: ufloat
Default: 1
The line width.
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.
The arrow on target side of the Edge.
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.
source
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.
addNewEdge()
Second and third parameter must be references to yEd::Node type instances, which are the Edge's source and target Nodes (in this order).
target
Further parameters to set properties are optional (property1 => value, property2 => value2, ...).
property1 => value, property2 => value2, ...
# 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);
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.
clearWaypoints()
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.
my $edge2 = $edge->copy('id2', $newSrcNode, $newTrgNode, 'relativeWaypoints' => 0);
Returns an array of all Nodes connected to this Edge (This will always be 1 or 2 elements).
foreach my $node ($edge->getNodes()) { ...
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.
sx
sy
tx
ty
$edge->addWaypoint(0,50);
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.
$edge->waypoints($edge2->waypoints()); $edge->waypoints([0,50],[150,0]);
Removes all waypoints from this edge.
$edge->clearWaypoints();
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.
text
Returns a ref to the Label object.
my $label = $edge->addNewLabel('hello world', 'alignment' => 'left');
Takes a yEd::Label::EdgeLabel object and adds it.
$edge->addLabel($label);
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.
# 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()); }
Removes all Labels from this Edge.
$edge->clearLabels();
Takes arguments of the form property1 => value, property2 => value2, ....
Returns a list of all Labels that matches the given filter.
my @bigfatlabels = $edge->getLabelsByProperties('fontSize' => 20, 'fontStyle' => 'bold');
As described at yEd::PropertyBasedObject
yEd::Document for further informations about the whole package
yEd::PropertyBasedObject for further basic information about properties and their additional functions
The specialized Edges:
To install yEd::Document, copy and paste the appropriate command in to your terminal.
cpanm
cpanm yEd::Document
CPAN shell
perl -MCPAN -e shell install yEd::Document
For more information on module installation, please visit the detailed CPAN module installation guide.