com.hfg.printer.zpl2.labelCmd.barcode.ZplCode93BarCode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.printer.zpl2.labelCmd.barcode;
import java.io.IOException;
import java.io.Writer;
import com.hfg.graphics.units.GfxContext;
import com.hfg.graphics.units.GfxSize;
import com.hfg.graphics.units.GfxUnits;
import com.hfg.graphics.units.Millimeters;
import com.hfg.printer.zpl2.ZplDocument;
import com.hfg.printer.zpl2.ZplOrientation;
import com.hfg.printer.zpl2.labelCmd.ZplLabelCmdImpl;
//------------------------------------------------------------------------------
/**
ZPL Code 93 bar code label command.
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class ZplCode93BarCode extends ZplLabelCmdImpl
{
private static final String CMD = "^BA";
private ZplOrientation mOrientation;
private GfxSize mHeight = sDefaultHeight;
private Boolean mPrintInterpretationLine;
private Boolean mPrintInterpretationLineAboveCode;
private Boolean mPrintCheckDigit;
private static GfxSize sDefaultHeight = new Millimeters(0.5f);
//###########################################################################
// CONSTRUCTORS
//###########################################################################
//--------------------------------------------------------------------------
public ZplCode93BarCode()
{
}
//--------------------------------------------------------------------------
public ZplCode93BarCode(ZplOrientation inOrientation, GfxSize inHeight)
{
setOrientation(inOrientation);
mHeight = inHeight;
}
//--------------------------------------------------------------------------
public ZplCode93BarCode(GfxSize inHeight)
{
mHeight = inHeight;
}
//###########################################################################
// PUBLIC METHODS
//###########################################################################
//--------------------------------------------------------------------------
public ZplCode93BarCode setOrientation(ZplOrientation inValue)
{
mOrientation = inValue;
return this;
}
//--------------------------------------------------------------------------
public ZplOrientation getOrientation()
{
return mOrientation;
}
//--------------------------------------------------------------------------
public ZplCode93BarCode setHeight(GfxSize inValue)
{
mHeight = inValue;
if (getDoc() != null)
{
mHeight.setGfxContext(new GfxContext(getDoc().getResolution()));
}
return this;
}
//--------------------------------------------------------------------------
public GfxSize getHeight()
{
return mHeight;
}
//--------------------------------------------------------------------------
public ZplCode93BarCode setPrintInterpretationLine(Boolean inValue)
{
mPrintInterpretationLine = inValue;
return this;
}
//--------------------------------------------------------------------------
public ZplCode93BarCode setPrintInterpretationLineAboveCode(Boolean inValue)
{
mPrintInterpretationLineAboveCode = inValue;
// In order to print above, general printing of the interpretation line also need to be enabled
if (inValue)
{
setPrintInterpretationLine(inValue);
}
return this;
}
//--------------------------------------------------------------------------
public ZplCode93BarCode setPrintCheckDigit(Boolean inValue)
{
mPrintCheckDigit = inValue;
return this;
}
//--------------------------------------------------------------------------
@Override
public ZplLabelCmdImpl setDoc(ZplDocument inValue)
{
super.setDoc(inValue);
GfxContext gfxContext = new GfxContext(inValue.getResolution());
if (mHeight != null)
{
mHeight.setGfxContext(gfxContext);
}
return this;
}
//--------------------------------------------------------------------------
@Override
public void toZPL(Writer inWriter)
throws IOException
{
// ^BXo,h,f,g,e
// o = orientation (N, R, I, B)
// h = bar code height
// f = print interpretation line [Y or N (default)]
// g = print interpretation line above code [Y (default) or N]
// e = print check digit [Y (default) or N]
inWriter.write(CMD);
inWriter.write(buildZplParamList(mOrientation != null ? mOrientation.getAbbrev() : null,
mHeight, mPrintInterpretationLine, mPrintInterpretationLineAboveCode, mPrintCheckDigit));
}
}