Graph/Xmgrace/Graph_Options.pm

filter: Statementstmt 58.9% 102 / 173 Branchbran 64.2% 9 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 15 / 30 Podpod n/a totaltotal 58.0% 126 / 217 CC 11 SCAR 10.1
CC
11
Cov
59%
print
6.8
print
4.1
print
3.4
CRAP 2.7
« Graph/Xmgrace/Dataset_Options.pm ↑ Summary Graph/Xmgrace/World_Option.pm »
1 #
2 # Graph_Options.pm contains all the different options (objects) for a particular graph
3 #
4 # options included:
5 # 1) Chart::Graph::Xmgrace::Graph_Global_Options
6 # 2) Chart::Graph::Xmgrace::Global_Options
7 # 3) Chart::Graph::Xmgrace::Stack_Options
8 # 4) Chart::Graph::Xmgrace::View_Options
9 # 5) Chart::Graph::Xmgrace::Title_Options
10 # 6) Chart::Graph::Xmgrace::Subtitle_Options
11 # 7) Chart::Graph::Xmgrace::Legend_Options
12 # 8) Chart::Graph::Xmgrace::Frame_Options
13 # 9) Chart::Graph::Xmgrace::Extra_Options
14 #
15 ## This software product is developed by Esmond Lee and David Moore,
16 ## and copyrighted(C) 1998 by the University of California, San Diego
17 ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant,
18 ## NCR-9711092, under which part of this code was developed.
19 ##
20 ## There is no charge for this software. You can redistribute it and/or
21 ## modify it under the terms of the GNU General Public License, v. 2 dated
22 ## June 1991 which is incorporated by reference herein. This software is
23 ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY
24 ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not
25 ## infringe on any third party's intellectual property rights.
26 ##
27 ## You should have received a copy of the GNU GPL along with this program.
28 ##
29 ##
30 ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
31 ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
32 ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
33 ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF
34 ## THE POSSIBILITY OF SUCH DAMAGE.
35 ##
36 ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
37 ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
38 ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY
39 ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
40 ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED
41 ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
42 ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
43 ## ANY PATENT, TRADEMARK OR OTHER RIGHTS.
44 ##
45 ##
46 ## Contact: graph-dev@caida.org
47 ##
48 ##
49  
50 4 $VERSION = 3.2;
51  
52 4 ▶use Chart::Graph::Xmgrace::Base_Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 package Chart::Graph::Xmgrace::Graph_Global_Options;
55 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
56  
57 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
58 3 my $self = shift;
59 3 my $graph_number = shift;
60  
61 3 $self->{name} = $graph_number;
62 3 $self->{print_order} = ["stacked","hidden","type","bar hgap","fixedpoint",
63 "fixedpoint type","fixedpoint xy","fixedpoint format",
64 "fixedpoint prec","with"];
65 3 $self->{length} = 0;
66 $self->{options} = {
67 3 "stacked" => "false",
68 "hidden" => "false",
69 "type" => "XY",
70 "bar hgap" => '0.000000',
71 "fixedpoint" => "off",
72 "fixedpoint type" => "0",
73 "fixedpoint xy" => ["0.000000","0.000000"],
74 "fixedpoint format" => "general general",
75 "fixedpoint prec" => ["6","6"],
76 "with" => $graph_number,
77 };
78 }
79  
80 1 ▶sub print($$ ) {
Subroutine print: called CC=6 SCAR=19.2
81 1 my $self = shift;
82 1 my $handle = shift;
83 1 my $string = "";
84 1 my $substr = ""; # for making arrays into a string
85  
86 1 foreach $option (@{ $self->{"print_order"} }) {
87 10 my $option_ref = $self->{"options"};
88  
89 # print function handles both scalars and lists
90 10 ▶ if ($self->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'name'}) { } 10 0 10
91 10 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 2 8 10
elsif ($option eq 'with') { } 1 7 8
92 2 $substr = join (", ", (@{ $option_ref->{$option} }));
93 2 $string = "$self->{name} $option $substr\n";
94 } elsif ($option eq "with") {
95 1 $string = "$option $option_ref->{$option}\n";
96 } else {
97 7 $string = "$self->{name} $option $option_ref->{$option}\n";
98 }
99 } else { # global options don't have a name field
100 0 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 0 0 0
101 0 $substr = join (", ", (@{ $option_ref->{$option} }));
102 0 $string = "$option $substr\n";
103 } else {
104 0 $string = "$option $option_ref->{$option}\n";
105 }
106 }
107 10 $self->_printline($handle, $string, $self->{"length"});
108 }
109 }
110  
111  
112 package Chart::Graph::Xmgrace::Global_Options;
113 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
114  
115 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
116 3 my $self = shift;
117 3 $self->{print_order} = ["version","page size","page scroll","page inout",
118 "link page","reference date","date wrap",
119 "date wrap year"];
120 3 $self->{length} = 0;
121 $self->{options} = {
122 3 "version" => "50005",
123 "page size" => ["640", "480"],
124 "page scroll" => "5\%",
125 "page inout" => "5\%",
126 "link page" => "off",
127 "reference date" => "0",
128 "date wrap" => "off",
129 "date wrap year" => "1950",
130 };
131 }
132  
133 0 ▶sub page_size ($$) {
Subroutine page_size: not called CC=1 SCAR=6.9
134 0 $self = shift;
135 0 $val = shift;
136 0 $self->{options}->{"page size"} = $val;
137 0 return 1;
138 }
139  
140 0 ▶sub page_scroll ($$) {
Subroutine page_scroll: not called CC=1 SCAR=6.9
141 0 $self = shift;
142 0 $val = shift;
143 0 $self->{options}->{"page size"} = $val;
144 0 return 1;
145 }
146  
147 0 ▶sub page_inout ($$) {
Subroutine page_inout: not called CC=1 SCAR=6.9
148 0 $self = shift;
149 0 $val = shift;
150 0 $self->{options}->{"page size"} = $val;
151 0 return 1;
152 }
153  
154 0 ▶sub link_page ($$) {
Subroutine link_page: not called CC=1 SCAR=6.9
155 0 $self = shift;
156 0 $val = shift;
157 0 $self->{options}->{"link page"} = $val;
158 0 return 1;
159 }
160  
161 0 ▶sub reference_date ($$) {
Subroutine reference_date: not called CC=1 SCAR=6.9
162 0 $self = shift;
163 0 $val = shift;
164 0 $self->{options}->{"reference date"} = $val;
165 0 return 1;
166 }
167  
168 0 ▶sub date_wrap ($$) {
Subroutine date_wrap: not called CC=1 SCAR=6.9
169 0 $self = shift;
170 0 $val = shift;
171 0 $self->{options}->{"date wrap"} = $val;
172 0 return 1;
173 }
174  
175 0 ▶sub date_wrap_year ($$) {
Subroutine date_wrap_year: not called CC=1 SCAR=6.9
176 0 $self = shift;
177 0 $val = shift;
178 0 $self->{options}->{"date wrap year"} = $val;
179 0 return 1;
180 }
181  
182 package Chart::Graph::Xmgrace::World_Options;
183 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
184  
185 4 my %def_world_options = (
186 );
187  
188 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
189 3 my $self = shift;
190 3 $self->{name} = "world";
191 3 $self->{print_order} = ["xmin","xmax","ymin","ymax"];
192 3 $self->{length} = 4;
193 $self->{options} = {
194 3 "xmin" => "0",
195 "xmax" => "1",
196 "ymin" => "0",
197 "ymax" => "1",
198 };
199 }
200  
201 package Chart::Graph::Xmgrace::Stack_Options;
202 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
203  
204 4 my %def_stack_options = (
205
206 );
207  
208 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
209 3 my $self = shift;
210 3 $self->{name} = "stack";
211 3 $self->{print_order} = ["world"];
212 3 $self->{length} = 4;
213 $self->{options} = {
214 3 "world" => ["0","0","0","0"],
215 };
216 }
217  
218 package Chart::Graph::Xmgrace::View_Options;
219 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
220  
221 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
222 3 my $self = shift;
223 3 $self->{name} = "view";
224 3 $self->{print_order} = ["xmin","xmax","ymin","ymax"];
225 3 $self->{length} = 4;
226 $self->{options} = {
227 3 "xmin" => "0.150000",
228 "xmax" => "1.150000",
229 "ymin" => "0.150000",
230 "ymax" => "0.850000",
231 };
232 }
233  
234 package Chart::Graph::Xmgrace::Title_Options;
235 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
236  
237 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
238 3 my $self = shift;
239 3 $self->{name} = "title";
240 3 $self->{print_order} = ["title","font","size","color"];
241 3 $self->{length} = 4;
242 $self->{options} = {
243 3 "title" => '""',
244 "font" => "0",
245 "size" => "1.250000",
246 "color" => "1",
247 };
248 }
249  
250 2 ▶sub print($$ ) {
Subroutine print: called CC=4 SCAR=14.2
251 2 my $self = shift;
252 2 my $handle = shift;
253 2 my $string = "";
254 2 my $substr = ""; # for making arrays into a string
255  
256 2 foreach $option (@{ $self->{"print_order"} }) {
257 8 my $option_ref = $self->{"options"};
258
259 8 ▶ if ($option eq "title") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq 'title') { } 2 6 8
260 2 $string = "$self->{name} \"$option_ref->{$option}\"\n";
261 } else {
262 # print function handles both scalars and lists
263 6 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 0 6 6
264 0 $substr = join (", ", (@{ $option_ref->{$option} }));
265 0 $string = "$self->{name} $option $substr\n";
266 } else {
267 6 $string = "$self->{name} $option $option_ref->{$option}\n";
268 }
269 }
270 8 $self->_printline($handle, $string, $self->{"length"});
271 }
272 }
273  
274 package Chart::Graph::Xmgrace::Subtitle_Options;
275 4 @ISA = qw(Chart::Graph::Xmgrace::Title_Options);
276  
277 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
278 3 my $self = shift;
279 3 $self->{name} = "subtitle";
280 3 $self->{print_order} = ["title","font","size","color"];
281 3 $self->{length} = 4;
282 $self->{options} = {
283 3 "title" => '""',
284 "font" => "0",
285 "size" => "1.000000",
286 "color" => "1",
287 };
288 }
289  
290 package Chart::Graph::Xmgrace::Legend_Options;
291 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
292  
293 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
294 3 my $self = shift;
295 3 $self->{name} = "legend";
296 3 $self->{print_order} = ["status","loctype","x1","y1","box color",
297 "box pattern","box linewidth","box linestyle",
298 "box fill color","box fill pattern","font",
299 "char size","color","length","vgap","hgap",
300 "invert"];
301 3 $self->{length} = 4;
302 $self->{options} = {
303 3 "status" => "on",
304 "loctype" => "view",
305 "x1" => "0.85",
306 "y1" => "0.8",
307 "box color" => "1",
308 "box pattern" => "1",
309 "box linewidth" => "1.0",
310 "box linestyle" => "1",
311 "box fill color" => "0",
312 "box fill pattern" => "1",
313 "font" => "0",
314 "char size" => "1.000000",
315 "color" => "1",
316 "length" => "4",
317 "vgap" => "1",
318 "hgap" => "1",
319 "invert" => "false",
320 };
321 }
322  
323 0 ▶sub box_color ($$) {
Subroutine box_color: not called CC=1 SCAR=6.9
324 0 $self = shift;
325 0 $val = shift;
326 0 $self->{options}->{"box color"} = $val;
327 0 return 1;
328 }
329  
330 0 ▶sub box_linewidth ($$) {
Subroutine box_linewidth: not called CC=1 SCAR=6.9
331 0 $self = shift;
332 0 $val = shift;
333 0 $self->{options}->{"box linewidth"} = $val;
334 0 return 1;
335 }
336  
337 0 ▶sub box_linestyle ($$) {
Subroutine box_linestyle: not called CC=1 SCAR=6.9
338 0 $self = shift;
339 0 $val = shift;
340 0 $self->{options}->{"box linestyle"} = $val;
341 0 return 1;
342 }
343  
344 0 ▶sub box_fill_color ($$) {
Subroutine box_fill_color: not called CC=1 SCAR=6.9
345 0 $self = shift;
346 0 $val = shift;
347 0 $self->{options}->{"box fill color"} = $val;
348 0 return 1;
349 }
350  
351 0 ▶sub box_fill_pattern ($$) {
Subroutine box_fill_pattern: not called CC=1 SCAR=6.9
352 0 $self = shift;
353 0 $val = shift;
354 0 $self->{options}->{"box fill pattern"} = $val;
355 0 return 1;
356 }
357  
358 0 ▶sub char_size ($$) {
Subroutine char_size: not called CC=1 SCAR=6.9
359 0 $self = shift;
360 0 $val = shift;
361 0 $self->{options}->{"char size"} = $val;
362 0 return 1;
363 }
364  
365 package Chart::Graph::Xmgrace::Frame_Options;
366 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
367  
368 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
369 3 my $self = shift;
370 3 $self->{name} = "frame";
371 3 $self->{print_order} = ["type","linestyle","linewidth","color",
372 "pattern","background color","background pattern"];
373 3 $self->{length} = 4;
374 $self->{options} = {
375 3 "type" => "0",
376 "linestyle" => "1",
377 "linewidth" => "1.0",
378 "color" => "1",
379 "pattern" => "1",
380 "background color" => "0",
381 "background pattern" => "0",
382 };
383 }
384  
385 0 ▶sub background_color ($$) {
Subroutine background_color: not called CC=1 SCAR=6.9
386 0 $self = shift;
387 0 $val = shift;
388 0 $self->{options}->{"background color"} = $val;
389 0 return 1;
390 }
391  
392 0 ▶sub background_pattern ($$) {
Subroutine background_pattern: not called CC=1 SCAR=6.9
393 0 $self = shift;
394 0 $val = shift;
395 0 $self->{options}->{"background pattern"} = $val;
396 0 return 1;
397 }
398  
399  
400 package Chart::Graph::Xmgrace::Extra_Options;
401 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
402  
403 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
404 3 my $self = shift;
405 3 $self->{name} = "extra options";
406 3 $self->{length} = 4;
407 3 $self->{options} = {"extras" => undef,}; # extra options are \n delimited
408 }
409  
410  
411 # just dumps, verbatim, whatever the user inputs
412 1 ▶sub print($$ ) {
Subroutine print: called CC=3 SCAR=12.3
413 1 my $self = shift;
414 1 my $handle = shift;
415 1 my $string = "";
416 1 my @xtra_opts;
417 1 my $pre_sub = $self->{options}->{extras};
418 1 ▶ if ($pre_sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre_sub) 0 1 1
419 0 @xtra_opts = split(/;\n*\s*/, $pre_sub);
420
421 0 foreach $option (@xqtra_opts) {
422 0 $self->_printline($handle, "$option\n", $self->{"length"});
423 }
424 }
425 }
426  
427 4 1;
« Graph/Xmgrace/Dataset_Options.pm ↑ Summary Graph/Xmgrace/World_Option.pm »