Merge branch 'topic/related_stock_datatables' into topic/trials_from_seedlots
[sgn.git] / lib / CXGN / ZPL.pm
blob6c163c6ced7a943692c08348c88714aa27e7a42a
2 package CXGN::ZPL;
4 use Moose;
7 has 'font' => ( is => 'rw',
8 isa => 'Str',
9 default => 'xyz',
12 has 'orientation' => ( is => 'rw',
13 isa => 'Str',
14 default => '',
18 has 'print_quality' => ( is => 'rw',
19 isa => 'Str',
20 default=> '',
23 has 'print_orientation' => ( is => 'rw',
24 isa => 'Str',
25 default => 'N',
28 has 'units_of_measurement' => ( is => 'rw',
29 isa => 'Str',
30 default => 'D',
33 has 'print_width' => ( is => 'rw',
34 isa => 'Int',
37 has 'label_length' => ( is => 'rw',
38 isa => 'Int',
41 has 'dots_per_millimeter' => ( is => 'rw',
42 isa => 'Int',
45 has 'command_list' => ( is => 'rw',
46 isa => 'ArrayRef',
49 has 'field_typeset' => ( is => 'rw',
50 isa => 'ArrayRef',
53 has 'field_default_height' => ( is => 'rw',
54 isa => 'Int',
55 default => 10,
58 has 'field_default_width' => ( is => 'rw',
59 isa => 'Int',
60 default => 2,
63 has 'field_default_ratio' => ( is => 'rw',
64 isa => 'Num',
65 default => 3.0,
68 sub graphic_symbol {
69 my $self = shift;
70 my ($o, $h, $w) = @_;
72 $self->add("^GS$o,$h,$w");
76 sub bar_code_field_default {
77 my $self =shift;
78 my ($w, $r, $h) = @_;
79 $self->field_default_width($w);
80 $self->field_default_ration($r);
81 $self->field_default_height($h);
84 sub graphic_box {
88 sub comment {
92 sub graphic_ellipse {
96 sub graphic_diagonal_line {
101 sub graphic_circle {
105 sub field_orientation {
108 sub field_origin {
112 sub field_data {
116 sub mirror_image {
117 my $self = shift;
118 my $mirror = shift;
119 die if ($mirror !~ /y|n/i);
120 $self->add("^PM$mirror");
123 sub barcode_code128 {
124 my $self = shift;
125 my ($o, $h, $f, $g, $e, $m) = @_;
127 if (!defined($o)) { $o = $self->print_orientation(); }
128 if (!defined($h)) { $h = $self->field_default_height(); }
129 if (!defined($f)) { $f = ''; }
130 if (!defined($g)) { $g = ''; }
131 if (!defined($e)) { $e = ''; }
132 if (!defined($m)) { $m = ''; }
134 $self->add("^BC$o,$h,$f,$g,$e,$m");
138 sub start_format {
139 my $self = shift;
141 $self->add("^XA");
146 sub end_format {
147 my $self = shift;
148 $self->add("^XZ");
152 sub add {
153 my $self = shift;
154 my $command = shift;
156 my $command_list = $self->command_list();
157 push @$command_list, $command;
158 $self->command_list($command_list);
162 sub render {
163 my $self = shift;
165 my $zpl = "";
166 foreach my $c (@{$self->command_list()}) {
167 $zpl .= "$c\n";
169 return $zpl;