package com.persagy.adm.diagram.core.model.base;

import com.google.gson.annotations.Expose;

/**
 * 容器的布局
 * @author zhaoyk
 */
public class Layout {

    public static final int ROW = 1;

    public static final int COLUMN = 2;

    public static final int TOP = 1;

    public static final int RIGHT = 2;

    public static final int BOTTOM = 3;

    public static final int LEFT = 4;

    public static final int CENTER = 5;

    @Expose
    public int layout;

    public int align = LEFT;

    public int valign = TOP;

    @Expose
    public int marginTop;

    @Expose
    public int marginRight;

    @Expose
    public int marginBottom;

    @Expose
    public int marginLeft;

    @Expose
    public int spaceH;

    @Expose
    public int spaceV;

    public Layout(int layout){
        this.layout = layout;
    }

    public void setLayout(int layout) {
        this.layout = layout;
    }

    public int getLayout() {
        return layout;
    }

    public void setMarginWidth(int marginWidth){
        this.marginLeft = this.marginRight = marginWidth;
    }

    public void setMarginHeight(int marginHeight){
        this.marginTop = this.marginBottom = marginHeight;
    }

    public static Layout defaultLayout(int layout) {
        Layout l = new Layout(layout);
        if(layout == ROW) {
            l.align = LEFT;
            l.valign = CENTER;
        } else if(layout == COLUMN) {
            l.valign = TOP;
            l.align = CENTER;
        }
        l.marginTop = l.marginBottom = 20;
        l.marginLeft = l.marginRight = 20;
        l.spaceH = l.spaceV = 20;
        return l;
    }

}
