Graph/Xmgrace/Axis.pm

filter: Statementstmt 79.5% 39 / 49 Branchbran 100% 8 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 6 totaltotal 71.4% 55 / 77 CC 7 SCAR 14.0
CC
7
Cov
82%
print
7.0
type_zero
2.0
bar_options
2.0
CRAP 4.1
« Graph/Xmgrace/Axis_Option.pm ↑ Summary Graph/Xmgrace/Dataset.pm »
1 #
2 # Axis.pm is a class that contains the fundamental options for
3 #
4 ## This software product is developed by Esmond Lee and David Moore,
5 ## and copyrighted(C) 1998 by the University of California, San Diego
6 ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant,
7 ## NCR-9711092, under which part of this code was developed.
8 ##
9 ## There is no charge for this software. You can redistribute it and/or
10 ## modify it under the terms of the GNU General Public License, v. 2 dated
11 ## June 1991 which is incorporated by reference herein. This software is
12 ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY
13 ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not
14 ## infringe on any third party's intellectual property rights.
15 ##
16 ## You should have received a copy of the GNU GPL along with this program.
17 ##
18 ##
19 ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
20 ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
21 ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
22 ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF
23 ## THE POSSIBILITY OF SUCH DAMAGE.
24 ##
25 ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
26 ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
27 ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY
28 ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
29 ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED
30 ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
31 ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
32 ## ANY PATENT, TRADEMARK OR OTHER RIGHTS.
33 ##
34 ##
35 ## Contact: graph-dev@caida.org
36 ##
37 ##
38 4 $VERSION = 3.2;
39 package Chart::Graph::Xmgrace::Axis;
40 4 @ISA = qw(Chart::Graph::Xmgrace::Base_Option);
41 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 # for Bar_Options, Label_Options, Tick_Options, Ticklabel_Options
43 4 ▶use Chart::Graph::Xmgrace::Axis_Options;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 12 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
46 12 my $self = shift;
47 12 my $type_of_axis = shift; #xaxis, yaxis, altxaxis, altyaxis
48 12 $self->{name} = $type_of_axis;
49 12 $self->{print_order} = ["status", "type zero", "offset", "bar options",
50 "label options", "tick options","ticklabel options"];
51 12 $self->{length} = 4;
52 $self->{options} = {
53 12 "status" => "on",
54 "type zero" => "false",
55 "offset" => ["0.000000","0.000000"],
56 "bar options" => new Chart::Graph::Xmgrace::Bar_Options,
57 "label options" => new Chart::Graph::Xmgrace::Label_Options,
58 "tick options" => new Chart::Graph::Xmgrace::Tick_Options,
59 "ticklabel options" => new Chart::Graph::Xmgrace::Ticklabel_Options,
60 };
61 }
62  
63 0 ▶sub type_zero ($$) {
Subroutine type_zero: not called CC=1 SCAR=6.9
Pod undocumented
64 0 $self = shift;
65 0 $val = shift;
66 0 $self->{options}->{"type zero"} = $val;
67 0 return 1;
68 }
69  
70 0 ▶sub bar_options ($) {
Subroutine bar_options: not called CC=1 SCAR=6.9
Pod undocumented
71 0 $self = shift;
72 0 return $self->{options}->{"bar options"};
73 }
74  
75 8 ▶sub label_options ($) {
Subroutine label_options: called CC=1 SCAR=0.0
Pod undocumented
76 8 $self = shift;
77 8 return $self->{options}->{"label options"};
78 }
79  
80 0 ▶sub tick_options ($) {
Subroutine tick_options: not called CC=1 SCAR=6.9
Pod undocumented
81 0 $self = shift;
82 0 return $self->{options}->{"tick options"};
83 }
84  
85 0 ▶sub ticklabel_options ($) {
Subroutine ticklabel_options: not called CC=1 SCAR=6.9
Pod undocumented
86 0 $self = shift;
87 0 return $self->{options}->{"ticklabel options"};
88 }
89  
90 4 ▶sub print($$ ) {
Subroutine print: called CC=7 SCAR=19.5
Pod undocumented
91 4 my $self = shift;
92 4 my $handle = shift;
93 4 my $string = "";
94 4 my $substr = "";
95  
96 4 foreach $option (@{ $self->{"print_order"} }) {
97 16 my $option_ref = $self->{"options"};
98  
99 16 ▶ if ($option eq "status" or $option eq "in_out_status") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq 'status' or $option eq 'in_out_status') { } 4 12 16
Condition66%2/3
$option eq "status" or $option eq "in_out_status"
l!l&&r!l&&!r
4012
MC/DC50%1/2
$option eq "status" or $option eq "in_out_status"
$option eq "status" $option eq "in_out_status"
Truth table66%2/3
A or B
A= $option eq "status"B= $option eq "in_out_status"
ABresult
1X1
011
000
100
101 # we first check the status of the axes, whether it's on/off
102 # if it's off, we don't print it out
103 4 ▶ if ($option_ref->{"status"} eq "off") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option_ref->{"status"} eq "off") 2 2 4
104 2 $string = "$self->{name} $option_ref->{$option}\n";
105 2 $self->_printline($handle, $string, $self->{"length"});
106 2 last;
107 }
108  
109 2 $string = "$self->{name} $option_ref->{$option}\n";
110 2 $self->_printline($handle, $string, $self->{"length"});
111
112 } else {
113 # print function handles both scalars and lists
114 12 ▶ if (!ref($option_ref->{$option})) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $option_ref->{$option}) { } 2 10 12
elsif (ref $option_ref->{$option} eq 'ARRAY') { } 2 8 10
115 2 $string = "$self->{name} $option $option_ref->{$option}\n";
116 2 $self->_printline($handle, $string, $self->{"length"});
117 } elsif (ref($option_ref->{$option}) eq ARRAY) {
118 2 $substr = join (", ", (@{ $option_ref->{$option} }));
119 2 $string = "$self->{name} $option $substr\n";
120 2 $self->_printline($handle, $string, $self->{"length"});
121 } else { # a blessed object, uses Axis Option print
122 8 $option_ref->{$option}->print($handle, $self->{name});
123 }
124 }
125 }
126 }
127  
128 4 1;
« Graph/Xmgrace/Axis_Option.pm ↑ Summary Graph/Xmgrace/Dataset.pm »