| 1 | package yEd::Label::EdgeLabel; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 1 | ▶ | use yEd::PropertyBasedObject; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | 1 | ▶ | use base qw(yEd::Label); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | yEd::Label::EdgeLabel - Textlabels for Edges | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | Use this class to label your Edges. | ||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | Make sure to have a look at L<yEd::Label>, the properties and functions described there will not be repeated here. | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | If you want to label a Node class element use L<yEd::Label::NodeLabel>. | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | =head1 SUPPORTED FEATURES | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | see L<yEd::Label> | ||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | =head1 PROPERTIES | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | =head2 all properties from base class | ||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | L<yEd::Label> | ||||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | =head2 positionModell | ||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | Type: descrete values ( see below ) | ||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | Default: 'two_pos-head' | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | Describes how to position the Label on the Edge. | ||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | =head3 free | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | Free positioning (use x, y) | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | =head3 two_pos-X | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | Where X is one of: | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =over 4 | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =item * | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | head : Centered above line | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =item * | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | tail : Centered below line | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =back | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | =head3 centered | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | Centered on line | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | =head3 six_pos-X | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | Where X is one of: | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | =over 4 | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | =item * | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | head : Centered above line | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | =item * | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | shead : At source above line | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | =item * | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | thead : At target above line | ||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | =item * | ||||||||||||||||||
| 80 | |||||||||||||||||||
| 81 | tail : Centered below line | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | =item * | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | stail : At source below line | ||||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | =item * | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | ttail : At target below line | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | =back | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | =head3 three_center-X | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | Where X is one of: | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | =over 4 | ||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | =item * | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | center : Centered on line | ||||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | =item * | ||||||||||||||||||
| 104 | |||||||||||||||||||
| 105 | scentr : At source on line | ||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | =item * | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | tcentr : At target on line | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | =back | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | =head3 center_slider | ||||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | On the line position defined by ratio | ||||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | =head3 side_slider | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | Above or below the line position defined by ratio and y value for above/below (?) | ||||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | =head2 ratio | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | Type: ration (ufloat [0-1]) | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | Default: 0.5 | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | Defines the Label position for slider positioning modells, where 0 is at source, 1 is at target and 0.5 is centered. | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | =head2 distance | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | Type: float | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | Default: 2 | ||||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | Defines the distance of the Label from the Edge (may have no effect depending on positioning modell). | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | =head2 autoFlip | ||||||||||||||||||
| 138 | |||||||||||||||||||
| 139 | Type: bool | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | Default: true | ||||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | Automatically flip the Label if it gets upside-down (because of effective direction of the Edge). | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||
| 146 | |||||||||||||||||||
| 147 | =head2 all functions from base class | ||||||||||||||||||
| 148 | |||||||||||||||||||
| 149 | L<yEd::Label> | ||||||||||||||||||
| 150 | |||||||||||||||||||
| 151 | =cut | ||||||||||||||||||
| 152 | |||||||||||||||||||
| 153 | 1 | my $modellmatch = '^(?:free|two_pos-(?:head|tail)|centered|six_pos-(?:head|shead|thead|tail|stail|ttail)|three_center-(?:center|scentr|tcentr)|center_slider|side_slider)$'; | |||||||||||||||||
| 154 | |||||||||||||||||||
| 155 | =head2 new | ||||||||||||||||||
| 156 | |||||||||||||||||||
| 157 | Creates a new instance of EdgeLabel. | ||||||||||||||||||
| 158 | |||||||||||||||||||
| 159 | A value for the text property must be provided as first parameter. | ||||||||||||||||||
| 160 | |||||||||||||||||||
| 161 | Further parameters to set properties are optional (property => value, ...). | ||||||||||||||||||
| 162 | |||||||||||||||||||
| 163 | =cut | ||||||||||||||||||
| 164 | |||||||||||||||||||
| 165 | sub new { | ||||||||||||||||||
| 166 | 0 | ▶ | my ($class, @args) = @_; | ||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 167 | 0 | my $self = bless {}, $class; | |||||||||||||||||
| 168 | 0 | return $self->_init(@args); | |||||||||||||||||
| 169 | } | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | sub _init { | ||||||||||||||||||
| 172 | 0 | ▶ | my ($self, @args) = @_; | ||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 173 | 0 | $self->distance(2); | |||||||||||||||||
| 174 | 0 | $self->autoFlip(1); | |||||||||||||||||
| 175 | 0 | $self->ratio(0.5); | |||||||||||||||||
| 176 | 0 | $self->positionModell('two_pos-head'); | |||||||||||||||||
| 177 | 0 | $self->SUPER::_init(@args); | |||||||||||||||||
| 178 | 0 | return $self; | |||||||||||||||||
| 179 | } | ||||||||||||||||||
| 180 | |||||||||||||||||||
| 181 | sub positionModell { | ||||||||||||||||||
| 182 | 0 | ▶ | return _PROPERTY($modellmatch, @_); | ||||||||||||||||
|
Subroutine
positionModell: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 183 | } | ||||||||||||||||||
| 184 | sub distance { # to edge | ||||||||||||||||||
| 185 | 0 | ▶ | return _PROPERTY($match{'float'}, @_); | ||||||||||||||||
|
Subroutine
distance: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 186 | } | ||||||||||||||||||
| 187 | sub ratio { # position on sliders | ||||||||||||||||||
| 188 | 0 | ▶ | return _PROPERTY($match{'ratio'}, @_); | ||||||||||||||||
|
Subroutine
ratio: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 189 | } | ||||||||||||||||||
| 190 | sub autoFlip { | ||||||||||||||||||
| 191 | 0 | ▶ | return _PROPERTY('bool', @_); | ||||||||||||||||
|
Subroutine
autoFlip: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 192 | } | ||||||||||||||||||
| 193 | |||||||||||||||||||
| 194 | sub _build { | ||||||||||||||||||
| 195 | 0 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
_build: not called CC=15 SCAR=54.8
| |||||||||||||||||||
| 196 | 0 | my $node = XML::LibXML::Element->new('y:EdgeLabel'); | |||||||||||||||||
| 197 | 0 | $node->appendText($self->getTextString()); | |||||||||||||||||
| 198 | 0 | $node->setAttribute('alignment', $self->alignment()); | |||||||||||||||||
| 199 | 0 | $node->setAttribute('fontFamily', $self->fontFamily()); | |||||||||||||||||
| 200 | 0 | $node->setAttribute('fontSize', $self->fontSize()); | |||||||||||||||||
| 201 | 0 | $node->setAttribute('fontStyle', $self->fontStyle()); | |||||||||||||||||
| 202 | 0 | ▶ | if ($self->backgroundColor() eq 'none') { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 203 | 0 | $node->setAttribute('hasBackgroundColor', 'false'); | |||||||||||||||||
| 204 | } else { | ||||||||||||||||||
| 205 | 0 | $node->setAttribute('backgroundColor', $self->backgroundColor()); | |||||||||||||||||
| 206 | } | ||||||||||||||||||
| 207 | 0 | ▶ | if ($self->lineColor() eq 'none') { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 208 | 0 | $node->setAttribute('hasLineColor', 'false'); | |||||||||||||||||
| 209 | } else { | ||||||||||||||||||
| 210 | 0 | $node->setAttribute('lineColor', $self->lineColor()); | |||||||||||||||||
| 211 | } | ||||||||||||||||||
| 212 | 0 | $node->setAttribute('x', $self->x()); | |||||||||||||||||
| 213 | 0 | $node->setAttribute('y', $self->y()); | |||||||||||||||||
| 214 | 0 | $node->setAttribute('height', $self->height()); | |||||||||||||||||
| 215 | 0 | $node->setAttribute('width', $self->width()); | |||||||||||||||||
| 216 | 0 | ▶ | $node->setAttribute('textColor', $self->textColor() eq 'none' ? '#000000' : $self->textColor()); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 217 | 0 | ▶ | $node->setAttribute('visible', $self->visible() ? 'true' : 'false'); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 218 | 0 | ▶ | $node->setAttribute('bottomInset', $self->bottomInset()) unless ($self->bottomInset() =~ m/^0*$/);; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 219 | 0 | ▶ | $node->setAttribute('topInset', $self->topInset()) unless ($self->topInset() =~ m/^0*$/);; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 220 | 0 | ▶ | $node->setAttribute('rightInset', $self->rightInset()) unless ($self->rightInset() =~ m/^0*$/);; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 221 | 0 | ▶ | $node->setAttribute('leftInset', $self->leftInset()) unless ($self->leftInset() =~ m/^0*$/);; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 222 | 0 | ▶ | $node->setAttribute('rotationAngle', $self->rotationAngle()) unless ($self->rotationAngle() =~ m/^-?0*\.?0*$/);; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 223 | 0 | ▶ | $node->setAttribute('underlinedText', 'true') if ($self->underlinedText()); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 224 | # EdgeLabel | ||||||||||||||||||
| 225 | 0 | ▶ | if ($self->positionModell() eq 'free') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 226 | 0 | $node->setAttribute('modelName', $self->positionModell()); | |||||||||||||||||
| 227 | 0 | $node->setAttribute('modelPosition', 'anywhere'); | |||||||||||||||||
| 228 | } elsif ($self->positionModell() eq 'centered') { | ||||||||||||||||||
| 229 | 0 | $node->setAttribute('modelName', $self->positionModell()); | |||||||||||||||||
| 230 | 0 | $node->setAttribute('modelPosition', 'center'); | |||||||||||||||||
| 231 | } elsif ($self->positionModell() =~ m/^(?:center|side)_slider$/) { | ||||||||||||||||||
| 232 | 0 | $node->setAttribute('modelName', $self->positionModell()); | |||||||||||||||||
| 233 | } else { | ||||||||||||||||||
| 234 | 0 | my ($m, $p) = split '-', $self->positionModell(); | |||||||||||||||||
| 235 | 0 | $node->setAttribute('modelName', $m); | |||||||||||||||||
| 236 | 0 | $node->setAttribute('modelPosition', $p); | |||||||||||||||||
| 237 | } | ||||||||||||||||||
| 238 | 0 | ▶ | $node->setAttribute('configuration', 'AutoFlippingLabel') if ($self->autoFlip()); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 239 | 0 | $node->setAttribute('distance', $self->distance()); | |||||||||||||||||
| 240 | 0 | $node->setAttribute('ratio', $self->ratio()); | |||||||||||||||||
| 241 | 0 | $node->setAttribute('preferredPlacement', 'anywhere'); | |||||||||||||||||
| 242 | 0 | my $ppdNode = $node->addNewChild('', 'y:PreferredPlacementDescriptor'); | |||||||||||||||||
| 243 | 0 | $ppdNode->setAttribute('angle', '0.0'); | |||||||||||||||||
| 244 | 0 | $ppdNode->setAttribute('angleOffsetOnRightSide', '0'); | |||||||||||||||||
| 245 | 0 | $ppdNode->setAttribute('angleReference', 'relative_to_edge_flow'); | |||||||||||||||||
| 246 | 0 | $ppdNode->setAttribute('angleRotationOnRightSide', 'co'); | |||||||||||||||||
| 247 | 0 | $ppdNode->setAttribute('distance', '-1.0'); | |||||||||||||||||
| 248 | 0 | $ppdNode->setAttribute('placement', 'anywhere'); | |||||||||||||||||
| 249 | 0 | $ppdNode->setAttribute('side', 'anywhere'); | |||||||||||||||||
| 250 | 0 | $ppdNode->setAttribute('sideReference', 'relative_to_edge_flow'); | |||||||||||||||||
| 251 | 0 | $ppdNode->setAttribute('preferredPlacement', 'anywhere'); | |||||||||||||||||
| 252 | 0 | return $node; | |||||||||||||||||
| 253 | } | ||||||||||||||||||
| 254 | |||||||||||||||||||
| 255 | =head1 SEE ALSO | ||||||||||||||||||
| 256 | |||||||||||||||||||
| 257 | L<yEd::Document> for further informations about the whole package | ||||||||||||||||||
| 258 | |||||||||||||||||||
| 259 | L<yEd::PropertyBasedObject> for further basic information about properties and their additional functions | ||||||||||||||||||
| 260 | |||||||||||||||||||
| 261 | L<yEd::Label> for information about the Label base class | ||||||||||||||||||
| 262 | |||||||||||||||||||
| 263 | L<yEd::Label::NodeLabel> for information about specialized Label elements for Nodes | ||||||||||||||||||
| 264 | |||||||||||||||||||
| 265 | =cut | ||||||||||||||||||
| 266 | |||||||||||||||||||
| 267 | 1 | 1; | |||||||||||||||||