Diagram2D/Label.pm

filter: Statementstmt 27.4% 14 / 51 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 26.0% 18 / 69 CC 5 SCAR 17.6
CC
5
Cov
24%
new
12.0
set_color
6.0
plot
6.0
CRAP 5.8
« Diagram2D/Polyline.pm ↑ Summary
1  
2 package LaTeX::PGF::Diagram2D::Label;
3  
4 1 ▶use 5.000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @ISA = qw();
11  
12 1 our $VERSION = '1.00';
13  
14  
15 # Arguments:
16 # - diagram
17 # - x
18 # - y
19 # - text
20 # - (position)
21  
22 sub new
23 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
24 0 my $self = undef;
25  
26 0 ▶ if($#_ < 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 6) { } 0 0 0
27 0 croak "Usage: LaTeX::PGF::Diagram2D::Label->new(diagram, xaxis, yaxis, x, y, text[, pos])";
28 } else {
29 0 my $class = shift;
30 0 my $diagram = shift;
31 0 my $ax = shift;
32 0 my $ay = shift;
33 0 my $x = shift;
34 0 my $y = shift;
35 0 my $t = shift;
36 0 my $p = undef;
37 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
38 0 $p = shift;
39 }
40 $self = {
41 0 'x' => $x, # X position
42 'y' => $y, # Y position
43 't' => $t, # Text
44 'p' => $p, # Alignment
45 'd' => $diagram, # Diagram
46 'c' => 'black', # Color
47 'ax' => $ax, # X axis
48 'ay' => $ay, # Y axis
49 };
50 0 bless($self, $class);
51 }
52 0 return $self;
53 }
54  
55  
56  
57 sub set_color
58 0 ▶{
Subroutine set_color: not called CC=2 SCAR=17.9
Pod undocumented
59 0 my $self = undef;
60 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
61 0 croak "Usage: \$polyline->set_color(color)";
62 } else {
63 0 $self = shift; $self->{'c'} = shift;
64 }
65 0 return $self;
66 }
67  
68  
69  
70 sub plot
71 0 ▶{
Subroutine plot: not called CC=2 SCAR=17.9
Pod undocumented
72 0 my $self = shift;
73 0 my $d = $self->{'d'};
74 my $x = $d->value_to_coord(
75 0 $self->{'ax'}, $self->{'ay'}, $self->{'x'}, 0
76 );
77 my $y = $d->value_to_coord(
78 0 $self->{'ax'}, $self->{'ay'}, $self->{'y'}, 1
79 );
80 0 my $fh = $d->{'f1'};
81 0 $d->set_color($self->{'c'});
82 0 print $fh "\\pgftext[at={";
83 0 $d->write_point($x, $y);
84 0 print $fh "}";
85 0 ▶ if(defined($self->{'p'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"p"}) 0 0 0
86 0 print $fh "," . $self->{'p'};
87 }
88 0 print $fh "]{";
89 0 print $fh "" . $self->{'t'};
90 0 print $fh "}";
91 0 return $self;
92 }
93  
94  
95  
96 1 1;
97 __END__
« Diagram2D/Polyline.pm ↑ Summary