Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
Signed-off-by:Teddy Dona <[email protected]>
  • Loading branch information
teddy-dubal committed Jul 16, 2016
1 parent 2bbb61a commit 82c46c1
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 41 deletions.
4 changes: 3 additions & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path=vendor/bin/phpunit
auxiliary.org-netbeans-modules-php-phpunit.test_2e_groups_2e_ask=false
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false
browser.reload.on.save=true
include.path=${php.global.include.path}
include.path=\
${php.global.include.path}
php.version=PHP_56
project.license=mit
source.encoding=UTF-8
src.dir=.
tags.asp=false
Expand Down
1 change: 0 additions & 1 deletion src/Weez/Zpl/Model/Element/ZebraAFontElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Weez\Zpl\Model\Element;

use Weez\Zpl\Constant\ZebraRotation;
use Weez\Zpl\Model\PrinterOptions;
use Weez\Zpl\Model\ZebraElement;
use Weez\Zpl\Utils\ZplUtils;

Expand Down
4 changes: 1 addition & 3 deletions src/Weez/Zpl/Model/Element/ZebraBarCode128.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Weez\Zpl\Model\Element;

use Weez\Zpl\Constant\ZebraRotation;
use Weez\Zpl\Utils\ZplUtils;

/**
Expand All @@ -13,8 +12,7 @@
* @author matthiasvets
*
*/
class ZebraBarCode128 extends ZebraBarCode
{
class ZebraBarCode128 extends ZebraBarCode {

private $checkDigit43 = false;
/**
Expand Down
4 changes: 1 addition & 3 deletions src/Weez/Zpl/Model/Element/ZebraBarCode39.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Weez\Zpl\Model\Element;

use Weez\Zpl\Constant\ZebraRotation;
use Weez\Zpl\Utils\ZplUtils;

/**
Expand All @@ -13,8 +12,7 @@
* @author ttropard
*
*/
class ZebraBarCode39 extends ZebraBarCode
{
class ZebraBarCode39 extends ZebraBarCode {

private $checkDigit43 = false;
/**
Expand Down
3 changes: 1 addition & 2 deletions src/Weez/Zpl/Model/Element/ZebraGraficBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function __construct($positionX, $positionY, $width, $height, $borderTick
/* (non-Javadoc)
* @see fr.w3blog.zpl.model.element.ZebraElement#getZplCode(fr.w3blog.zpl.model.PrinterOptions)
*/
public function getZplCode($printerOptions)
{
public function getZplCode($printerOptions = null) {
$zpl = '';
$zpl .= $this->getZplCodePosition();
$zpl .= "\n";
Expand Down
19 changes: 9 additions & 10 deletions src/Weez/Zpl/Model/Element/ZebraText.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class ZebraText extends ZebraElement
* @param type $zebraFont
* @param type $zebraRotation
*/
public function __construct($text, $positionX, $positionY, $fontSize = null, $zebraFont = null, $zebraRotation = null)
{
public function __construct($positionX, $positionY, $text, $fontSize = null, $zebraFont = null, $zebraRotation = null) {
$this->zebraFont = $zebraFont;
$this->fontSize = $fontSize;
$this->zebraRotation = $zebraRotation ? : new ZebraRotation(ZebraRotation::NORMAL);
Expand All @@ -51,20 +50,20 @@ public function __construct($text, $positionX, $positionY, $fontSize = null, $ze
* @see fr.w3blog.zpl.model.element.ZebraElement#getZplCode(fr.w3blog.zpl.model.PrinterOptions)
*/

public function getZplCode($printerOptions = null)
{
public function getZplCode($_printerOptions = null) {
$printerOptions = $_printerOptions? : $this->printerOptions;
$zpl = '';
$zpl .= $this->getZplCodePosition();

if ($this->fontSize != null && $this->zebraFont != null) {
if (!is_null($this->fontSize) && !is_null($this->zebraFont)) {
//This element has specified size and font
$dimension = ZplUtils::extractDotsFromFont($this->zebraFont, $this->fontSize, $this->printerOptions->getZebraPPP());
$dimension = ZplUtils::extractDotsFromFont($this->zebraFont, $this->fontSize, $printerOptions->getZebraPPP());
$zpl .= ZplUtils::zplCommand("A", [$this->zebraFont->getLetter() . $this->zebraRotation->getLetter(),
$dimension[0], $dimension[1]]);
} else if ($this->fontSize != null && $this->printerOptions->getDefaultZebraFont() != null) {
} else if (!is_null($this->fontSize) && !is_null($printerOptions->getDefaultZebraFont())) {
//This element has specified size, but with default font
$dimension = ZplUtils::extractDotsFromFont($this->printerOptions->getDefaultZebraFont(), $this->fontSize, $this->printerOptions->getZebraPPP());
$zpl .= ZplUtils::zplCommand("A", [$this->printerOptions->getDefaultZebraFont()->getLetter() . $this->zebraRotation->getLetter(),
$dimension = ZplUtils::extractDotsFromFont($printerOptions->getDefaultZebraFont(), $this->fontSize, $printerOptions->getZebraPPP());
$zpl .= ZplUtils::zplCommand("A", [$printerOptions->getDefaultZebraFont()->getLetter() . $this->zebraRotation->getLetter(),
$dimension[0], $dimension[1]]);
}

Expand Down
20 changes: 18 additions & 2 deletions src/Weez/Zpl/Model/ZebraLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ class ZebraLabel
* Height explain in dots
*/
private $heightDots;

/**
*
* @var ZebraPrintMode
*/
private $zebraPrintMode;

/**
*
* @var PrinterOptions
*/
private $printerOptions;
private $zebraElements = [];

Expand All @@ -50,7 +60,7 @@ public function __construct($widthDots = null, $heightDots = null, $printerOptio
* Element is abstract, you should use one of child Element( ZebraText, ZebraBarcode, etc)
*
* @param zebraElement
* @return
* @return self
*/
public function addElement($zebraElement)
{
Expand All @@ -62,7 +72,7 @@ public function addElement($zebraElement)
* Use to define a default Zebra font on the label
*
* @param defaultZebraFont
* the defaultZebraFont to set
* @return self
*/
public function setDefaultZebraFont($defaultZebraFont)
{
Expand Down Expand Up @@ -105,6 +115,10 @@ public function setHeightDots($heightDots)
return $this;
}

/**
*
* @return PrinterOptions
*/
public function getPrinterOptions()
{
return $this->printerOptions;
Expand All @@ -113,6 +127,7 @@ public function getPrinterOptions()
public function setPrinterOptions($printerOptions)
{
$this->printerOptions = $printerOptions;
return $this;
}

/**
Expand Down Expand Up @@ -148,6 +163,7 @@ public function getZebraElements()
public function setZebraElements($zebraElements)
{
$this->zebraElements = $zebraElements;
return $this;
}

public function getZplCode()
Expand Down
2 changes: 1 addition & 1 deletion src/Weez/Zpl/Utils/ZplUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function extractDotsFromFont($zebraFont, $fontSize, $zebraPPP)
{
$tab = [];

if (ZebraFont::ZEBRA_ZERO == $zebraFont && ZebraPPP::DPI_300 == $zebraPPP) {
if (ZebraFont::ZEBRA_ZERO == $zebraFont->getLetter() && ZebraPPP::DPI_300 == $zebraPPP) {
//We use ratio to converted (based on ratio used by Zebra Designer Tools)
$tab[0] = round($fontSize * 4.16); //Heigth
$tab[1] = round($fontSize * 4.06); //With
Expand Down
4 changes: 4 additions & 0 deletions src/nbproject/private/private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
</project-private>
35 changes: 17 additions & 18 deletions tests/Weez/Zpl/Model/ZebraLabelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,23 @@ public function testZebraLabelSize()
public function testZplOutput2()
{
$zebraLabel = new ZebraLabel(912, 912);
// $zebraLabel->setDefaultZebraFont(ZebraFont::ZEBRA_ZERO);

// $zebraLabel->addElement(new ZebraText(10, 84, "Product:", 14));
// $zebraLabel->addElement(new ZebraText(395, 85, "Camera", 14));
//
// $zebraLabel->addElement(new ZebraText(10, 161, "CA201212AA", 14));
//
// //Add Code Bar 39
// $zebraLabel->addElement(new ZebraBarCode39(10, 297, "CA201212AA", 118, 2, 2));
//
// $zebraLabel->addElement(new ZebraText(10, 365, "Qté:", 11));
// $zebraLabel->addElement(new ZebraText(180, 365, "3", 11));
// $zebraLabel->addElement(new ZebraText(317, 365, "QA", 11));
//
// $zebraLabel->addElement(new ZebraText(10, 520, "Ref log:", 11));
// $zebraLabel->addElement(new ZebraText(180, 520, "0035", 11));
// $zebraLabel->addElement(new ZebraText(10, 596, "Ref client:", 11));
// $zebraLabel->addElement(new ZebraText(180, 599, "1234", 11));
$zebraLabel->setDefaultZebraFont(new ZebraFont(ZebraFont::ZEBRA_ZERO));
$zebraLabel->addElement(new ZebraText(10, 84, "Product:", 14));
$zebraLabel->addElement(new ZebraText(395, 85, "Camera", 14));

$zebraLabel->addElement(new ZebraText(10, 161, "CA201212AA", 14));

//Add Code Bar 39
$zebraLabel->addElement(new ZebraBarCode39(10, 297, "CA201212AA", 118, 2, 2));

$zebraLabel->addElement(new ZebraText(10, 365, "Qté:", 11));
$zebraLabel->addElement(new ZebraText(180, 365, "3", 11));
$zebraLabel->addElement(new ZebraText(317, 365, "QA", 11));

$zebraLabel->addElement(new ZebraText(10, 520, "Ref log:", 11));
$zebraLabel->addElement(new ZebraText(180, 520, "0035", 11));
$zebraLabel->addElement(new ZebraText(10, 596, "Ref client:", 11));
$zebraLabel->addElement(new ZebraText(180, 599, "1234", 11));
echo $zebraLabel->getZplCode();
exit;
$this->assertEquals(1, 1);
Expand Down

0 comments on commit 82c46c1

Please sign in to comment.