PrinterAttributes

发布时间 2023-06-29 14:12:05作者: 一颗苹果!!
package com.android.bluetooth.print;

import android.os.Parcel;
import android.os.Parcelable;

import com.android.bluetooth.print.PrinterConfigs;

import java.util.Map;

/**
* Created by guangyi.peng on 2017/2/27.
*/
public class PrinterAttributes implements Parcelable {
public final static String KEY_ALIGN = "key_attributes_align";//text align
public final static String KEY_TEXTSIZE = "key_attributes_textsize";
public final static String KEY_TYPEFACE = "key_attributes_typeface";
public final static String KEY_MARGINLEFT = "key_attributes_marginleft";
public final static String KEY_MARGINRIGHT = "key_attributes_marginright";
public final static String KEY_MARGINTOP = "key_attributes_margintop";
public final static String KEY_MARGINBOTTOM = "key_attributes_marginbottom";
public final static String KEY_LINESPACE = "key_attributes_linespace";
public final static String KEY_WEIGHT = "key_attributes_weight";
public final static String KEY_PAPERWIDTH = "key_attributes_paperwidth";
public final static String KEY_UNDERLINE = "key_attributes_underline";
public final static String KEY_TEXTSCALEX = "key_attributes_textscalex";
public final static String KEY_LETTERSPACING = "key_attributes_letterspacing";
//XCSW GuoYanjie add for BarcodeCommand start
public final static String KEY_BARALIGN = "key_attributes_baraligh";
public final static String KEY_BARWIDTH = "key_attributes_barwidth";
public final static String KEY_BARHEIGHT = "key_attributes_barheight";
public final static String KEY_BARHRIPOS = "key_attributes_barhripos";
public final static String KEY_BARFORMAT = "key_attributes_barformat";
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
public final static String KEY_QRSIZE = "key_attributes_qrsize";
public final static String KEY_QRERROR = "key_attributes_qrsize";
public final static String KEY_QRSAVE = "key_attributes_qrsave";
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
public final static String KEY_REVERSE = "key_attributes_reverse";
public final static String KEY_CODETABLE = "key_attributes_codetable";
public final static String KEY_DOUBLESTRIKE = "key_attributes_doublestrike";
public final static String KEY_FONT_TYPE = "key_font_type";
//XCSW GuoYanjie add for PrinterCommand end

public final static int DEF_PRINTER_ATTRIBUTES_TYPEFACE = 0;
private final static int DEF_PRINTER_ATTRIBUTES_ALIGN = 0;
public final static int DEF_PRINTER_ATTRIBUTES_TEXTSIZE = 24;
private final static int DEF_PRINTER_ATTRIBUTES_MARGINLEFT = 0;
private final static int DEF_PRINTER_ATTRIBUTES_MARGINRIGHT = 0;
private final static int DEF_PRINTER_ATTRIBUTES_MARGINTOP = 0;
private final static int DEF_PRINTER_ATTRIBUTES_MARGINBOTTOM = 0;
private final static int DEF_PRINTER_ATTRIBUTES_LINESPACE = 4;
private final static int DEF_PRINTER_ATTRIBUTES_WEIGHT = 1;
private final static int DEF_PRINTER_ATTRIBUTES_PAPERWIDTH = PrinterConfigs.CONFIG_PRINTER_PAPER_WIDTH;
private final static int DEF_PRINTER_ATTRIBUTES_UNDERLINE = 0;
private final static float DEF_PRINTER_ATTRIBUTES_TEXTSCALEX = 1;
private final static float DEF_PRINTER_ATTRIBUTES_LETTERSPACING = 0;
//XCSW GuoYanjie add for BarcodeCommand start
private final static int DEF_PRINTER_ATTRIBUTES_BARCODE_ALIGN = 0;
private final static int DEF_PRINTER_ATTRIBUTES_BARCODE_WIDTH = PrinterConfigs.CONFIG_PRINTER_BAR_WIDTH;
private final static int DEF_PRINTER_ATTRIBUTES_BARCODE_HEIGHT = 162;
private final static int DEF_PRINTER_ATTRIBUTES_BARCODE_HRIPOS = PrinterConfigs.CONFIG_PRINTER_HRI_POSITION;
private final static int DEF_PRINTER_ATTRIBUTES_BARCODE_FORMAT = PrinterConfigs.CONFIG_PRINTER_BAR_FORMAT;
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
public final static int DEF_PRINTER_ATTRIBUTES_QRCODE_SIZE = PrinterConfigs.CONFIG_PRINTER_QR_SIZE;
public final static int DEF_PRINTER_ATTRIBUTES_QRCODE_ERROR = PrinterConfigs.CONFIG_PRINTER_QR_ERROR;
public final static int DEF_PRINTER_ATTRIBUTES_QRCODE_SAVE = 0;
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
private final static int DEF_PRINTER_ATTRIBUTES_CODE_TYPE = 3;
private final static int DEF_PRINTER_ATTRIBUTES_FONT_TYPE = 0;
//XCSW GuoYanjie add for PrinterCommand end

public static final int ABOVE = 1;
public static final int BELOW = 2;

public static final int HORIZONTAL = 1;
public static final int VERTICAL = 2;


private int mTextSize;
private int mAlign;
private int mTypeface;
private int mMarginLeft;
private int mMarginRight;
private int mMarginTop;
private int mMarginBottom;
private int mLinespace;
private int mWeight;
private int mPaperwidth;
private int mUnderline;
private float mTextScaleX;
private float mLetterSpacing;
//XCSW GuoYanjie add for BarcodeCommand start
private int mBarcodeAlign;
private int mBarcodeWidth;
private int mBarcodeHeight;
private int mBarcodeHRIPOS;
private int mBarcodeFormat;
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
private int mQRCodeSize;
private int mQRCodeError;
private int mQRCodeSave;
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
private boolean mReverse;
private boolean mDStrike;
private int mCodeType;
private int mFontType;
//XCSW GuoYanjie add for PrinterCommand end

public PrinterAttributes(){
setDefaultAttributes();
}
public void setDefaultAttributes(){
this.mTextSize = DEF_PRINTER_ATTRIBUTES_TEXTSIZE;
this.mAlign = DEF_PRINTER_ATTRIBUTES_ALIGN;
this.mTypeface = DEF_PRINTER_ATTRIBUTES_TYPEFACE;
this.mMarginLeft = DEF_PRINTER_ATTRIBUTES_MARGINLEFT;
this.mMarginRight = DEF_PRINTER_ATTRIBUTES_MARGINRIGHT;
this.mMarginTop = DEF_PRINTER_ATTRIBUTES_MARGINTOP;
this.mMarginBottom = DEF_PRINTER_ATTRIBUTES_MARGINBOTTOM;
this.mLinespace = DEF_PRINTER_ATTRIBUTES_LINESPACE;
this.mWeight = DEF_PRINTER_ATTRIBUTES_WEIGHT;
this.mPaperwidth = DEF_PRINTER_ATTRIBUTES_PAPERWIDTH;
this.mUnderline = DEF_PRINTER_ATTRIBUTES_UNDERLINE;
this.mTextScaleX = DEF_PRINTER_ATTRIBUTES_TEXTSCALEX;
this.mLetterSpacing = DEF_PRINTER_ATTRIBUTES_LETTERSPACING;
//XCSW GuoYanjie add for BarcodeCommand start
this.mBarcodeAlign = DEF_PRINTER_ATTRIBUTES_BARCODE_ALIGN;
this.mBarcodeWidth = DEF_PRINTER_ATTRIBUTES_BARCODE_WIDTH;
this.mBarcodeHeight = DEF_PRINTER_ATTRIBUTES_BARCODE_HEIGHT;
this.mBarcodeHRIPOS = DEF_PRINTER_ATTRIBUTES_BARCODE_HRIPOS;
this.mBarcodeFormat = DEF_PRINTER_ATTRIBUTES_BARCODE_FORMAT;
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
this.mQRCodeSize = DEF_PRINTER_ATTRIBUTES_QRCODE_SIZE;
this.mQRCodeError = DEF_PRINTER_ATTRIBUTES_QRCODE_ERROR;
this.mQRCodeSave = DEF_PRINTER_ATTRIBUTES_QRCODE_SAVE;
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
this.mReverse = false;
this.mDStrike = false;
this.mCodeType = DEF_PRINTER_ATTRIBUTES_CODE_TYPE;
this.mFontType = DEF_PRINTER_ATTRIBUTES_FONT_TYPE;
//XCSW GuoYanjie add for PrinterCommand end
}

public static PrinterAttributes clone(PrinterAttributes attr){
PrinterAttributes attributes = new PrinterAttributes();
if(attr!=null){
attributes.setTextSize(attr.getTextSize());
attributes.setAlign(attr.getAlign());
attributes.setTypeface(attr.getTypeface());
attributes.setMarginLeft(attr.getMarginLeft());
attributes.setMarginRight(attr.getMarginRight());
attributes.setMarginTop(attr.getMarginTop());
attributes.setMarginBottom(attr.getMarginBottom());
attributes.setLinespace(attr.getLinespace());
attributes.setWeight(attr.getWeight());
attributes.setPaperwidth(attr.getPaperwidth());
attributes.setUnderline(attr.getUnderline());
attributes.setTextScaleX(attr.getTextScaleX());
attributes.setLetterSpacing(attr.getLetterSpacing());
//XCSW GuoYanjie add for BarcodeCommand start
attributes.setBarcodeAlign(attr.getBarcodeAlign());
attributes.setBarcodeWidth(attr.getBarcodeWidth());
attributes.setBarcodeHeight(attr.getBarcodeHeight());
attributes.setBarcodeHRIPOS(attr.getBarcodeHRIPOS());
attributes.setBarcodeFormat(attr.getBarcodeFormat());
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
attributes.setQRCodeSize(attr.getQRCodeSize());
attributes.setQRCodeError(attr.getQRCodeError());
attributes.setQRCodeSave(attr.getQRCodeSave());
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
attributes.setPrinterReverse(attr.getPrinterReverse());
attributes.setPrinterDoubleStrike(attr.getPrinterDoubleStrike());
attributes.setPrinterCodeType(attr.getPrinterCodeType());
attributes.setPrinterFontType(attr.getPrinterFontType());
//XCSW GuoYanjie add for PrinterCommand end
}
return attributes;
}

//HashMap<String,Integer>
public void applyHashMapValues(Map<String, Integer> attributes){
try {
if (attributes != null) {
if (attributes.containsKey(KEY_ALIGN)) {
this.mAlign = (int)attributes.get(KEY_ALIGN);
}
if (attributes.containsKey(KEY_TEXTSIZE)) {
this.mTextSize = (int)attributes.get(KEY_TEXTSIZE);
}
if (attributes.containsKey(KEY_TYPEFACE)) {
this.mTypeface = (int)attributes.get(KEY_TYPEFACE);
}
if (attributes.containsKey(KEY_MARGINLEFT)) {
this.mMarginLeft = (int)attributes.get(KEY_MARGINLEFT);
}
if (attributes.containsKey(KEY_MARGINRIGHT)) {
this.mMarginRight = (int)attributes.get(KEY_MARGINRIGHT);
}
if (attributes.containsKey(KEY_MARGINTOP)) {
this.mMarginTop = (int)attributes.get(KEY_MARGINTOP);
}
if (attributes.containsKey(KEY_MARGINBOTTOM)) {
this.mMarginBottom = (int)attributes.get(KEY_MARGINBOTTOM);
}
if (attributes.containsKey(KEY_LINESPACE)) {
this.mLinespace = (int)attributes.get(KEY_LINESPACE);
}
if (attributes.containsKey(KEY_WEIGHT)) {
this.mWeight = (int)attributes.get(KEY_WEIGHT);
}
if (attributes.containsKey(KEY_PAPERWIDTH)) {
this.mPaperwidth = (int)attributes.get(KEY_PAPERWIDTH);
}
if (attributes.containsKey(KEY_UNDERLINE)) {
this.mUnderline = (int)attributes.get(KEY_UNDERLINE);
}
if (attributes.containsKey(KEY_TEXTSCALEX)) {
this.mTextScaleX = (float)attributes.get(KEY_TEXTSCALEX);
}
if (attributes.containsKey(KEY_LETTERSPACING)) {
this.mLetterSpacing = (float)attributes.get(KEY_LETTERSPACING);
}
//XCSW GuoYanjie add for BarcodeCommand start
if (attributes.containsKey(KEY_BARALIGN)){
this.mBarcodeAlign = (int)attributes.get(KEY_BARALIGN);
}
if (attributes.containsKey(KEY_BARWIDTH)){
this.mBarcodeWidth = (int)attributes.get(KEY_BARWIDTH);
}
if (attributes.containsKey(KEY_BARHEIGHT)){
this.mBarcodeHeight = (int)attributes.get(KEY_BARHEIGHT);
}
if (attributes.containsKey(KEY_BARHRIPOS)){
this.mBarcodeHRIPOS = (int)attributes.get(KEY_BARHRIPOS);
}
if (attributes.containsKey(KEY_BARFORMAT)){
this.mBarcodeFormat = (int)attributes.get(KEY_BARFORMAT);
}
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
if (attributes.containsKey(KEY_QRSIZE)){
this.mQRCodeSize = (int)attributes.get(KEY_QRSIZE);
}
if (attributes.containsKey(KEY_QRERROR)){
this.mQRCodeError = (int)attributes.get(KEY_QRERROR);
}
if (attributes.containsKey(KEY_QRSAVE)){
this.mQRCodeSave = (int)attributes.get(KEY_QRSAVE);
}
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
if (attributes.containsKey(KEY_REVERSE)){
this.mReverse = ((int)attributes.get(KEY_REVERSE) == 1);
}
if (attributes.containsKey(KEY_DOUBLESTRIKE)){
this.mDStrike = ((int)attributes.get(KEY_DOUBLESTRIKE) == 1);
}
if (attributes.containsKey(KEY_CODETABLE)){
this.mCodeType = (int)attributes.get(KEY_CODETABLE);
}
if (attributes.containsKey(KEY_FONT_TYPE)){
this.mFontType = (int)attributes.get(KEY_FONT_TYPE);
}
//XCSW GuoYanjie add for PrinterCommand end
}
}catch(Exception e){

}
}

public int getAlign() {
return mAlign;
}

public void setAlign(int align) {
this.mAlign = align;
}

public int getTextSize() {
return mTextSize;
}

public void setTextSize(int textSize) {
this.mTextSize = textSize;
}

public int getTypeface() {
return mTypeface;
}

public void setTypeface(int typeFace) {
this.mTypeface = typeFace;
}

public int getMarginLeft() {
return mMarginLeft;
}

public void setMarginLeft(int marginLeft) {
this.mMarginLeft = marginLeft;
}

public int getMarginRight() {
return mMarginRight;
}

public void setMarginRight(int marginRight) {
this.mMarginRight = marginRight;
}

public int getMarginTop() {
return mMarginTop;
}

public void setMarginTop(int marginTop) {
this.mMarginTop = marginTop;
}

public int getMarginBottom() {
return mMarginBottom;
}

public void setMarginBottom(int marginBottom) {
this.mMarginBottom = marginBottom;
}

public int getLinespace() {
return mLinespace;
}

public void setLinespace(int lineSpace) {
this.mLinespace = lineSpace;
}

public int getWeight() {
return mWeight;
}

public void setWeight(int weight) {
this.mWeight = weight;
}

public int getPaperwidth() {
return mPaperwidth;
}

public void setPaperwidth(int paperwidth) {
this.mPaperwidth = paperwidth;
}

public int getUnderline() {
return mUnderline;
}

public void setUnderline(int underline) {
this.mUnderline = underline;
}

public float getTextScaleX() {
return mTextScaleX;
}

public void setTextScaleX(float textScaleX) {
this.mTextScaleX = textScaleX;
}

public float getLetterSpacing() {
return mLetterSpacing;
}

public void setLetterSpacing(float letterSpacing) {
this.mLetterSpacing = letterSpacing;
}

//XCSW GuoYanjie add for BarcodeCommand start
public int getBarcodeAlign() {
return mBarcodeAlign;
}

public void setBarcodeAlign(int align) {
this.mBarcodeAlign = align;
}

public int getBarcodeWidth() {
return mBarcodeWidth;
}

public void setBarcodeWidth(int width) {
this.mBarcodeWidth = width;
}

public int getBarcodeHeight() {
return mBarcodeHeight;
}

public void setBarcodeHeight(int height) {
this.mBarcodeHeight = height;
}

public int getBarcodeHRIPOS(){
return mBarcodeHRIPOS;
}
public void setBarcodeHRIPOS(int pos){
this.mBarcodeHRIPOS = pos;
}

public int getBarcodeFormat(){
return mBarcodeFormat;
}
public void setBarcodeFormat(int format){
mBarcodeFormat = format;
}
//XCSW GuoYanjie add for BarcodeCommand end

//add for QRCode start
public int getQRCodeSize(){
return mQRCodeSize;
}
public void setQRCodeSize(int size){
mQRCodeSize = size;
}

public int getQRCodeError(){
return mQRCodeError;
}
public void setQRCodeError(int error){
mQRCodeError = error;
}

public int getQRCodeSave(){
return mQRCodeSave;
}
public void setQRCodeSave(int save){
mQRCodeSave = save;
}
//add for QRCode end

//XCSW GuoYanjie add for PrinterCommand start
public void setPrinterReverse(boolean flag) {
this.mReverse = flag;
}
public boolean getPrinterReverse(){
return mReverse;
}
public void setPrinterDoubleStrike(boolean flag) {
this.mDStrike = flag;
}
public boolean getPrinterDoubleStrike(){
return mDStrike;
}
public void setPrinterCodeType(int codeType) {
this.mCodeType = codeType;
}
public int getPrinterCodeType(){
return mCodeType;
}
public void setPrinterFontType(int fontType){
this.mFontType = fontType;
}
public int getPrinterFontType(){
return mFontType;
}
//XCSW GuoYanjie add for PrinterCommand end

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mTextSize);
dest.writeInt(mAlign);
dest.writeInt(mTypeface);
dest.writeInt(mMarginLeft);
dest.writeInt(mMarginRight);
dest.writeInt(mMarginTop);
dest.writeInt(mMarginBottom);
dest.writeInt(mLinespace);
dest.writeInt(mWeight);
dest.writeInt(mPaperwidth);
dest.writeInt(mUnderline);
dest.writeFloat(mTextScaleX);
dest.writeFloat(mLetterSpacing);
//XCSW GuoYanjie add for BarcodeCommand start
dest.writeInt(mBarcodeAlign);
dest.writeInt(mBarcodeWidth);
dest.writeInt(mBarcodeHeight);
dest.writeInt(mBarcodeHRIPOS);
dest.writeInt(mBarcodeFormat);
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
dest.writeInt(mQRCodeSize);
dest.writeInt(mQRCodeError);
dest.writeInt(mQRCodeSave);
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
dest.writeInt(mReverse ? 1 : 0);
dest.writeInt(mDStrike ? 1 : 0);
dest.writeInt(mCodeType);
dest.writeInt(mFontType);
//XCSW GuoYanjie add for PrinterCommand end
}
/**
* Parcelable.Creator<T>
*/
public static final Creator<PrinterAttributes> CREATOR = new Creator<PrinterAttributes>() {
@Override
public PrinterAttributes[] newArray(int size) {
return new PrinterAttributes[size];
}
@Override
public PrinterAttributes createFromParcel(Parcel source) {
PrinterAttributes attributes = new PrinterAttributes();
attributes.setTextSize(source.readInt());
attributes.setAlign(source.readInt());
attributes.setTypeface(source.readInt());
attributes.setMarginLeft(source.readInt());
attributes.setMarginRight(source.readInt());
attributes.setMarginTop(source.readInt());
attributes.setMarginBottom(source.readInt());
attributes.setLinespace(source.readInt());
attributes.setWeight(source.readInt());
attributes.setPaperwidth(source.readInt());
attributes.setUnderline(source.readInt());
attributes.setTextScaleX(source.readFloat());
attributes.setLetterSpacing(source.readFloat());
//XCSW GuoYanjie add for BarcodeCommand start
attributes.setBarcodeAlign(source.readInt());
attributes.setBarcodeWidth(source.readInt());
attributes.setBarcodeHeight(source.readInt());
attributes.setBarcodeHRIPOS(source.readInt());
attributes.setBarcodeFormat(source.readInt());
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
attributes.setQRCodeSize(source.readInt());
attributes.setQRCodeError(source.readInt());
attributes.setQRCodeSave(source.readInt());
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
attributes.setPrinterReverse(source.readInt() == 1);
attributes.setPrinterDoubleStrike(source.readInt() == 1);
attributes.setPrinterCodeType(source.readInt());
attributes.setPrinterFontType(source.readInt());
//XCSW GuoYanjie add for PrinterCommand end
return attributes;
}
};
@Override
public int describeContents() {
return 0;
}

