blib/lib/Graphics/Primitive/Border.pm

filter: Statementstmt 89.1% 66 / 74 Branchbran 78.5% 11 / 14 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 93.7% 15 / 16 Podpod 80.0% 4 / 5 totaltotal 85.5% 101 / 118 SCAR 23.3
CC
10
Cov
86%
equal_to
5.9
homogeneous
4.1
BUILD
3.0
CRAP 10.3
« blib/lib/Graphics/Primitive/Container.pm ↑ Summary blib/lib/Graphics/Primitive/Path.pm »
1 package Graphics::Primitive::Border;
2 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 with 'MooseX::Clone';
6 9 with Storage (format => 'JSON', io => 'File');
7  
8 9 ▶use Graphics::Color;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Graphics::Primitive::Brush;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has 'bottom' => (
12 is => 'rw',
13 isa => 'Graphics::Primitive::Brush',
14 default => sub {
15 24 ▶ Graphics::Primitive::Brush->new
Subroutine __ANON__: called CC=1 SCAR=0.0
16 },
17 9 traits => [qw(Clone)]
18 );
19 has 'color' => (
20 is => 'rw',
21 isa => 'Graphics::Color',
22 trigger => sub {
23 3 ▶ my ($self, $newval) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
24 3 $self->bottom->color($newval);
25 3 $self->left->color($newval);
26 3 $self->right->color($newval);
27 3 $self->top->color($newval);
28 },
29 9 predicate => 'has_color'
30 );
31 has 'left' => (
32 is => 'rw',
33 isa => 'Graphics::Primitive::Brush',
34 default => sub {
35 24 ▶ Graphics::Primitive::Brush->new
Subroutine __ANON__: called CC=1 SCAR=0.0
36 },
37 9 traits => [qw(Clone)]
38 );
39 has 'right' => (
40 is => 'rw',
41 isa => 'Graphics::Primitive::Brush',
42 default => sub {
43 24 ▶ Graphics::Primitive::Brush->new
Subroutine __ANON__: called CC=1 SCAR=0.0
44 },
45 9 traits => [qw(Clone)]
46 );
47 has 'top' => (
48 is => 'rw',
49 isa => 'Graphics::Primitive::Brush',
50 default => sub {
51 24 ▶ Graphics::Primitive::Brush->new
Subroutine __ANON__: called CC=1 SCAR=0.0
52 },
53 9 traits => [qw(Clone)]
54 );
55 has 'width' => (
56 is => 'rw',
57 isa => 'Int',
58 trigger => sub {
59 4 ▶ my ($self, $newval) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
60 4 $self->bottom->width($newval);
61 4 $self->left->width($newval);
62 4 $self->right->width($newval);
63 4 $self->top->width($newval);
64 },
65 9 predicate => 'has_width'
66 );
67  
68 9 __PACKAGE__->meta->make_immutable;
69  
70 sub BUILD {
71 26 ▶ my ($self) = @_;
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
72  
73 26 ▶ if($self->has_width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_width) 1 25 26
74 1 my $w = $self->width;
75 1 $self->bottom->width($w);
76 1 $self->left->width($w);
77 1 $self->right->width($w);
78 1 $self->top->width($w);
79 }
80 26 ▶ if($self->has_color) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_color) 1 25 26
81 1 my $c = $self->color;
82 1 $self->bottom->color($c);
83 1 $self->left->color($c);
84 1 $self->right->color($c);
85 1 $self->top->color($c);
86 }
87 }
88  
89 # sub color {
90 # my ($self, $c) = @_;
91 #
92 # $self->bottom->color($c);
93 # $self->left->color($c);
94 # $self->right->color($c);
95 # $self->top->color($c);
96 # }
97  
98 sub dash_pattern {
99 0 ▶ my ($self, $d) = @_;
Subroutine dash_pattern: not called CC=1 SCAR=6.9
Pod documented
100  
101 0 $self->bottom->dash_pattern($d);
102 0 $self->left->dash_pattern($d);
103 0 $self->right->dash_pattern($d);
104 0 $self->top->dash_pattern($d);
105 }
106  
107 sub equal_to {
108 3 ▶ my ($self, $other) = @_;
Subroutine equal_to: called CC=5 SCAR=17.8
Pod documented
109  
110 3 ▶ unless($self->top->equal_to($other->top)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->top->equal_to($other->top)) 0 3 3
111 0 return 0;
112 }
113 3 ▶ unless($self->right->equal_to($other->right)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->right->equal_to($other->right)) 0 3 3
114 0 return 0;
115 }
116 3 ▶ unless($self->bottom->equal_to($other->bottom)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->bottom->equal_to($other->bottom)) 0 3 3
117 0 return 0;
118 }
119 3 ▶ unless($self->left->equal_to($other->left)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->left->equal_to($other->left)) 1 2 3
120 1 return 0;
121 }
122  
123 2 return 1;
124 }
125  
126 sub homogeneous {
127 2 ▶ my ($self) = @_;
Subroutine homogeneous: called CC=4 SCAR=14.0
Pod documented
128  
129 2 my $b = $self->top;
130 2 ▶ unless($self->bottom->equal_to($b) && $self->left->equal_to($b)
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->bottom->equal_to($b) and $self->left->equal_to($b) and $self->right->equal_to($b)) 1 1 2
Condition66%4/6
$self->bottom->equal_to($b) and $self->left->equal_to($b) and $self->right->equal_to($b)
!ll&&!rl&&r
101
$self->bottom->equal_to($b) and $self->left->equal_to($b)
!ll&&!rl&&r
011
MC/DC33%1/3
$self->bottom->equal_to($b) and $self->left->equal_to($b) and $self->right->equal_to($b)
$self->bottom->equal_to($b) $self->left->equal_to($b) $self->right->equal_to($b)
Truth table50%2/4
A and B and C
A= $self->bottom->equal_to($b)B= $self->left->equal_to($b)C= $self->right->equal_to($b)
ABCresult
0XX0
10X0
1100
1111
131 && $self->right->equal_to($b)) {
132 1 return 0;
133 }
134 1 return 1;
135 }
136  
137 sub not_equal_to {
138 1 ▶ my ($self, $other) = @_;
Subroutine not_equal_to: called CC=1 SCAR=0.0
Pod documented
139  
140 1 return !$self->equal_to($other);
141 }
142  
143 # sub width {
144 # my ($self, $w) = @_;
145 #
146 # $self->bottom->width($w);
147 # $self->left->width($w);
148 # $self->right->width($w);
149 # $self->top->width($w);
150 # }
151  
152 9 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
153 9 1;
154 __END__
155  
156 =head1 NAME
157  
158 Graphics::Primitive::Border - Line around components
159  
160 =head1 DESCRIPTION
161  
162 Graphics::Primitive::Border describes the border to be rendered around a
163 component.
164  
165 =head1 SYNOPSIS
166  
167 use Graphics::Primitive::Border;
168  
169 my $border = Graphics::Primitive::Border->new;
170  
171 =head1 METHODS
172  
173 =head2 new
174  
175 Creates a new Graphics::Primitiver::Border. Borders are composed of 4
176 brushes, one for each of the 4 sides. See the documentation for
177 L<Graphics::Primitive::Brush> for more information. Note that you can
178 provide a C<width> and C<color> argument to the constructor and it will create
179 brushes of that width for each side.
180  
181 =head2 bottom
182  
183 The brush representing the bottom border.
184  
185 =head2 clone
186  
187 Close this border.
188  
189 =head2 color
190  
191 Set the Color on all 4 borders to the one supplied. Shortcut for setting it
192 with each side.
193  
194 =head2 dash_pattern
195  
196 Set the dash pattern on all 4 borders to the one supplied. Shortcut for
197 setting it with each side.
198  
199 =head2 equal_to ($other)
200  
201 Returns 1 if this border is equal to the one provided, else returns 0.
202  
203 =head2 homogeneous
204  
205 Returns 1 if all of this border's sides are the same. Allows for driver
206 optimizations.
207  
208 =head2 left
209  
210 The brush representing the left border.
211  
212 =head2 not_equal_to
213  
214 Opposite of C<equal_to>.
215  
216 =head2 right
217  
218 The brush representing the right border.
219  
220 =head2 top
221  
222 The brush representing the top border.
223  
224 =head2 width
225  
226 Set the width on all 4 borders to the one supplied. Shortcut for setting it
227 with each side.
228  
229 =head1 AUTHOR
230  
231 Cory Watson, C<< <gphat@cpan.org> >>
232  
233 =head1 COPYRIGHT & LICENSE
234  
235 Copyright 2008-2010 by Cory G Watson.
236  
237 This program is free software; you can redistribute it and/or modify it
238 under the same terms as Perl itself.
« blib/lib/Graphics/Primitive/Container.pm ↑ Summary blib/lib/Graphics/Primitive/Path.pm »