package com.sheep.gamegroup.model.entity;

/**
 * Created by realicing on 2018/11/13.
 * realicing@sina.com
 * 配置layoutParams，配置LayoutParamsUtil使用
 */
public class Lp {
    //不用设置标识
    public static final int NONE = -101;
    private int leftMargin = NONE;
    private int rightMargin = NONE;
    private int topMargin = NONE;
    private int bottomMargin = NONE;
    private int width = NONE;
    private int height = NONE;
    private float per = 1.0f;

    public Lp() {
    }

    public Lp(float per) {
        this.per = per;
    }

    public static int getNONE() {
        return NONE;
    }

    public int getLeftMargin() {
        return leftMargin;
    }

    public Lp setLeftMargin(int leftMargin) {
        this.leftMargin = (int) (leftMargin * per);
        return this;
    }

    public int getRightMargin() {
        return rightMargin;
    }

    public Lp setRightMargin(int rightMargin) {
        this.rightMargin = (int) (rightMargin * per);
        return this;
    }

    public int getTopMargin() {
        return topMargin;
    }

    public Lp setTopMargin(int topMargin) {
        this.topMargin = (int) (topMargin * per);
        return this;
    }

    public int getBottomMargin() {
        return bottomMargin;
    }

    public Lp setBottomMargin(int bottomMargin) {
        this.bottomMargin = (int) (bottomMargin * per);
        return this;
    }

    public int getWidth() {
        return width;
    }

    public Lp setWidth(int width) {
        this.width = (int) (width * per);
        return this;
    }

    public int getHeight() {
        return height;
    }

    public Lp setHeight(int height) {
        this.height = (int) (height * per);
        return this;
    }

    public Lp addLeftMargin(float mx) {
        int addMargin = (int) (per * mx);
        switch (leftMargin) {
            case NONE:
                leftMargin = addMargin;
                break;
            default:
                leftMargin += addMargin;
                break;
        }
        return this;
    }

    public Lp setLrMargin(int margin) {
        margin = (int) (margin * per);
        this.leftMargin = margin;
        this.rightMargin = margin;
        return this;
    }

    public Lp setTbMargin(int margin) {
        margin = (int) (margin * per);
        this.topMargin = margin;
        this.bottomMargin = margin;
        return this;
    }

    public Lp setMargin(int margin) {
        margin = (int) (margin * per);
        this.topMargin = margin;
        this.bottomMargin = margin;
        this.leftMargin = margin;
        this.rightMargin = margin;
        return this;
    }
}
