package de.wwwu.awolf.model;

import java.util.HashSet;
import java.util.Set;

/**
 * Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
 *
 * @Author: Armin Wolf
 * @Email: a_wolf28@uni-muenster.de
 * @Date: 28.05.2017.
 */
public class LineModel {

    private Set<Line> lines;
    private Double xMinimum;
    private Double xMaximum;
    private Double yMinimum;
    private Double yMaximum;
    private int size;

    /**
     * Konstruktor
     */
    public LineModel() {
        lines = new HashSet<>();
        size = 0;

        xMinimum = Double.MAX_VALUE;
        xMaximum = Double.MIN_VALUE;
        yMinimum = Double.MAX_VALUE;
        yMaximum = Double.MIN_VALUE;

    }


    /**
     * Fügt eine Gerade zu dem Modell hinzu
     *
     * @param line Gerade
     */
    public void addLine(Line line) {
        this.lines.add(line);
    }


    /**
     * @return Liste der Geraden
     */
    public Set<Line> getLines() {
        return lines;
    }

    /**
     * @param lines Liste der Geraden
     */
    public void setLines(Set<Line> lines) {
        this.lines = lines;
        this.size = lines.size();
    }

    /**
     * @return Minimale x-Koordiante
     */
    public Double getxMinimum() {
        return xMinimum;
    }

    /**
     * @param xMinimum Minimale x-Koordiante
     */
    public void setxMinimum(Double xMinimum) {
        this.xMinimum = xMinimum;
    }

    /**
     * @return Maximale x-Koordiante
     */
    public Double getxMaximum() {
        return xMaximum;
    }

    /**
     * @param xMaximum Maximale x-Koordiante
     */
    public void setxMaximum(Double xMaximum) {
        this.xMaximum = xMaximum;
    }

    /**
     * @return Minimale y-Koordiante
     */
    public Double getyMinimum() {
        return yMinimum;
    }

    /**
     * @param yMinimum Minimale y-Koordiante
     */
    public void setyMinimum(Double yMinimum) {
        this.yMinimum = yMinimum;
    }

    /**
     * @return Maximale y-Koordiante
     */
    public Double getyMaximum() {
        return yMaximum;
    }

    /**
     * @param yMaximum Maximale y-Koordiante
     */
    public void setyMaximum(Double yMaximum) {
        this.yMaximum = yMaximum;
    }

    /**
     * Setzt die minimalen, maximalen x- und y-Koordinaten
     */
    public void resetRanges() {
        xMinimum = Double.MAX_VALUE;
        xMaximum = Double.MIN_VALUE;
        yMinimum = Double.MAX_VALUE;
        yMaximum = Double.MIN_VALUE;
    }

    public int getSize() {
        return size;
    }
}
