algorithms-for-computing-li.../src/main/java/Presenter/Presenter.java

113 lines
2.2 KiB
Java

package Presenter;
import Model.Arrangement;
import Model.Pair;
import View.*;
import javax.swing.*;
import java.util.Collections;
import java.util.LinkedList;
/**
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
*
* @Author: Armin Wolf
* @Email: a_wolf28@uni-muenster.de
* @Date: 28.05.2017.
*/
public class Presenter {
private Arrangement model;
private View view;
private LinkedList<Pair> lines;
private Double max;
private Double min;
public Presenter(Arrangement model, View view){
this.model = model;
this.view = view;
this.lines = new LinkedList<>();
}
public void getDataFromModel() {
}
public void setDataByModel() {
}
public void getActionsFromView() {
}
public void setActionByView() {
Double[] x = {1d,2d,3d,4d,10d,12d,18d};
Double[] y = {9d,15d,19d,20d,45d,55d,78d};
// Float[] x = {18f,24f,30f,34f,38f};
// Float[] y = {18f,26f,30f,40f,70f};
// Double[] x = {1d,3d,4d,5d,8d};
// Double[] y = {4d,2d,1d,0d,0d};
for (int j=0;j<7;j++){
Pair p = new Pair(x[j], y[j]);
lines.add(p);
}
extractBounds();
view.createArrangement();
}
private void extractBounds(){
Pair pmax = Collections.max(lines);
Pair pmin = Collections.min(lines);
max = pmax.getX() >= pmax.getY() ? pmax.getX() : pmax.getY();
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
}
public Arrangement getModel() {
return model;
}
public void setModel(Arrangement model) {
this.model = model;
}
public View getView() {
return view;
}
public void setView(View view) {
this.view = view;
}
public LinkedList<Pair> getLines() {
return lines;
}
public void setLines(LinkedList<Pair> lines) {
this.lines = lines;
}
public Double getMax() {
return max;
}
public void setMax(Double max) {
this.max = max;
}
public Double getMin() {
return min;
}
public void setMin(Double min) {
this.min = min;
}
}