All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.printer.zpl2.labelCmd.barcode.ZplDataMatrixBarCode Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
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.Millimeters;
import com.hfg.printer.zpl2.ZplDocument;
import com.hfg.printer.zpl2.labelCmd.ZplLabelCmdImpl;
import com.hfg.printer.zpl2.ZplOrientation;

//------------------------------------------------------------------------------
/**
 ZPL data matrix 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 ZplDataMatrixBarCode extends ZplLabelCmdImpl { private static final String CMD = "^BX"; private ZplOrientation mOrientation; private int mSymbolHeight = sDefaultSymbolHeight; private Integer mQuality = sDefaultQuality; private Integer mAspectRatio; private static int sDefaultSymbolHeight = 8; private static Integer sDefaultQuality = 200; //########################################################################### // CONSTRUCTORS //########################################################################### //-------------------------------------------------------------------------- public ZplDataMatrixBarCode() { } //-------------------------------------------------------------------------- public ZplDataMatrixBarCode(ZplOrientation inOrientation, int inSymbolHeight) { setOrientation(inOrientation); mSymbolHeight = inSymbolHeight; } //-------------------------------------------------------------------------- public ZplDataMatrixBarCode(int inSymbolHeightInDots) { mSymbolHeight = inSymbolHeightInDots; } //########################################################################### // PUBLIC METHODS //########################################################################### //-------------------------------------------------------------------------- public ZplDataMatrixBarCode setOrientation(ZplOrientation inValue) { mOrientation = inValue; return this; } //-------------------------------------------------------------------------- public ZplOrientation getOrientation() { return mOrientation; } //-------------------------------------------------------------------------- public ZplDataMatrixBarCode setSymbolHeight(int inValue) { mSymbolHeight = inValue; return this; } //-------------------------------------------------------------------------- public int getSymbolHeight() { return mSymbolHeight; } //-------------------------------------------------------------------------- public ZplDataMatrixBarCode setQuality(Integer inValue) { mQuality = inValue; return this; } //-------------------------------------------------------------------------- public Integer getQuality() { return mQuality; } //-------------------------------------------------------------------------- public ZplDataMatrixBarCode useRectangularAspectRatio() { mAspectRatio = 2; return this; } //-------------------------------------------------------------------------- @Override public ZplLabelCmdImpl setDoc(ZplDocument inValue) { super.setDoc(inValue); GfxContext gfxContext = new GfxContext(inValue.getResolution()); // if (mSymbolHeight != null) // { // mSymbolHeight.setGfxContext(gfxContext); // } return this; } //-------------------------------------------------------------------------- @Override public void toZPL(Writer inWriter) throws IOException { // ^BXo,h,s,c,r,f,g // o = orientation (N, R, I, B) // h = height of single bar code symbol block // s = quality level // c = columns to encode (9 - 49) TODO // r = rows to encode (9 - 49) TODO // f = format ID (0 - 6) TODO // g = esc sequence control char TODO // a = aspect ratio (1 = square, 2 = rect) inWriter.write(CMD); inWriter.write(buildZplParamList(mOrientation != null ? mOrientation.getAbbrev() : null, mSymbolHeight, mQuality, null, null, null, null, mAspectRatio)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy