67 lines
1.6 KiB
Java
67 lines
1.6 KiB
Java
package View;
|
|
|
|
import Model.Coordinates;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.util.LinkedList;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 03.06.2017.
|
|
*/
|
|
public class ArrangementDialog2 extends JPanel {
|
|
|
|
private double scale;
|
|
|
|
private int min = 0;
|
|
private int max = 600;
|
|
private int zero = max/2;
|
|
|
|
private Dimension dimension;
|
|
private LinkedList<Coordinates> lines;
|
|
private LinkedList<Coordinates> points;
|
|
|
|
|
|
public ArrangementDialog2(){
|
|
super();
|
|
this.dimension = new Dimension(max,max);
|
|
this.setPreferredSize(dimension);
|
|
}
|
|
|
|
public void setPrameters(Double pmax, Double pmin, LinkedList<Coordinates> lines, LinkedList<Coordinates> points) {
|
|
this.scale = max / (Math.abs(pmin) - Math.abs(pmax));
|
|
this.lines = lines;
|
|
this.points = points;
|
|
|
|
scalePoints();
|
|
this.repaint();
|
|
}
|
|
|
|
private void scalePoints(){
|
|
for (Coordinates c : lines) {
|
|
c.setX(c.getX() * scale);
|
|
c.setY(c.getY() * scale);
|
|
}
|
|
|
|
JOptionPane.showMessageDialog(null,points.size());
|
|
for (Coordinates c : points) {
|
|
c.setX((c.getX() * scale) + zero);
|
|
c.setY((c.getY()* scale) + zero);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
protected void paintComponent(Graphics g){
|
|
super.paintComponent(g);
|
|
g.setColor(Color.BLACK);
|
|
for (Coordinates point : points) {
|
|
g.drawRect(point.getX().intValue(),point.getY().intValue(), 5, 5);
|
|
}
|
|
}
|
|
}
|