package de.ivu.elect.business.gebietsbaum.entity;

import java.io.Serializable;

/**
 *  on 04.01.2016.
 */
public class SvgLegendeKonfiguration implements Serializable {


  public static final SvgLegendeKonfiguration KEINE_LEGENDE = new SvgLegendeKonfiguration(null, 0,0);
  private final double relativeHorizontalePosition;

  private final double relativeVertikalePosition;

  private final String legendeHeader;

  public SvgLegendeKonfiguration(String legendeHeader, double relativeHorizontalePosition, double relativeVertikalePosition) {
    assert relativeHorizontalePosition >= 0.d && relativeHorizontalePosition <= 1d && relativeVertikalePosition >= 0.d && relativeVertikalePosition <= 1d;
    this.relativeHorizontalePosition = relativeHorizontalePosition;
    this.relativeVertikalePosition = relativeVertikalePosition;
    this.legendeHeader = legendeHeader;
  }

  public SvgPoint berechnePosition(long width, long height) {
    return new SvgPoint((int) Math.round(width * relativeHorizontalePosition), (int) Math.round(height * relativeVertikalePosition));
  }

  public String getLegendeHeader() {
    return legendeHeader;
  }

  public boolean isShowLegend() {
    return getLegendeHeader() != null;
  }
}
