alternative arrangement gui
This commit is contained in:
parent
994a288e84
commit
22bb11a7d6
|
@ -0,0 +1,66 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@ public class MainFrame extends JFrame {
|
||||||
private JPanel sidepanel;
|
private JPanel sidepanel;
|
||||||
private JSplitPane splitpane;
|
private JSplitPane splitpane;
|
||||||
private JScrollPane scrollPane;
|
private JScrollPane scrollPane;
|
||||||
private ArrangementDialog arrangement;
|
private ArrangementDialog2 arrangement;
|
||||||
private PlotDialog plot;
|
private PlotDialog plot;
|
||||||
|
|
||||||
public MainFrame() {
|
public MainFrame() {
|
||||||
|
@ -51,9 +51,9 @@ public class MainFrame extends JFrame {
|
||||||
|
|
||||||
public void createArrangement() {
|
public void createArrangement() {
|
||||||
if (arrangement == null) {
|
if (arrangement == null) {
|
||||||
arrangement = new ArrangementDialog();
|
arrangement = new ArrangementDialog2();
|
||||||
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines(), getPresenter().getModel().getNodes());
|
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines(), getPresenter().getModel().getNodes());
|
||||||
arrangement.createArrangement();
|
// arrangement.createArrangement();
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -103,7 +103,7 @@ public class MainFrame extends JFrame {
|
||||||
|
|
||||||
arrangementDialog = new JDialog();
|
arrangementDialog = new JDialog();
|
||||||
plotDialog = new JDialog();
|
plotDialog = new JDialog();
|
||||||
arrangementDialog.setSize(new Dimension(700, 470));
|
arrangementDialog.setSize(new Dimension(600, 600));
|
||||||
plotDialog.setSize(new Dimension(700, 470));
|
plotDialog.setSize(new Dimension(700, 470));
|
||||||
arrangementDialog.setTitle("Arrangement Dialog");
|
arrangementDialog.setTitle("Arrangement Dialog");
|
||||||
plotDialog.setTitle("Scatter Plot Dialog");
|
plotDialog.setTitle("Scatter Plot Dialog");
|
||||||
|
|
Loading…
Reference in New Issue