File Coverage

blib/lib/Chart/Graph/Xmgrace/Graph_Presentation_Type.pm
Criterion Covered Total %
statement 44 61 72.1
branch 6 12 50.0
condition 1 9 11.1
subroutine 8 11 72.7
pod 0 3 0.0
total 59 96 61.4


line stmt bran cond sub pod time code
1             #
2             # Graph_Presentation_Type manages what type of graphs and what kind of presentation
3             # is used. XY graph, Xy chart, BAR graph, BAR chart.
4             #
5             # contains: Chart::Graph::Xmgrace::Graph
6             # Chart::Graph::Xmgrace::Chart
7             #
8             # things to do as of 4/2000:
9             # 1) implement Polar graph object
10             # 2) implement Smith chart object
11             # 3) implement Fixed chart object
12             #
13             ## This software product is developed by Esmond Lee and David Moore,
14             ## and copyrighted(C) 1998 by the University of California, San Diego
15             ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant,
16             ## NCR-9711092, under which part of this code was developed.
17             ##
18             ## There is no charge for this software. You can redistribute it and/or
19             ## modify it under the terms of the GNU General Public License, v. 2 dated
20             ## June 1991 which is incorporated by reference herein. This software is
21             ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY
22             ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not
23             ## infringe on any third party's intellectual property rights.
24             ##
25             ## You should have received a copy of the GNU GPL along with this program.
26             ##
27             ##
28             ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
29             ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
30             ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
31             ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF
32             ## THE POSSIBILITY OF SUCH DAMAGE.
33             ##
34             ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
35             ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
36             ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY
37             ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
38             ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED
39             ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
40             ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
41             ## ANY PATENT, TRADEMARK OR OTHER RIGHTS.
42             ##
43             ##
44             ## Contact: graph-dev@caida.org
45             ##
46             ##
47              
48             $VERSION = 3.2;
49              
50 4     4   2574 use Chart::Graph::Xmgrace::Dataset_Options;
  4         15  
  4         157  
51 4     4   39 use Chart::Graph::Xmgrace::Base_Dataset_Option;
  4         10  
  4         160  
52              
53             package Chart::Graph::Xmgrace::Graph_Presentation_Type;
54 4     4   23 use Carp;
  4         6  
  4         1799  
55              
56             sub new {
57 15     15 0 26 my $that = shift;
58 15         23 my $color = shift;
59 15         23 $color += 1;
60 15   33     72 my $class = ref($that) || $that;
61 15         300 my $self = {
62             "XY graph" => new Chart::Graph::Xmgrace::Graph("XY", $color),
63             "XY chart" => new Chart::Graph::Xmgrace::Chart("XY", $color),
64             "BAR graph" => new Chart::Graph::Xmgrace::Graph("BAR",$color),
65             "BAR chart" => new Chart::Graph::Xmgrace::Chart("BAR",$color),
66             "Polar graph" => undef,
67             "Smith chart" => undef,
68             "Fixed" => undef,
69             };
70 15         49 bless $self, $class;
71 15         43 return $self;
72             }
73              
74             sub XY_graph {
75 0     0 0 0 my $self = shift;
76 0         0 return $self->{"XY graph"};
77             }
78              
79             sub XY_chart {
80 0     0 0 0 my $self = shift;
81 0         0 return $self->{"XY chart"};
82             }
83              
84             sub AUTOLOAD {
85 0     0   0 my $self = shift;
86 0   0     0 my $type = ref($self) || croak "$self is not an object";
87 0         0 my $name = $AUTOLOAD;
88 0         0 $name =~ s/.*://; #strip fully-qualified portion
89 0 0 0     0 unless (($name eq "DESTROY") or (exists $self->{$name})) {
90 0         0 croak "Can't access '$name' field in object of class $type";
91             }
92              
93 0 0       0 if (@_) {
94 0         0 return $self->{$name} = shift;
95             } else {
96 0         0 return $self->{$name};
97             }
98             }
99              
100             package Chart::Graph::Xmgrace::Graph;
101 4     4   29 use Carp;
  4         8  
  4         1457  
102             @ISA = qw(Chart::Graph::Xmgrace::Base_Dataset_Option);
103              
104             sub _init {
105 30     30   38 my $self = shift;
106 30         51 my ($type, $color) = @_;
107 30         154 $self->{type} = $type;
108 30         110 $self->{print_order} = ["hidden","type","symbol","line","baseline",
109             "dropline","fill","avalue","errorbar","comment",
110             "legend"],
111             $self->{length} = 4;
112 30         147 $self->{options} = {
113             "hidden" => "false",
114             "type" => "$type",
115             "symbol" => new Chart::Graph::Xmgrace::Symbol_Options($color),
116             "line" => new Chart::Graph::Xmgrace::Line_Options($color),
117             "baseline" => new Chart::Graph::Xmgrace::Baseline_Options($color),
118             "dropline" => new Chart::Graph::Xmgrace::Dropline_Options($color),
119             "fill" => new Chart::Graph::Xmgrace::Fill_Options($color),
120             "avalue" => new Chart::Graph::Xmgrace::Avalue_Options($color),
121             "errorbar" => new Chart::Graph::Xmgrace::Errorbar_Options($color),
122             "comment" => "",
123             "legend" => "",
124             };
125              
126 30 100       110 if ($type eq "XY") {
    50          
127 15         41 return 1;
128             } elsif ($type eq "BAR") {
129 15         1617 $self->symbol->fill_pattern("1");
130 15         227 $self->symbol->color("1");
131 15         438 $self->line->type("0");
132 15         38 return 1;
133             } else {
134 0         0 carp "Warning: Invalid graph type\n";
135 0         0 return 0;
136             }
137             }
138              
139             package Chart::Graph::Xmgrace::Chart;
140 4     4   24 use Carp;
  4         6  
  4         1614  
141             @ISA = qw(Chart::Graph::Xmgrace::Base_Dataset_Option);
142              
143             sub _init {
144 30     30   40 my $self = shift;
145 30         49 my ($type, $color) = @_;
146 30         82 $self->{type} = $type;
147 30         127 $self->{print_order} = ["hidden","type","symbol","line","baseline",
148             "dropline","fill","avalue","errorbar","comment",
149             "legend"],
150             $self->{length} = 4;
151              
152 30         115 $self->{options} = {
153             "hidden" => "false",
154             "type" => "$type",
155             "symbol" => new Chart::Graph::Xmgrace::Symbol_Options($color),
156             "line" => new Chart::Graph::Xmgrace::Line_Options($color),
157             "baseline" => new Chart::Graph::Xmgrace::Baseline_Options($color),
158             "dropline" => new Chart::Graph::Xmgrace::Dropline_Options($color),
159             "fill" => new Chart::Graph::Xmgrace::Fill_Options($color),
160             "avalue" => new Chart::Graph::Xmgrace::Avalue_Options($color),
161             "errorbar" => new Chart::Graph::Xmgrace::Errorbar_Options($color),
162             "comment" => "",
163             "legend" => "",
164             };
165              
166 30 100       96 if ($type eq "XY") {
    50          
167 15         36 return 1;
168             } elsif ($type eq "BAR") {
169 15         115 $self->symbol->fill_pattern("1");
170 15         68 $self->symbol->pattern("0");
171 15         76 $self->line->type("0");
172 15         36 return 1;
173             } else {
174 0           carp "Warning: Invalid graph type\n";
175 0           return 0;
176             }
177             }
178            
179             1;