113 lines
3.3 KiB
Java
113 lines
3.3 KiB
Java
package View;
|
|
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 28.05.2017.
|
|
*/
|
|
public class MainFrame<T> extends View {
|
|
|
|
//TODO refactoring
|
|
private JButton arrangementButton;
|
|
private JButton plotButton;
|
|
private JButton button3;
|
|
private JPanel pane;
|
|
private JDialog arrangementDialog;
|
|
private JDialog plotDialog;
|
|
private ArrangementDialog arrangement;
|
|
private PlotDialog plot;
|
|
|
|
public MainFrame(){
|
|
initGUI();
|
|
}
|
|
|
|
|
|
protected void initGUI(){
|
|
this.setTitle("MainFrame");
|
|
this.setSize(800,800);
|
|
this.setLayout(new BorderLayout());
|
|
pane = new JPanel();
|
|
pane.setLayout(new FlowLayout());
|
|
arrangementDialog = new JDialog();
|
|
plotDialog = new JDialog();
|
|
arrangementDialog.setSize(new Dimension(700,470));
|
|
plotDialog.setSize(new Dimension(700,470));
|
|
arrangementDialog.setTitle("Arrangement Dialog");
|
|
plotDialog.setTitle("Scatter Plot Dialog");
|
|
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
|
plotDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
|
arrangementButton = new JButton("Arrangement");
|
|
plotButton = new JButton("Plot");
|
|
button3 = new JButton("Import");
|
|
|
|
arrangementButton.addActionListener(new ActionListener() {
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
getPresenter().startArrangementVisualization();
|
|
}
|
|
});
|
|
|
|
plotButton.addActionListener(new ActionListener() {
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
getPresenter().startScatterPlotVisualization();
|
|
}
|
|
});
|
|
|
|
pane.add(arrangementButton);
|
|
pane.add(plotButton);
|
|
pane.add(button3);
|
|
this.add(pane, BorderLayout.WEST);
|
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
this.setVisible(true);
|
|
}
|
|
|
|
@Override
|
|
public void createArrangement() {
|
|
if (arrangement == null){
|
|
arrangement = new ArrangementDialog();
|
|
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines());
|
|
arrangement.createArrangement();
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
arrangementDialog.add(arrangement);
|
|
arrangementDialog.setVisible(true);
|
|
}
|
|
});
|
|
} else {
|
|
arrangementDialog.setVisible(true);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void createLine() {
|
|
//TODO
|
|
}
|
|
|
|
@Override
|
|
public void createPlot() {
|
|
if (plot == null){
|
|
plot = new PlotDialog();
|
|
plot.createPlot(getPresenter().getLines());
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
plotDialog.add(plot);
|
|
plotDialog.setVisible(true);
|
|
}
|
|
});
|
|
} else {
|
|
plotDialog.setVisible(true);
|
|
}
|
|
}
|
|
}
|