blib/lib/CXC/Gnuplot/V1/MultiPlot.pm

filter: Statementstmt 75.0% 6 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 81.8% 9 / 11 CC 1 SCAR 0.9
CC
1
Cov
75%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/CXC/Gnuplot/V1/Label.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/MultiPlot/Title.pm »
1 package CXC::Gnuplot::V1::MultiPlot;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental 'builtin', 'declared_refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Object::Pad 0.821;
Subroutine BEGIN: called CC=1 SCAR=2.6
6  
7 our $VERSION = 'v0.29.3';
8  
9 class CXC::Gnuplot::V1::MultiPlot : isa(CXC::Gnuplot::V1::Base)
10 does( CXC::Gnuplot::V1::Role::Clone );
11  
12 use builtin 'true', 'false';
13  
14 use CXC::Gnuplot::V1::Util
15 -lexical => 'maybe_quote',
16 'pvalidate', 'pvalidate_xy_pair', 'to_hash_r',
17 'render_opts', 'render_set', 'flatten_array';
18  
19 use CXC::Gnuplot::V1::Types
20 -lexical => 'Dict',
21 'Enum',
22 'Maybe',
23 'MultiPlotLayout',
24 'Num',
25 'Optional',
26 'SetFormats',
27 'signature_for';
28  
29 no namespace::clean;
30  
31 use Ref::Util 'is_hashref';
32  
33 use constant XYPair => Num | Dict [ x => Num, y => Optional [ Maybe [Num] ] ];
34  
35 use namespace::clean;
36  
37 my sub croak {
38 require Carp;
39 goto \&Carp::croak;
40 }
41  
42 #<<< no tidy
43 field $title :param :reader = undef;
44 field $layout :param :reader = undef;
45 field $order :param :reader = undef;
46 field $direction :param :reader = undef;
47 field $scale :param :reader = undef;
48 field $offset :param :reader = undef;
49 field $margins :param :reader = undef;
50 field $spacing :param :reader = undef;
51 #>>>
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77 ADJUST {
78  
79 pvalidate( title => 'MultiPlot::Title' => \$title );
80 pvalidate( margins => 'MultiPlot::Margins' => \$margins );
81  
82 pvalidate_xy_pair( spacing => XYPair, \$spacing );
83 defined $spacing
84 and !defined $spacing->{y}
85 and delete $spacing->{y};
86  
87 pvalidate_xy_pair( offset => XYPair, \$offset );
88 defined $offset
89 and !defined $offset->{y}
90 and delete $offset->{y};
91  
92 pvalidate_xy_pair( scale => XYPair, \$scale );
93 defined $scale
94 and !defined $scale->{y}
95 and delete $scale->{y};
96  
97 pvalidate( order => Enum [ 'rowsfirst', 'columnsfirst' ], \$order );
98 pvalidate( direction => Enum [ 'downwards', 'upwards' ], \$direction );
99  
100 pvalidate( layout => MultiPlotLayout, \$layout );
101 }
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121 method to_hash {
122  
123 to_hash_r( {
124 ( defined $title ? ( title => $title ) : () ),
125 ( defined $layout ? ( layout => { $layout->%* } ) : () ),
126 ( defined $order ? ( order => $order ) : () ),
127 ( defined $direction ? ( direction => $direction ) : () ),
128 ( defined $scale ? ( scale => $scale ) : () ),
129 ( defined $offset ? ( offset => $offset ) : () ),
130 ( defined $margins ? ( margins => $margins ) : () ),
131 ( defined $spacing ? ( spacing => $spacing ) : () ),
132 } );
133 }
134  
135  
136  
137  
138  
139  
140 signature_for opts => (
141 method => 1,
142 named => [
143 as => SetFormats,
144 { default => 'array' },
145 ],
146 );
147  
148 method opts ( $opt ) {
149  
150 my @opts;
151  
152 push @opts, render_opts( title => $title );
153  
154 if ( defined $layout ) {
155  
156 push @opts, [ layout => join( q{,}, $layout->{nrows}, $layout->{ncols} ) ];
157  
158 defined $order
159 and push @opts, $order;
160  
161 defined $direction
162 and push @opts, $direction;
163  
164 defined $scale
165 and push @opts, [ scale => join( q{,}, grep defined, $scale->@{ 'x', 'y' } ) ];
166  
167 defined $offset
168 and push @opts, [ offset => join( q{,}, grep defined, $offset->@{ 'x', 'y' } ) ];
169  
170 push @opts, render_opts( margins => $margins );
171  
172 defined $spacing
173 and push @opts, [ spacing => join( q{,}, grep defined, $spacing->@{ 'x', 'y' } ) ];
174 }
175  
176  
177 return
178 $opt->as eq 'array' ? @opts
179 : $opt->as eq 'flatten_array' ? map { flatten_array( $_ ) } @opts
180 : $opt->as eq 'string' ? join q{ }, map { flatten_array( $_ )->@* } @opts
181 : croak( 'unknown format: ' . $opt->as );
182 }
183  
184  
185  
186  
187  
188 signature_for set => (
189 method => 1,
190 named => [
191 as => SetFormats,
192 { default => 'string' },
193 ],
194 );
195  
196 method set ( $opt ) {
197 return render_set( [ render_opts( [ set => 'multiplot' ], $self ) ], $opt->as );
198 }
199  
200 1;
201  
202 #
203 # This file is part of CXC-Gnuplot
204 #
205 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
206 #
207 # This is free software, licensed under:
208 #
209 # The GNU General Public License, Version 3, June 2007
210 #
211  
212 __END__
« blib/lib/CXC/Gnuplot/V1/Label.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/MultiPlot/Title.pm »