public static PrinterAttributes merge(PrinterAttributes attr1,PrinterAttributes attr2){
if(attr2!=null){
if(attr2.getTextSize()!=DEF_PRINTER_ATTRIBUTES_TEXTSIZE){
attr1.setTextSize(attr2.getTextSize());
}
if(attr2.getAlign()!=DEF_PRINTER_ATTRIBUTES_ALIGN){
attr1.setAlign(attr2.getAlign());
}
if(attr2.getTypeface()!=DEF_PRINTER_ATTRIBUTES_TYPEFACE){
attr1.setTypeface(attr2.getTypeface());
}
if(attr2.getMarginLeft()!=DEF_PRINTER_ATTRIBUTES_MARGINLEFT){
attr1.setMarginLeft(attr2.getMarginLeft());
}
if(attr2.getMarginRight()!=DEF_PRINTER_ATTRIBUTES_MARGINRIGHT){
attr1.setMarginRight(attr2.getMarginRight());
}
if(attr2.getMarginTop()!=DEF_PRINTER_ATTRIBUTES_MARGINTOP){
attr1.setMarginTop(attr2.getMarginTop());
}
if(attr2.getMarginBottom()!=DEF_PRINTER_ATTRIBUTES_MARGINBOTTOM){
attr1.setMarginBottom(attr2.getMarginBottom());
}
if(attr2.getLinespace()!=DEF_PRINTER_ATTRIBUTES_LINESPACE){
attr1.setLinespace(attr2.getLinespace());
}
if(attr2.getWeight()!=DEF_PRINTER_ATTRIBUTES_WEIGHT){
attr1.setWeight(attr2.getWeight());
}
if(attr2.getPaperwidth()!=DEF_PRINTER_ATTRIBUTES_PAPERWIDTH){
attr1.setPaperwidth(attr2.getPaperwidth());
}
if(attr2.getUnderline()!=DEF_PRINTER_ATTRIBUTES_UNDERLINE){
attr1.setUnderline(attr2.getUnderline());
}
if(attr2.getTextScaleX()!=DEF_PRINTER_ATTRIBUTES_TEXTSCALEX){
attr1.setTextScaleX(attr2.getTextScaleX());
}
if(attr2.getLetterSpacing()!=DEF_PRINTER_ATTRIBUTES_LETTERSPACING){
attr1.setLetterSpacing(attr2.getLetterSpacing());
}
//XCSW GuoYanjie add for BarcodeCommand start
if(attr2.getBarcodeAlign() != DEF_PRINTER_ATTRIBUTES_ALIGN){
attr1.setBarcodeAlign(attr2.getBarcodeAlign());
}
if(attr2.getBarcodeWidth() != DEF_PRINTER_ATTRIBUTES_BARCODE_WIDTH){
attr1.setBarcodeWidth(attr2.getBarcodeWidth());
}
if(attr2.getBarcodeHeight() != DEF_PRINTER_ATTRIBUTES_BARCODE_HEIGHT){
attr1.setBarcodeHeight(attr2.getBarcodeHeight());
}
if(attr2.getBarcodeHRIPOS() != DEF_PRINTER_ATTRIBUTES_BARCODE_HRIPOS){
attr1.setBarcodeHRIPOS(attr2.getBarcodeHRIPOS());
}
if(attr2.getBarcodeFormat() != DEF_PRINTER_ATTRIBUTES_BARCODE_FORMAT){
attr1.setBarcodeFormat(attr2.getBarcodeFormat());
}
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
if(attr2.getQRCodeSize() != DEF_PRINTER_ATTRIBUTES_QRCODE_SIZE){
attr1.setQRCodeSize(attr2.getQRCodeSize());
}
if(attr2.getQRCodeError() != DEF_PRINTER_ATTRIBUTES_QRCODE_ERROR){
attr1.setQRCodeError(attr2.getQRCodeError());
}
if(attr2.getQRCodeSave() != DEF_PRINTER_ATTRIBUTES_QRCODE_SAVE){
attr1.setQRCodeSave(attr2.getQRCodeSave());
}
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
if(attr2.getPrinterReverse()){
attr1.setPrinterReverse(attr2.getPrinterReverse());
}
if(attr2.getPrinterDoubleStrike()){
attr1.setPrinterDoubleStrike(attr2.getPrinterDoubleStrike());
}
if(attr2.getPrinterCodeType() != DEF_PRINTER_ATTRIBUTES_CODE_TYPE){
attr1.setPrinterCodeType(attr2.getPrinterCodeType());
}
if(attr2.getPrinterFontType() != DEF_PRINTER_ATTRIBUTES_FONT_TYPE){
attr1.setPrinterFontType(attr2.getPrinterFontType());
}
//XCSW GuoYanjie add for PrinterCommand end
}
return attr1;
}

