Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Barcode / Object / Code25interleaved.php
blobe02d38b7c9b3a51faae38fcac87ac87f5f8579d9
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Barcode\Object;
12 /**
13 * Class for generate Interleaved 2 of 5 barcode
15 class Code25interleaved extends Code25
17 /**
18 * Drawing of bearer bars
19 * @var bool
21 private $withBearerBars = false;
23 /**
24 * Default options for Code25interleaved barcode
25 * @return void
27 protected function getDefaultOptions()
29 $this->barcodeLength = 'even';
32 /**
33 * Activate/deactivate drawing of bearer bars
34 * @param bool $value
35 * @return Code25
37 public function setWithBearerBars($value)
39 $this->withBearerBars = (bool) $value;
40 return $this;
43 /**
44 * Retrieve if bearer bars are enabled
45 * @return bool
47 public function getWithBearerBars()
49 return $this->withBearerBars;
52 /**
53 * Width of the barcode (in pixels)
54 * @return int
56 protected function calculateBarcodeWidth()
58 $quietZone = $this->getQuietZone();
59 $startCharacter = (4 * $this->barThinWidth) * $this->factor;
60 $characterLength = (3 * $this->barThinWidth + 2 * $this->barThickWidth) * $this->factor;
61 $encodedData = strlen($this->getText()) * $characterLength;
62 $stopCharacter = ($this->barThickWidth + 2 * $this->barThinWidth) * $this->factor;
63 return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
66 /**
67 * Prepare array to draw barcode
68 * @return array
70 protected function prepareBarcode()
72 if ($this->withBearerBars) {
73 $this->withBorder = false;
76 // Start character (0000)
77 $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
78 $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
79 $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
80 $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
82 // Encoded $text
83 $text = $this->getText();
84 for ($i = 0, $len = strlen($text); $i < $len; $i += 2) { // Draw 2 chars at a time
85 $char1 = substr($text, $i, 1);
86 $char2 = substr($text, $i + 1, 1);
88 // Interleave
89 for ($ibar = 0; $ibar < 5; $ibar ++) {
90 // Draws char1 bar (fore color)
91 $barWidth = (substr($this->codingMap[$char1], $ibar, 1))
92 ? $this->barThickWidth
93 : $this->barThinWidth;
95 $barcodeTable[] = array(1, $barWidth, 0, 1);
97 // Left space corresponding to char2 (background color)
98 $barWidth = (substr($this->codingMap[$char2], $ibar, 1))
99 ? $this->barThickWidth
100 : $this->barThinWidth;
101 $barcodeTable[] = array(0, $barWidth, 0, 1);
105 // Stop character (100)
106 $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
107 $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
108 $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
109 return $barcodeTable;
113 * Drawing of bearer bars (if enabled)
115 * @return void
117 protected function postDrawBarcode()
119 if (!$this->withBearerBars) {
120 return;
123 $width = $this->barThickWidth * $this->factor;
124 $point1 = $this->rotate(-1, -1);
125 $point2 = $this->rotate($this->calculateWidth() - 1, -1);
126 $point3 = $this->rotate($this->calculateWidth() - 1, $width - 1);
127 $point4 = $this->rotate(-1, $width - 1);
128 $this->addPolygon(array(
129 $point1,
130 $point2,
131 $point3,
132 $point4,
134 $point1 = $this->rotate(
136 0 + $this->barHeight * $this->factor - 1
138 $point2 = $this->rotate(
139 $this->calculateWidth() - 1,
140 0 + $this->barHeight * $this->factor - 1
142 $point3 = $this->rotate(
143 $this->calculateWidth() - 1,
144 0 + $this->barHeight * $this->factor - $width
146 $point4 = $this->rotate(
148 0 + $this->barHeight * $this->factor - $width
150 $this->addPolygon(array(
151 $point1,
152 $point2,
153 $point3,
154 $point4,