64 lines
1.7 KiB
Java
64 lines
1.7 KiB
Java
package View;
|
|
|
|
import Model.Pair;
|
|
import org.jfree.chart.ChartFactory;
|
|
import org.jfree.chart.ChartPanel;
|
|
import org.jfree.chart.JFreeChart;
|
|
import org.jfree.chart.plot.PlotOrientation;
|
|
import org.jfree.data.xy.XYSeries;
|
|
import org.jfree.data.xy.XYSeriesCollection;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.Dimension;
|
|
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 ArrangementDialog extends JPanel {
|
|
|
|
private LinkedList<Pair> lines;
|
|
private double max;
|
|
private double min;
|
|
private JFreeChart chart;
|
|
private ChartPanel panel;
|
|
|
|
public ArrangementDialog(){
|
|
super();
|
|
this.setPreferredSize(new Dimension(800,500));
|
|
}
|
|
|
|
public void setPrameters(Double pmax, Double pmin, LinkedList<Pair> lines){
|
|
this.max = pmax;
|
|
this.min = pmin;
|
|
this.lines = lines;
|
|
}
|
|
|
|
public void createArrangement(){
|
|
XYSeriesCollection dataset = new XYSeriesCollection();
|
|
|
|
for (Pair p : lines) {
|
|
XYSeries series = new XYSeries(p.getX()+p.getY());
|
|
series.add((-1 * this.max), ((-1 * this.max) * p.getX() + p.getY()));
|
|
series.add(this.max, (this.max * p.getX() + p.getY()));
|
|
dataset.addSeries(series);
|
|
}
|
|
|
|
chart = ChartFactory.createXYLineChart(
|
|
null, null, null, dataset,
|
|
PlotOrientation.HORIZONTAL, false, false, false );
|
|
chart.getPlot().setBackgroundPaint(Color.WHITE);
|
|
panel = new ChartPanel(chart);
|
|
this.add(panel);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|