| 1 | package yEd::Edge; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use yEd::PropertyBasedObject; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use yEd::Label::EdgeLabel; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | yEd::Edge - Base class for Edges | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | This is the base class for Edges. | ||||||||||||||||||||||||||||
| 16 | It may not be instanciated, instead use one of the specialized types as described in the L</SUPPORTED FEATURES> section. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 SUPPORTED FEATURES | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | All Edge types are supported, these are: | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =over 4 | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =item * | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | L<yEd::Edge::ArcEdge> | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =item * | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | L<yEd::Edge::BezierEdge> | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =item * | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | L<yEd::Edge::GenericEdge> | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =item * | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | L<yEd::Edge::PolyLineEdge> | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =item * | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | L<yEd::Edge::QuadCurveEdge> | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =item * | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | L<yEd::Edge::SplineEdge> | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =back | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | The following features are currently not supported: | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =over 4 | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =item * | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Adding meta data to Edges or edit the present ones (e.g. URL, description) | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =back | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | All other basic features of Edges (yEd Version 3.13) are supported. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | Support beyond yEd: | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =over 4 | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =item * | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | You may specify waypoints to be relative to previous waypoints / source Node (see C<relativeWaypoints> property) | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =item * | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | You may add multiple Labels to a single Edge (yEd will handle it properly) | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =back | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head1 PROPERTIES | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head2 id | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | This property is read only and returns the Edge's ID. | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | See L<yEd::Document> for details about object identifiers. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head2 source | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Type: L<yEd::Node> | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Default: ... must be provided at constructor | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | The source Node reference. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head2 target | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Type: L<yEd::Node> | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Default: ... must be provided at constructor | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | The target Node reference. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 sx | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Type: float | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Default: 0 | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | The x value for Edge connection to source Node (x=0 y=0 is center). | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head2 sy | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Type: float | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Default: 0 | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | The y value for Edge connection to source Node (x=0 y=0 is center). | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head2 tx | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | Type: float | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | Default: 0 | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | The x value for Edge connection to target Node (x=0 y=0 is center). | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head2 ty | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | Type: float | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | Default: 0 | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | The y value for Edge connection to target Node (x=0 y=0 is center). | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head2 lineColor | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | Type: '#0000fa' (rgb) or '#000000cc' (rgb + transparency) java.awt.Color hex form or 'none' | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Default: '#000000' | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | The line color. | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =head2 lineType | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | Type: descrete values ( line | dotted | dashed | dashed_dotted ) | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Default: 'line' | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | The line type. | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =head2 lineWidth | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | Type: ufloat | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | Default: 1 | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | The line width. | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head2 sArrow | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 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 ) | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | Default: 'none' | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | The arrow on source side of the Edge. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =head2 tArrow | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 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 ) | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Default: 'none' | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | The arrow on target side of the Edge. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =head2 relativeWaypoints | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Type: bool | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | Default: false | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 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. | ||||||||||||||||||||||||||||
| 179 | First waypoint will be relative to the C<source> Node's coords. | ||||||||||||||||||||||||||||
| 180 | 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. | ||||||||||||||||||||||||||||
| 181 | 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. | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =head2 new | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | Creates a new instance of the corresponding Edge type. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | An ID must be provided as first parameter. | ||||||||||||||||||||||||||||
| 190 | This value may be any string or number but must be unique among the whole L<yEd::Document>. | ||||||||||||||||||||||||||||
| 191 | If you don't want to bother with IDs use the C<addNewEdge()> function of L<yEd::Document> instead, it will take care of the IDs. | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Second and third parameter must be references to L<yEd::Node> type instances, which are the Edge's C<source> and C<target> Nodes (in this order). | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | Further parameters to set properties are optional (C<property1 =E<gt> value, property2 =E<gt> value2, ...>). | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | # connects to the lower left corner of $srcNode (and center of $trgNode) | ||||||||||||||||||||||||||||
| 200 | my $edge = yEd::Edge::GenericEdge->new('myid1', $srcNode, $trgNode, 'sx' => $srcNode->width() * -0.5 , 'sy' => $srcNode->height() * 0.5); | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 205 | 0 | confess 'you may not instantiate a yEd::Edge base class object'; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head2 copy | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | Creates a copy of this Edge and returns it. | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | Also copies all attached Labels and waypoints, so unless C<relativeWaypoints> was set you will most likely want to call C<clearWaypoints()> on the copy. | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | An ID must be given as first parameter as described in the Edge class constructor, it will be applied to the copy. | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | Second and third parameter must be references to L<yEd::Node> type instances, which are the copy's C<source> and C<target> Nodes (in this order). | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | You may optionally specify properties in the form C<property1 =E<gt> value, property2 =E<gt> value2, ...> to change these properties for the returned copy. | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | my $edge2 = $edge->copy('id2', $newSrcNode, $newTrgNode, 'relativeWaypoints' => 0); | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =cut | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub copy { | ||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 227 | 0 | my ($self, $id, $s, $t, @p) = @_; | |||||||||||||||||||||||||||
| 228 | 0 | my $ref = ref $self; | |||||||||||||||||||||||||||
| 229 | 0 | my $o = $ref->new($id, $s, $t); | |||||||||||||||||||||||||||
| 230 | 0 | $o->setProperties($self->getProperties()); | |||||||||||||||||||||||||||
| 231 | 0 | $o->setProperties(@p, 'source' => $s, 'target' => $t); | |||||||||||||||||||||||||||
| 232 | 0 | foreach my $l ($self->labels()) { | |||||||||||||||||||||||||||
| 233 | 0 | $o->addLabel($l->copy()); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | foreach my $wp ($self->waypoints()) { | |||||||||||||||||||||||||||
| 236 | 0 | $o->addWaypoint(@{$wp}); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | 0 | return $o; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 6 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 242 | 6 | my ($self, $id, $source, $target, @properties) = @_; | |||||||||||||||||||||||||||
| 243 | 6 | ▶ | confess 'edge id missing for edge creation' unless (defined $id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 6 | ▶ | confess 'provide a source and target node for edge creation' unless (defined $source and defined $target); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $source and defined $target
MC/DC0%0/2
defined $source and defined $target
defined $source
defined $target
Truth table33%1/3
A and B
A= defined $sourceB= defined $target
| |||||||||||||||||||||||||||||
| 245 | 6 | $self->{'properties'}{'id'} = $id; | |||||||||||||||||||||||||||
| 246 | 6 | $self->{'datakeys'} = [ 'd8', 'd9' ]; | |||||||||||||||||||||||||||
| 247 | 6 | $self->{'rootkey'} = 'd10'; | |||||||||||||||||||||||||||
| 248 | 6 | $self->source($source); | |||||||||||||||||||||||||||
| 249 | 6 | $self->target($target); | |||||||||||||||||||||||||||
| 250 | # defaults | ||||||||||||||||||||||||||||
| 251 | 6 | $self->sx(0); | |||||||||||||||||||||||||||
| 252 | 6 | $self->sy(0); | |||||||||||||||||||||||||||
| 253 | 6 | $self->tx(0); | |||||||||||||||||||||||||||
| 254 | 6 | $self->ty(0); | |||||||||||||||||||||||||||
| 255 | 6 | $self->lineColor('#000000'); | |||||||||||||||||||||||||||
| 256 | 6 | $self->lineType('line'); | |||||||||||||||||||||||||||
| 257 | 6 | $self->lineWidth(1); | |||||||||||||||||||||||||||
| 258 | 6 | $self->sArrow('none'); | |||||||||||||||||||||||||||
| 259 | 6 | $self->tArrow('none'); | |||||||||||||||||||||||||||
| 260 | 6 | $self->relativeWaypoints(0); | |||||||||||||||||||||||||||
| 261 | 6 | $self->clearWaypoints(); | |||||||||||||||||||||||||||
| 262 | 6 | $self->clearLabels(); | |||||||||||||||||||||||||||
| 263 | # user values | ||||||||||||||||||||||||||||
| 264 | 6 | $self->setProperties(@properties); | |||||||||||||||||||||||||||
| 265 | 6 | return $self; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | # edge | ||||||||||||||||||||||||||||
| 269 | 18 | ▶ | sub id { | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 270 | 18 | return _PROPERTY('ro', @_); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | 30 | ▶ | sub source { | ||||||||||||||||||||||||||
|
Subroutine
source: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 273 | 30 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 274 | 30 | my $key = 'source'; | |||||||||||||||||||||||||||
| 275 | 30 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 6 | ▶ | confess "value must be a yEd::Node (or one of its subtypes) (given value: $value)" unless ($value->isa('yEd::Node')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 6 | ▶ | $self->{'properties'}{$key}->_deregisterEdge($self) if (defined $self->{'properties'}{$key}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 6 | $self->{'properties'}{$key} = $value; | |||||||||||||||||||||||||||
| 279 | 6 | $self->{'properties'}{$key}->_registerEdge($self); | |||||||||||||||||||||||||||
| 280 | 6 | return; | |||||||||||||||||||||||||||
| 281 | } else { | ||||||||||||||||||||||||||||
| 282 | 24 | return $self->{'properties'}{$key}; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | 18 | ▶ | sub target { | ||||||||||||||||||||||||||
|
Subroutine
target: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | 18 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 287 | 18 | my $key = 'target'; | |||||||||||||||||||||||||||
| 288 | 18 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 6 | ▶ | confess "value must be a yEd::Node (or one of its subtypes) (given value: $value)" unless ($value->isa('yEd::Node')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 6 | ▶ | $self->{'properties'}{$key}->_deregisterEdge($self) if (defined $self->{'properties'}{$key}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 6 | $self->{'properties'}{$key} = $value; | |||||||||||||||||||||||||||
| 292 | 6 | $self->{'properties'}{$key}->_registerEdge($self); | |||||||||||||||||||||||||||
| 293 | 6 | return; | |||||||||||||||||||||||||||
| 294 | } else { | ||||||||||||||||||||||||||||
| 295 | 12 | return $self->{'properties'}{$key}; | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub _deregisterAll { | ||||||||||||||||||||||||||
|
Subroutine
_deregisterAll: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 299 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 300 | 0 | $self->source()->_deregisterEdge($self); | |||||||||||||||||||||||||||
| 301 | 0 | $self->target()->_deregisterEdge($self); | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | =head2 getNodes | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | Returns an array of all Nodes connected to this Edge (This will always be 1 or 2 elements). | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | foreach my $node ($edge->getNodes()) { ... | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 6 | ▶ | sub getNodes { | ||||||||||||||||||||||||||
|
Subroutine
getNodes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 316 | 6 | my @nodes; | |||||||||||||||||||||||||||
| 317 | 6 | push @nodes, $self->source(); | |||||||||||||||||||||||||||
| 318 | 6 | ▶ | push @nodes, $self->target() unless $self->source() == $self->target(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 6 | return @nodes; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | # Path | ||||||||||||||||||||||||||||
| 323 | 18 | ▶ | sub sx { | ||||||||||||||||||||||||||
|
Subroutine
sx: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 324 | 18 | return _PROPERTY($match{'float'}, @_); | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | 18 | ▶ | sub sy { | ||||||||||||||||||||||||||
|
Subroutine
sy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 327 | 18 | return _PROPERTY($match{'float'}, @_); | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | 12 | ▶ | sub tx { | ||||||||||||||||||||||||||
|
Subroutine
tx: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 330 | 12 | return _PROPERTY($match{'float'}, @_); | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | 12 | ▶ | sub ty { | ||||||||||||||||||||||||||
|
Subroutine
ty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 333 | 12 | return _PROPERTY($match{'float'}, @_); | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 6 | ▶ | sub relativeWaypoints { | ||||||||||||||||||||||||||
|
Subroutine
relativeWaypoints: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 337 | 6 | return _PROPERTY('bool', @_); | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =head2 addWaypoint | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | Takes 2 parameters, a x and y coordinate for the waypoint. | ||||||||||||||||||||||||||||
| 343 | The waypoint is added at the end of the list. | ||||||||||||||||||||||||||||
| 344 | Waypoint order is interpreted as: first to last = C<source> to C<target>. | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | Note that C<source> and C<target> are not provided as waypoints, neither do the anchor point properties C<sx>,C<sy>,C<tx>,C<ty> describe waypoints. | ||||||||||||||||||||||||||||
| 347 | Waypoints describe anchor mid-points for an Edge and are absolute by default. | ||||||||||||||||||||||||||||
| 348 | However you can have them interpreted as being relative by using the C<relativeWaypoints> property. | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | $edge->addWaypoint(0,50); | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | =cut | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub addWaypoint { | ||||||||||||||||||||||||||
|
Subroutine
addWaypoint: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | 0 | my ($self, @coords) = @_; | |||||||||||||||||||||||||||
| 358 | 0 | ▶ | confess "waypoints have to be added as one pair of x,y coords : addWaypoint(x,y)" unless (@coords == 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | ▶ | confess "waypoint coords must be floatingpoint values" unless ($coords[0] =~ m/$match{'float'}/ and $coords[1] =~ m/$match{'float'}/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$coords[0] =~ /$yEd::Edge::match{"float"}/ and $coords[1] =~ /$yEd::Edge::match{"float"}/
MC/DC0%0/2
$coords[0] =~ /$yEd::Edge::match{"float"}/ and $coords[1] =~ /$yEd::Edge::match{"float"}/
$coords[0] =~ /$yEd::Edge::match{"float"}/
$coords[1] =~ /$yEd::Edge::match{"float"}/
Truth table0%0/3
A and B
A= $coords[0] =~ /$yEd::Edge::match{"float"}/B= $coords[1] =~ /$yEd::Edge::match{"float"}/
| |||||||||||||||||||||||||||||
| 360 | 0 | push @{$self->{'waypoints'}}, \@coords; | |||||||||||||||||||||||||||
| 361 | 0 | return; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | =head2 waypoints | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | Acts as a getter with no parameters provided and returns an array of all waypoints attached to this Edge. | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 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. | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | $edge->waypoints($edge2->waypoints()); | ||||||||||||||||||||||||||||
| 373 | $edge->waypoints([0,50],[150,0]); | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =cut | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 5 | ▶ | sub waypoints { | ||||||||||||||||||||||||||
|
Subroutine
waypoints: called CC=7 SCAR=34.2
Pod
documented
| |||||||||||||||||||||||||||||
| 378 | 5 | my ($self, @wps) = @_; | |||||||||||||||||||||||||||
| 379 | 5 | ▶ | if (@wps) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 380 | 0 | foreach my $wp (@wps) { | |||||||||||||||||||||||||||
| 381 | 0 | ▶ | confess "waypoint array has to consist of 2-element arrayrefs, which represent x,y coords" unless (ref($wp) eq 'ARRAY' and @{$wp} == 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $wp eq "ARRAY" and @{$wp;} == 2
MC/DC0%0/2
ref $wp eq "ARRAY" and @{$wp;} == 2
ref $wp eq "ARRAY"
@{$wp;} == 2
Truth table0%0/3
A and B
A= ref $wp eq "ARRAY"B= @{$wp;} == 2
| |||||||||||||||||||||||||||||
| 382 | 0 | ▶ | confess "waypoint coords must be floatingpoint values (bad pair: (@{$wp}))" unless ($wp->[0] =~ m/$match{'float'}/ and $wp->[1] =~ m/$match{'float'}/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$wp->[0] =~ /$yEd::Edge::match{"float"}/ and $wp->[1] =~ /$yEd::Edge::match{"float"}/
MC/DC0%0/2
$wp->[0] =~ /$yEd::Edge::match{"float"}/ and $wp->[1] =~ /$yEd::Edge::match{"float"}/
$wp->[0] =~ /$yEd::Edge::match{"float"}/
$wp->[1] =~ /$yEd::Edge::match{"float"}/
Truth table0%0/3
A and B
A= $wp->[0] =~ /$yEd::Edge::match{"float"}/B= $wp->[1] =~ /$yEd::Edge::match{"float"}/
| |||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | 0 | $self->{'waypoints'} = \@wps; | |||||||||||||||||||||||||||
| 385 | 0 | return; | |||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||
| 387 | 5 | return @{$self->{'waypoints'}}; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =head2 clearWaypoints | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | Removes all waypoints from this edge. | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | $edge->clearWaypoints(); | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | =cut | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 6 | ▶ | sub clearWaypoints { | ||||||||||||||||||||||||||
|
Subroutine
clearWaypoints: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 402 | 6 | $_[0]->{'waypoints'} = []; | |||||||||||||||||||||||||||
| 403 | 6 | return; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | # Labels | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | =head2 addNewLabel | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | Takes a value for the C<text> property of Labels followed by optional Label properties (C<property1 =E<gt> value, property2 =E<gt> value2, ...>) and creates and adds a new Label from it. | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | Returns a ref to the Label object. | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | my $label = $edge->addNewLabel('hello world', 'alignment' => 'left'); | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | =cut | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 1 | ▶ | sub addNewLabel { | ||||||||||||||||||||||||||
|
Subroutine
addNewLabel: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 421 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 422 | 1 | my $label = yEd::Label::EdgeLabel->new(@_); | |||||||||||||||||||||||||||
| 423 | 1 | $self->addLabel($label); | |||||||||||||||||||||||||||
| 424 | 1 | return $label; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | =head2 addLabel | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | Takes a L<yEd::Label::EdgeLabel> object and adds it. | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | $edge->addLabel($label); | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =cut | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 1 | ▶ | sub addLabel { | ||||||||||||||||||||||||||
|
Subroutine
addLabel: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 438 | 1 | my ($self, $label) = @_; | |||||||||||||||||||||||||||
| 439 | 1 | ▶ | confess "only yEd::Label::EdgeLabel's can be added" unless ($label->isa('yEd::Label::EdgeLabel')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 440 | 1 | push @{$self->{'labels'}}, $label; | |||||||||||||||||||||||||||
| 441 | 1 | return; | |||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =head2 labels | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | Acts as a getter with no parameters provided and returns an array of all Labels attached to this Edge. | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | If an array of EdgeLabel objects is provided, this Edge's Labels are replaced by the given Labels. | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | # this will make a copy of the array but not the Labels itself | ||||||||||||||||||||||||||||
| 453 | $edge->labels($edge2->labels()); | ||||||||||||||||||||||||||||
| 454 | # if you want a copy rather than shared refs use Label's copy() function: | ||||||||||||||||||||||||||||
| 455 | $edge->clearLabels(); # if there may be any | ||||||||||||||||||||||||||||
| 456 | foreach my $l ($edge2->labels()) { | ||||||||||||||||||||||||||||
| 457 | $edge->addLabel($l->copy()); | ||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | =cut | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 6 | ▶ | sub labels { | ||||||||||||||||||||||||||
|
Subroutine
labels: called CC=4 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||
| 463 | 6 | my ($self, @labels) = @_; | |||||||||||||||||||||||||||
| 464 | 6 | ▶ | if (@labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 0 | foreach my $label (@labels) { | |||||||||||||||||||||||||||
| 466 | 0 | ▶ | confess "only yEd::Label::EdgeLabel's can be added" unless ($label->isa('yEd::Label::EdgeLabel')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||
| 468 | 0 | $self->{'labels'} = \@labels; | |||||||||||||||||||||||||||
| 469 | 0 | return; | |||||||||||||||||||||||||||
| 470 | } else { | ||||||||||||||||||||||||||||
| 471 | 6 | return @{$self->{'labels'}}; | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =head2 clearLabels | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | Removes all Labels from this Edge. | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | $edge->clearLabels(); | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =cut | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 6 | ▶ | sub clearLabels { | ||||||||||||||||||||||||||
|
Subroutine
clearLabels: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 486 | 6 | $_[0]->{'labels'} = []; | |||||||||||||||||||||||||||
| 487 | 6 | return; | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | =head2 getLabelsByProperties | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | Takes arguments of the form C<property1 =E<gt> value, property2 =E<gt> value2, ...>. | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | Returns a list of all Labels that matches the given filter. | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | =head3 EXAMPLE | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | my @bigfatlabels = $edge->getLabelsByProperties('fontSize' => 20, 'fontStyle' => 'bold'); | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | =cut | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub getLabelsByProperties { | ||||||||||||||||||||||||||
|
Subroutine
getLabelsByProperties: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 503 | 0 | my ($self, @properties) = @_; | |||||||||||||||||||||||||||
| 504 | 0 | my @labels; | |||||||||||||||||||||||||||
| 505 | 0 | foreach my $label ($self->labels()) { | |||||||||||||||||||||||||||
| 506 | 0 | ▶ | push @labels, $label if $label->hasProperties(@properties); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | 0 | return @labels; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | # LineStyle | ||||||||||||||||||||||||||||
| 512 | 18 | ▶ | sub lineColor { | ||||||||||||||||||||||||||
|
Subroutine
lineColor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 513 | 18 | return _PROPERTY($match{'color'}, @_); | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | 12 | ▶ | sub lineType { | ||||||||||||||||||||||||||
|
Subroutine
lineType: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 516 | 12 | return _PROPERTY($match{'linetype'}, @_); | |||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||
| 518 | 12 | ▶ | sub lineWidth { | ||||||||||||||||||||||||||
|
Subroutine
lineWidth: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 519 | 12 | return _PROPERTY($match{'ufloat'}, @_); | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | # Arrows | ||||||||||||||||||||||||||||
| 523 | 12 | ▶ | sub sArrow { | ||||||||||||||||||||||||||
|
Subroutine
sArrow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 524 | 12 | return _PROPERTY($match{'arrowtype'}, @_); | |||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||
| 526 | 12 | ▶ | sub tArrow { | ||||||||||||||||||||||||||
|
Subroutine
tArrow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 527 | 12 | return _PROPERTY($match{'arrowtype'}, @_); | |||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 6 | ▶ | sub _build { | ||||||||||||||||||||||||||
|
Subroutine
_build: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 531 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 532 | 6 | my $node = $self->_createEdgeNode(); | |||||||||||||||||||||||||||
| 533 | 6 | my $root = $self->_addRootNode($node); | |||||||||||||||||||||||||||
| 534 | 6 | my $type = $self->_addTypeNode($root); | |||||||||||||||||||||||||||
| 535 | 6 | $self->_addPathNode($type); | |||||||||||||||||||||||||||
| 536 | 6 | $self->_addLineStyleNode($type); | |||||||||||||||||||||||||||
| 537 | 6 | $self->_addArrowsNode($type); | |||||||||||||||||||||||||||
| 538 | 6 | $self->_addLabelsNode($type); | |||||||||||||||||||||||||||
| 539 | 6 | $self->_addAdditionalNodes($type); | |||||||||||||||||||||||||||
| 540 | 6 | return $node; | |||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||
| 542 | 6 | ▶ | sub _createEdgeNode { | ||||||||||||||||||||||||||
|
Subroutine
_createEdgeNode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 543 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 544 | 6 | my $node = XML::LibXML::Element->new('edge'); | |||||||||||||||||||||||||||
| 545 | 6 | $node->setAttribute('id', $self->id()); | |||||||||||||||||||||||||||
| 546 | 6 | $node->setAttribute('source', $self->source()->id()); | |||||||||||||||||||||||||||
| 547 | 6 | $node->setAttribute('target', $self->target()->id()); | |||||||||||||||||||||||||||
| 548 | 6 | foreach my $dk (@{$self->{'datakeys'}}) { | |||||||||||||||||||||||||||
| 549 | 12 | $node->addNewChild('', 'data')->setAttribute('key', $dk); | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | 6 | return $node; | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | 6 | ▶ | sub _addRootNode { | ||||||||||||||||||||||||||
|
Subroutine
_addRootNode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 554 | 6 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 555 | 6 | my $root = $node->addNewChild('', 'data'); | |||||||||||||||||||||||||||
| 556 | 6 | $root->setAttribute('key', $self->{'rootkey'}); | |||||||||||||||||||||||||||
| 557 | 6 | return $root; | |||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | 0 | ▶ | sub _addTypeNode { | ||||||||||||||||||||||||||
|
Subroutine
_addTypeNode: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 560 | # add type node here and return it (e.g. <y:ArcEdge>) | ||||||||||||||||||||||||||||
| 561 | 0 | confess 'you may not build a yEd::Edge base class object, override this method in a specialized subclass'; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | 6 | ▶ | sub _addPathNode { | ||||||||||||||||||||||||||
|
Subroutine
_addPathNode: called CC=3 SCAR=15.0
| |||||||||||||||||||||||||||||
| 564 | 6 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 565 | 6 | my $path = $node->addNewChild('', 'y:Path'); | |||||||||||||||||||||||||||
| 566 | 6 | $path->setAttribute('sx', $self->sx()); | |||||||||||||||||||||||||||
| 567 | 6 | $path->setAttribute('sy', $self->sy()); | |||||||||||||||||||||||||||
| 568 | 6 | $path->setAttribute('tx', $self->tx()); | |||||||||||||||||||||||||||
| 569 | 6 | $path->setAttribute('ty', $self->ty()); | |||||||||||||||||||||||||||
| 570 | 6 | my @prev = $self->source()->absCenter(); | |||||||||||||||||||||||||||
| 571 | 6 | $prev[0] += $self->sx(); # <-calculated absolute coords for the source anchor | |||||||||||||||||||||||||||
| 572 | 6 | $prev[1] += $self->sy(); # <-' | |||||||||||||||||||||||||||
| 573 | 6 | foreach my $coords ($self->waypoints()) { | |||||||||||||||||||||||||||
| 574 | 0 | my $x = $coords->[0]; | |||||||||||||||||||||||||||
| 575 | 0 | my $y = $coords->[1]; | |||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ($self->relativeWaypoints()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 577 | 0 | $x += $prev[0]; | |||||||||||||||||||||||||||
| 578 | 0 | $y += $prev[1]; | |||||||||||||||||||||||||||
| 579 | 0 | $prev[0] = $x; | |||||||||||||||||||||||||||
| 580 | 0 | $prev[1] = $y; | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | 0 | my $wp = $path->addNewChild('', 'y:Point'); | |||||||||||||||||||||||||||
| 583 | 0 | $wp->setAttribute('x', $x); | |||||||||||||||||||||||||||
| 584 | 0 | $wp->setAttribute('y', $y); | |||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||
| 587 | 6 | ▶ | sub _addLineStyleNode { | ||||||||||||||||||||||||||
|
Subroutine
_addLineStyleNode: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 588 | 6 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 589 | 6 | my $ls = $node->addNewChild('', 'y:LineStyle'); | |||||||||||||||||||||||||||
| 590 | 6 | ▶ | $ls->setAttribute('color', $self->lineColor() eq 'none' ? '#000000' : $self->lineColor()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 591 | 6 | $ls->setAttribute('type', $self->lineType()); | |||||||||||||||||||||||||||
| 592 | 6 | $ls->setAttribute('width', $self->lineWidth()); | |||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | 6 | ▶ | sub _addArrowsNode { | ||||||||||||||||||||||||||
|
Subroutine
_addArrowsNode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 595 | 6 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 596 | 6 | my $arrows = $node->addNewChild('', 'y:Arrows'); | |||||||||||||||||||||||||||
| 597 | 6 | $arrows->setAttribute('source', $self->sArrow()); | |||||||||||||||||||||||||||
| 598 | 6 | $arrows->setAttribute('target', $self->tArrow()); | |||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||
| 600 | 6 | ▶ | sub _addLabelsNode { | ||||||||||||||||||||||||||
|
Subroutine
_addLabelsNode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 601 | 6 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 602 | 6 | foreach my $label ($self->labels()) { | |||||||||||||||||||||||||||
| 603 | 1 | $node->addChild($label->_build()); | |||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | 3 | ▶ | sub _addAdditionalNodes { | ||||||||||||||||||||||||||
|
Subroutine
_addAdditionalNodes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 607 | # add type specific data here (e.g. <y:Arc ...) | ||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | =head2 setProperties getProperties hasProperties | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | As described at L<yEd::PropertyBasedObject> | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | L<yEd::Document> for further informations about the whole package | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | L<yEd::PropertyBasedObject> for further basic information about properties and their additional functions | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | The specialized Edges: | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | L<yEd::Edge::ArcEdge> | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | L<yEd::Edge::BezierEdge> | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | L<yEd::Edge::GenericEdge> | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | L<yEd::Edge::PolyLineEdge> | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | L<yEd::Edge::QuadCurveEdge> | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | L<yEd::Edge::SplineEdge> | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =cut | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | 3 | 1; | |||||||||||||||||||||||||||