package zpl.model.element;

import zpl.model.PrinterOptions;
import zpl.model.ZebraElement;
import zpl.utils.ZplUtils;

/**
 * Zebra element to create a box (or line)
 * 
 * Zpl command : ^GB
 * 
 * @author matthiasvets
 * 
 */
public class ZebraGraficBox extends ZebraElement {

    private Integer width;
    private Integer height;
    private Integer borderTickness;
    private String lineColor;

    public ZebraGraficBox(int positionX, int positionY,Integer width, Integer height, Integer borderTickness,String lineColor) {
        this.positionX = positionX;
        this.positionY = positionY;
        this.width = width;
        this.height = height;
        this.borderTickness = borderTickness;
        this.lineColor = lineColor;
    }


    /* (non-Javadoc)
	 * @see zpl.model.element.ZebraElement#getZplCode(zpl.model.PrinterOptions)
	 */
	@Override
	public String getZplCode(PrinterOptions printerOptions) {
	    StringBuilder zpl = new StringBuilder();
        zpl.append(getZplCodePosition());
        zpl.append("\n");
        zpl.append(ZplUtils.zplCommand("GB", width, height, borderTickness, lineColor));
        zpl.append("^FS");
        zpl.append("\n");
        return zpl.toString();
	}
	
	protected String getZplCodePosition() {
        StringBuffer zpl = new StringBuffer("");
        if (positionX != null && positionY != null) {
            zpl.append(ZplUtils.zplCommand("FO", positionX, positionY));
        }
        return zpl.toString();
    }

}
