PrinterPagerItemData.java 3.71 KB
package com.yanzuoguang.util.printer.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.BaseVo;

/**
 * 打印项
 *
 * @author 颜佐光
 */
public class PrinterPagerItemData extends BaseVo {

    /**
     * 名称,用于识别
     */
    @JSONField(name = "Name")
    public String name;

    /**
     * 是否图片,打印项类型:PrinterPagerItemType
     */
    @JSONField(name = "Type")
    public int type;

    /**
     * 是否显示
     */
    @JSONField(name = "IsVisible")
    public boolean isVisible;

    /**
     * 左边距离
     */
    @JSONField(name = "Left")
    public double left;

    /**
     * 上面距离
     */
    @JSONField(name = "Top")
    public double top;

    /**
     * 宽度
     */
    @JSONField(name = "Width")
    public Object width;

    /**
     * 高度
     */
    @JSONField(name = "Height")
    public Object height;

    /**
     * 字体名称
     */
    @JSONField(name = "Font")
    public String font;

    /**
     * 对齐方式,参见类:ContentAlignment
     */
    @JSONField(name = "TextAlign")
    public int textAlign;

    /**
     * 格式化
     */
    @JSONField(name = "Format")
    public String format;

    /**
     * 构造函数
     */
    public PrinterPagerItemData() {
        this.name = StringHelper.EMPTY;
        this.type = PrinterPagerItemType.None;
        this.isVisible = true;
        this.left = 0;
        this.top = 0;
        this.width = 100;
        this.height = 20;
        this.font = "微软雅黑,9pt,style=Bold";
        this.format = StringHelper.EMPTY;
        this.textAlign = ContentAlignment.TopLeft;
    }

    /**
     * 复制到新属性
     *
     * @param to
     */
    public void copyTo(PrinterPagerItemData to) {
        to.name = this.name;
        to.type = this.type;
        to.isVisible = this.isVisible;
        to.left = this.left;
        to.top = this.top;
        to.width = this.width;
        to.height = this.height;
        to.format = this.format;
        to.font = this.font;
        to.textAlign = this.textAlign;
    }

    /**
     * 处理字体
     *
     * @return
     */
    private String initFont() {
        if (this.font != null && this.font.endsWith(",")) {
            this.font = this.font.substring(0, this.font.length() - 1);
        }
        return font;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean isVisible() {
        return isVisible;
    }

    public void setVisible(boolean visible) {
        isVisible = visible;
    }

    public double getLeft() {
        return left;
    }

    public void setLeft(double left) {
        this.left = left;
    }

    public double getTop() {
        return top;
    }

    public void setTop(double top) {
        this.top = top;
    }

    public Object getWidth() {
        return width;
    }

    public void setWidth(Object width) {
        this.width = width;
    }

    public Object getHeight() {
        return height;
    }

    public void setHeight(Object height) {
        this.height = height;
    }

    public String getFont() {
        this.initFont();
        return font;
    }

    public void setFont(String font) {
        this.font = font;
    }

    public int getTextAlign() {
        return textAlign;
    }

    public void setTextAlign(int textAlign) {
        this.textAlign = textAlign;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }
}