Bug 453883, ensure true/false marcos are available, r=joshmoz, sr=jst
[wine-gecko.git] / tools / page-loader / URLTimingGraph.pm
blob2ea9eef02bd14e01b9b9e44181ee666489f5083d
1 #
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is Mozilla page-loader test, released Aug 5, 2001.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 2001
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
23 # John Morrison <jrgm@netscape.com>, original author
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
38 package URLTimingGraph;
39 use strict;
40 use GD;
41 use GD::Graph::linespoints;
42 use GD::Graph::points;
43 use GD::Graph::lines;
44 use GD::Graph::mixed;
45 use GD::Graph::colour;
46 use GD::Graph::Data;
48 sub new {
49 my $proto = shift;
50 my $class = ref($proto) || $proto;
51 my $self = {};
52 bless ($self, $class);
53 $self->{data} = shift || die "No data.";
54 my $args = shift || {};
55 $self->{cgimode} = $args->{cgimode} || 0;
56 $self->{title} = $args->{title} || "";
57 $self->{types} = $args->{types} || ['lines', undef, undef, undef, undef, undef, undef];
58 $self->{dclrs} = $args->{dclrs} || [qw(lred)];
59 $self->{legend} = $args->{legend} || [qw(undef)];
60 $self->{y_max_value} = $args->{y_max_value} || 10000;
61 $self->{width} = $args->{width} || 800;
62 $self->{height} = $args->{height} || 720;
63 return $self;
66 sub _set_standard_options {
67 my $self = shift;
68 $self->{graph}->set(
69 x_label => '',
70 y_label => 'Page Load Time (msec)',
71 default_type => 'points',
72 x_labels_vertical => 1,
73 y_long_ticks => 1,
74 x_tick_length => 8,
75 x_long_ticks => 0,
76 line_width => 2,
77 marker_size => 3,
78 markers => [8],
79 show_values => 0,
80 transparent => 0,
81 interlaced => 1,
82 skip_undef => 1,
84 || warn $self->{graph}->error;
85 $self->{graph}->set_title_font(GD::Font->Giant);
86 $self->{graph}->set_x_label_font(GD::Font->Large);
87 $self->{graph}->set_y_label_font(GD::Font->Large);
88 $self->{graph}->set_x_axis_font(GD::Font->Large);
89 $self->{graph}->set_y_axis_font(GD::Font->Large);
90 $self->{graph}->set_legend_font(GD::Font->Giant);
93 sub plot {
94 my $self = shift;
95 $self->{graph} = new GD::Graph::mixed($self->{width},
96 $self->{height});
97 $self->_set_standard_options();
99 $self->{graph}->set(title => $self->{title},
100 types => $self->{types},
101 y_max_value => $self->{y_max_value},
102 dclrs => $self->{dclrs},
104 || warn $self->{graph}->error;
106 $self->{graph}->set_legend( @{$self->{legend}} );
108 # draw the graph image
109 $self->{graph}->plot($self->{data}) ||
110 die $self->{graph}->error;
112 # send it back to stdout (or browser)
113 print "Content-type: image/png\n\n" if $self->{cgimode};
114 binmode STDOUT;
115 print $self->{graph}->gd->png();
119 1; #return true