Pluggable/Plugin/Style.pm

filter: Statementstmt 32.0% 17 / 53 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 41.6% 5 / 12 Podpod 100% 7 / 7 totaltotal 33.3% 29 / 87 CC 7 SCAR 27.4
CC
7
Cov
26%
Style
42.0
LineStyle
6.0
StyleMap
2.0
CRAP 15.5
« Pluggable/Plugin/Others.pm ↑ Summary Pluggable/Folder.pm »
1 package Geo::GoogleEarth::Pluggable::Plugin::Style;
2 1 ▶use Geo::GoogleEarth::Pluggable::Style;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Geo::GoogleEarth::Pluggable::StyleMap;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Scalar::Util qw{blessed};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION='0.17';
9  
10 =head1 NAME
11  
12 Geo::GoogleEarth::Pluggable::Plugin::Style - Geo::GoogleEarth::Pluggable Style Plugin Methods
13  
14 =head1 SYNOPSIS
15  
16 use Geo::GoogleEarth::Pluggable;
17 my $document=Geo::GoogleEarth::Pluggable->new; #ISA L<Geo::GoogleEarth::Pluggable>
18 my $style=$document->IconStyle(color=>{red=>255}); #ISA L<Geo::GoogleEarth::Pluggable::Style>
19 my $point=$document->Point(style=>$style); #ISA L<Geo::GoogleEarth::Pluggable::Contrib::Point>
20 print $document->render;
21  
22 =head1 METHODS
23  
24 Methods in this package are AUTOLOADed into the Geo::GoogleEarth::Pluggable::Folder namespace at runtime.
25  
26 =head2 Style
27  
28 Constructs a new Style object and appends it to the document object. Returns the Style object reference.
29  
30 my $style=$folder->Style(
31 id => $id, #default is good
32 IconStyle => {},
33 LineStyle => {},
34 PolyStyle => {},
35 LabelStyle => {},
36 ListStyle => {},
37 );
38  
39 my $style=$folder->Style(
40 IconStyle => $style1, #extracts IconStyle from $style1
41 LineStyle => $style2, #extracts LineStyle from $style2
42 PolyStyle => $style3, #extracts PolyStyle from $style3
43 );
44  
45 =cut
46  
47 0 ▶sub Style {
Subroutine Style: not called CC=6 SCAR=37.4
Pod documented
48 0 my $self=shift;
49 0 my %data=@_;
50 0 foreach my $key (keys %data) {
51 0 ▶ next unless $key=~m/Style$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /Style$/ 0 0 0
52 #Extracts the particular IconStyle, LineStyle, etc from an existing Style object
53 0 my $ref=$data{$key};
54 0 ▶ if (blessed($ref) and $ref->can("type") and $ref->type eq "Style") {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($ref) and $ref->can("type") and $ref->type eq "Style") 0 0 0
Condition0%0/6
builtin::blessed($ref) and $ref->can("type") and $ref->type eq "Style"
!ll&&!rl&&r
000
builtin::blessed($ref) and $ref->can("type")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($ref) and $ref->can("type") and $ref->type eq "Style"
builtin::blessed($ref) $ref->can("type") $ref->type eq "Style"
Truth table0%0/4
A and B and C
A= builtin::blessed($ref)B= $ref->can("type")C= $ref->type eq "Style"
ABCresult
0XX0
10X0
1100
1111
55 0 $data{$key}=$ref->{$key}; #allow Style to be blessed objects
56 }
57 }
58 0 my $obj=Geo::GoogleEarth::Pluggable::Style->new(
59 document=>$self->document,
60 %data,
61 );
62 0 $self->document->data($obj);
63 0 return $obj;
64 }
65  
66 =head2 StyleMap
67  
68 Constructs a new StyleMap object and appends it to the document object. Returns the StyleMap object reference.
69  
70 my $stylemap=$document->StyleMap(
71 normal => $style1,
72 highlight => $style2,
73 );
74  
75 =cut
76  
77 0 ▶sub StyleMap {
Subroutine StyleMap: not called CC=1 SCAR=6.9
Pod documented
78 0 my $self=shift;
79 0 my %data=@_;
80 0 my $obj=Geo::GoogleEarth::Pluggable::StyleMap->new(
81 document=>$self->document,
82 %data,
83 );
84 0 $self->document->data($obj);
85 0 return $obj;
86 }
87  
88 =head2 IconStyle
89  
90 my $style=$folder->IconStyle(
91 color => $color,
92 scale => $scale,
93 href => $url,
94 );
95  
96 =cut
97  
98 0 ▶sub IconStyle {
Subroutine IconStyle: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self=shift;
100 0 my %data=@_;
101 0 my $id=delete($data{"id"}); #undef is fine here...
102 0 return $self->Style(id=>$id, IconStyle=>\%data);
103 }
104  
105 =head2 LineStyle
106  
107 my $color={red=>255, green=>255, blue=>255, alpha=>255};
108 my $style=$folder->LineStyle(color=>$color);
109  
110 =cut
111  
112 0 ▶sub LineStyle {
Subroutine LineStyle: not called CC=2 SCAR=17.9
Pod documented
113 0 my $self=shift;
114 0 my %data=@_;
115 0 ▶ $data{"width"}=1 unless defined $data{"width"};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data{"width"} 0 0 0
116 0 my $id=delete($data{"id"}); #undef is fine here...
117 0 return $self->Style(id=>$id, LineStyle=>\%data);
118 }
119  
120 =head2 PolyStyle
121  
122 my $color={red=>255, green=>255, blue=>255, alpha=>255};
123 my $style=$folder->PolyStyle(color=>$color);
124  
125 =cut
126  
127 0 ▶sub PolyStyle {
Subroutine PolyStyle: not called CC=1 SCAR=6.9
Pod documented
128 0 my $self=shift;
129 0 my %data=@_;
130 0 my $id=delete($data{"id"}); #undef is fine here...
131 0 return $self->Style(id=>$id, PolyStyle=>\%data);
132 }
133  
134 =head2 LabelStyle
135  
136 my $style=$folder->LabelStyle(
137 color => $color,
138 scale => $scale,
139 );
140  
141 =cut
142  
143 0 ▶sub LabelStyle {
Subroutine LabelStyle: not called CC=1 SCAR=6.9
Pod documented
144 0 my $self=shift;
145 0 my %data=@_;
146 0 my $id=delete($data{"id"}); #undef is fine here...
147 0 return $self->Style(id=>$id, LabelStyle=>\%data);
148 }
149  
150 =head2 ListStyle
151  
152 my $style=$folder->ListStyle(
153 href => $url,
154 );
155  
156 =cut
157  
158 0 ▶sub ListStyle {
Subroutine ListStyle: not called CC=1 SCAR=6.9
Pod documented
159 0 my $self=shift;
160 0 my %data=@_;
161 0 my $id=delete($data{"id"}); #undef is fine here...
162 0 return $self->Style(id=>$id, ListStyle=>\%data);
163 }
164  
165 =head1 TODO
166  
167 Need to determine what methods should be in the Folder package and what should be on the Plugin/Style package and why.
168  
169 =head1 BUGS
170  
171 Please log on RT and send to the geo-perl email list.
172  
173 =head1 LIMITATIONS
174  
175 This will construct 100 identical style objects
176  
177 foreach (1 .. 100) {
178 $document->Point(style=>$document->IconStyle(color=>{red=>255}));
179 }
180  
181 Do this instead
182  
183 my $style=$document->IconStyle(color=>{red=>255});
184 foreach (1 .. 100) {
185 $document->Point(style=>$style);
186 }
187  
188 =head1 SUPPORT
189  
190 Try geo-perl email list.
191  
192 =head1 AUTHOR
193  
194 Michael R. Davis (mrdvt92)
195 CPAN ID: MRDVT
196  
197 =head1 COPYRIGHT
198  
199 This program is free software licensed under the...
200  
201 The BSD License
202  
203 The full text of the license can be found in the
204 LICENSE file included with this module.
205  
206 =head1 SEE ALSO
207  
208 L<Geo::GoogleEarth::Pluggable> creates a GoogleEarth Document.
209  
210 =cut
211  
212 1 1;
« Pluggable/Plugin/Others.pm ↑ Summary Pluggable/Folder.pm »