package de.ivu.elect.presentation.charts;

import java.io.Serializable;

/**
 *  on 22.07.2015.
 */
public class BarChartSize implements Serializable {

  public static final BarChartSize AUTO = new BarChartSize(0, 0){
    @Override
    public boolean isAutosize() {
      return true;
    }
  };

  public BarChartSize(long width, long height) {
    this.width = width;
    this.height = height;
  }

  private final long width;

  private final long height;

  public String getStyle() {
    if (isAutosize()) {
      return "width: 90%;";
    }
    return "width:" + width + "px;" + "height:" + height + "px;";
  }

  public boolean isResponsive(){
    return isAutosize();
  }

  public boolean isMaintainAspectRatio(){
    return isAutosize();
  }

  public boolean isAutosize() {
    return width == 0 || height == 0;
  }

  public long getHeight() {
    return height;
  }

  public long getWidth() {
    return width;
  }
}