public String toString(){
StringBuffer buffer = new StringBuffer();
buffer.append("PrinterAttributes:");
buffer.append("mTextSize="+mTextSize+";");
buffer.append("mAlign="+mAlign+";");
buffer.append("mTypeface="+mTypeface+";");
buffer.append("mMarginLeft="+mMarginLeft+";");
buffer.append("mMarginRight="+mMarginRight+";");
buffer.append("mMarginTop="+mMarginTop+";");
buffer.append("mMarginBottom="+mMarginBottom+";");
buffer.append("mLinespace="+mLinespace+";");
buffer.append("mWeight="+mWeight+";");
buffer.append("mPaperwidth="+mPaperwidth+";");
buffer.append("mUnderline="+mUnderline+";");
buffer.append("mTextScaleX="+mTextScaleX+";");
buffer.append("mLetterSpacing="+mLetterSpacing+";");
//XCSW GuoYanjie add for BarcodeCommand start
buffer.append("mBarcodeAlign="+mBarcodeAlign+";");
buffer.append("mBarcodeWidth="+mBarcodeWidth+";");
buffer.append("mBarcodeHeight="+mBarcodeHeight+";");
buffer.append("mBarcodeHRIPOS="+mBarcodeHRIPOS+";");
buffer.append("mBarcodeFormat="+mBarcodeFormat+";");
//XCSW GuoYanjie add for BarcodeCommand end
//add for QRCode start
buffer.append("mQRCodeSize="+mQRCodeSize+";");
buffer.append("mQRCodeError="+mQRCodeError+";");
buffer.append("mQRCodeSave="+mQRCodeSave+";");
//add for QRCode end
//XCSW GuoYanjie add for PrinterCommand start
buffer.append("mReverse="+mReverse+";");
buffer.append("mDStrike="+mDStrike+";");
buffer.append("mCodeType="+mCodeType+";");
buffer.append("mFontType="+mFontType+";");
//XCSW GuoYanjie add for PrinterCommand end
return buffer.toString();
}
}