line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::GoogleEarth::Pluggable::Plugin::Style; |
2
|
1
|
|
|
1
|
|
1481
|
use Geo::GoogleEarth::Pluggable::Style; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Geo::GoogleEarth::Pluggable::StyleMap; |
4
|
|
|
|
|
|
|
use Scalar::Util qw{blessed}; |
5
|
|
|
|
|
|
|
use warnings; |
6
|
|
|
|
|
|
|
use strict; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION='0.14'; |
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 |
18
|
|
|
|
|
|
|
my $style=$document->IconStyle(color=>{red=>255}); #ISA L |
19
|
|
|
|
|
|
|
my $point=$document->Point(style=>$style); #ISA L |
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
|
|
|
|
|
|
|
sub Style { |
48
|
|
|
|
|
|
|
my $self=shift; |
49
|
|
|
|
|
|
|
my %data=@_; |
50
|
|
|
|
|
|
|
foreach my $key (keys %data) { |
51
|
|
|
|
|
|
|
next unless $key=~m/Style$/; |
52
|
|
|
|
|
|
|
#Extracts the particular IconStyle, LineStyle, etc from an existing Style object |
53
|
|
|
|
|
|
|
my $ref=$data{$key}; |
54
|
|
|
|
|
|
|
if (blessed($ref) and $ref->can("type") and $ref->type eq "Style") { |
55
|
|
|
|
|
|
|
$data{$key}=$ref->{$key}; #allow Style to be blessed objects |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
my $obj=Geo::GoogleEarth::Pluggable::Style->new( |
59
|
|
|
|
|
|
|
document=>$self->document, |
60
|
|
|
|
|
|
|
%data, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
$self->document->data($obj); |
63
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub StyleMap { |
78
|
|
|
|
|
|
|
my $self=shift; |
79
|
|
|
|
|
|
|
my %data=@_; |
80
|
|
|
|
|
|
|
my $obj=Geo::GoogleEarth::Pluggable::StyleMap->new( |
81
|
|
|
|
|
|
|
document=>$self->document, |
82
|
|
|
|
|
|
|
%data, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
$self->document->data($obj); |
85
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub IconStyle { |
99
|
|
|
|
|
|
|
my $self=shift; |
100
|
|
|
|
|
|
|
my %data=@_; |
101
|
|
|
|
|
|
|
my $id=delete($data{"id"}); #undef is fine here... |
102
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub LineStyle { |
113
|
|
|
|
|
|
|
my $self=shift; |
114
|
|
|
|
|
|
|
my %data=@_; |
115
|
|
|
|
|
|
|
$data{"width"}=1 unless defined $data{"width"}; |
116
|
|
|
|
|
|
|
my $id=delete($data{"id"}); #undef is fine here... |
117
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub PolyStyle { |
128
|
|
|
|
|
|
|
my $self=shift; |
129
|
|
|
|
|
|
|
my %data=@_; |
130
|
|
|
|
|
|
|
my $id=delete($data{"id"}); #undef is fine here... |
131
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub LabelStyle { |
144
|
|
|
|
|
|
|
my $self=shift; |
145
|
|
|
|
|
|
|
my %data=@_; |
146
|
|
|
|
|
|
|
my $id=delete($data{"id"}); #undef is fine here... |
147
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub ListStyle { |
159
|
|
|
|
|
|
|
my $self=shift; |
160
|
|
|
|
|
|
|
my %data=@_; |
161
|
|
|
|
|
|
|
my $id=delete($data{"id"}); #undef is fine here... |
162
|
|
|
|
|
|
|
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 creates a GoogleEarth Document. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |