File Coverage

blib/lib/Chart/Graph/Xmgrace/Axis_Option.pm
Criterion Covered Total %
statement 37 44 84.0
branch 7 10 70.0
condition 5 12 41.6
subroutine 5 5 100.0
pod 0 2 0.0
total 54 73 73.9


line stmt bran cond sub pod time code
1             #
2             # Chart::Graph::Xmgrace::Axis_Option.pm is a base class for all the axis options
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             $VERSION = 3.2;
39              
40             package Chart::Graph::Xmgrace::Axis_Option;
41 4     4   20 use Carp;
  4         9  
  4         2718  
42              
43             sub new {
44 75     75 0 81 my $this = shift;
45 75   33     202 my $class = ref($this) || $this;
46 75         87 my $self = {};
47 75         140 bless $self, $class;
48 75         176 $self->_init(@_);
49 75         318 return $self;
50             }
51              
52             sub _printline ($$$$ ) {
53 92     92   96 my $self = shift;
54 92         114 my ($handle, $string, $length) = @_;
55              
56 92         106 print $handle "@";
57 92         110 print $handle ' ' x $length;
58 92         102 print $handle "$string";
59              
60 92         235 return 1; # just for fun
61             }
62              
63             sub print ($$$ ) {
64 2     2 0 3 my $self = shift;
65 2         4 my ($handle, $name) = @_;
66 2         3 my $string = "";
67 2         3 my $substr = "";
68              
69 2         2 foreach $option (@{ $self->{"print_order"} }) {
  2         6  
70 8         12 my $option_ref = $self->{"options"};
71              
72 8 100 66     31 if ($option eq "status" or $option eq "in_out_status") {
73            
74             # we first check the status of the option, whether it's on/off
75             # if it's off, we don't print it out
76 2 50       6 if ($option_ref->{"status"} eq "off") {
77 0         0 $string = "$name $self->{name} $option_ref->{$option}\n";
78 0         0 $self->_printline($handle, $string, $self->{"length"});
79 0         0 last;
80             }
81 2         7 $string = "$name $self->{name} $option_ref->{$option}\n";
82 2         9 $self->_printline($handle, $string, $self->{"length"});
83              
84             } else {
85            
86             # print function handles both scalars and lists
87 6 50       15 if (ref($option_ref->{$option}) eq ARRAY) {
88 0         0 $substr = join (", ", (@{ $option_ref->{$option} }));
  0         0  
89 0         0 $string = "$name $self->{name} $option $substr\n";
90             } else {
91 6         16 $string = "$name $self->{name} $option $option_ref->{$option}\n";
92             }
93 6         13 $self->_printline($handle, $string, $self->{"length"});
94             }
95             }
96             }
97              
98             sub AUTOLOAD {
99 22     22   26 my $self = shift;
100 22   33     82 my $type = ref($self) || croak "$self is not an object";
101 22         29 my $name = $AUTOLOAD;
102 22         73 $name =~ s/.*://; #strip fully-qualified portion
103 22 50 33     99 unless (($name eq "DESTROY") or (exists $self->{options}->{$name})) {
104 0         0 croak "Can't access '$name' field in object of class $type";
105             }
106              
107 22 100       41 if (@_) {
108 8         24 return $self->{options}->{$name} = shift;
109             } else {
110 14         78 return $self->{options}->{$name};
111             }
112             }
113              
114             1;