315 lines
8.7 KiB
Java
315 lines
8.7 KiB
Java
package View;
|
|
|
|
|
|
import Model.Line;
|
|
import Presenter.Algorithms.LeastMedianOfSquaresEstimator;
|
|
import Presenter.Presenter;
|
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
import jdk.nashorn.internal.scripts.JO;
|
|
|
|
import javax.swing.*;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeListener;
|
|
import java.awt.*;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.util.List;
|
|
import java.util.Observable;
|
|
import java.util.Observer;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 28.05.2017.
|
|
*/
|
|
public class MainFrame extends JFrame{
|
|
|
|
private Presenter presenter;
|
|
private Boolean lmsIsComplete = false;
|
|
private Boolean rmIsComplete = false;
|
|
private Boolean tsIsComplete = false;
|
|
|
|
|
|
//TODO refactoring
|
|
private JButton arrangementButton;
|
|
private JButton button3;
|
|
|
|
private OutputPanel output;
|
|
private MenuPanel menupanel;
|
|
private SidePanel sidepanel;
|
|
private JPanel pane;
|
|
|
|
private ArrangementDialog arrangement;
|
|
private JDialog arrangementDialog;
|
|
private PlotDialog plot;
|
|
|
|
|
|
private JSplitPane splitpane;
|
|
private JScrollPane scrollPane;
|
|
|
|
private JTabbedPane tabbedPane;
|
|
|
|
public MainFrame() {
|
|
initializeComponents();
|
|
setDimensions();
|
|
setLayouts();
|
|
setTitles();
|
|
|
|
addComponents();
|
|
|
|
setCloseOperations();
|
|
setActionListeners();
|
|
|
|
this.setVisible(true);
|
|
}
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
* visualisierungs methoden
|
|
******************************************************************************************************************/
|
|
|
|
public void createArrangement() {
|
|
if (arrangement == null) {
|
|
arrangement = new ArrangementDialog();
|
|
arrangement.setPrameters(getPresenter().calcArrangementLines(), getPresenter().getModel().getNodes());
|
|
arrangement.createArrangement();
|
|
SwingUtilities.invokeLater(() -> {
|
|
arrangementDialog.add(arrangement, BorderLayout.CENTER);
|
|
arrangementDialog.setVisible(true);
|
|
});
|
|
} else {
|
|
arrangementDialog.setVisible(true);
|
|
}
|
|
}
|
|
|
|
public void createPlot(double m, double b) {
|
|
|
|
plot = new PlotDialog();
|
|
SwingUtilities.invokeLater(() -> {
|
|
plot.createPlot(getPresenter().getLines());
|
|
plot.addLineToPlot(m, b);
|
|
sidepanel.setPlotDialog(plot);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
* init GUI
|
|
******************************************************************************************************************/
|
|
private void setTitles(){
|
|
this.setTitle("MainFrame");
|
|
arrangementDialog.setTitle("Dual Representation - Dialog");
|
|
button3.setText("Import");
|
|
arrangementButton.setText("Dualraum");
|
|
}
|
|
|
|
private void setupTabbedPane(){
|
|
tabbedPane.add("LMS", sidepanel);
|
|
tabbedPane.add("RM", new JPanel());
|
|
tabbedPane.add("TS", new JPanel());
|
|
}
|
|
|
|
private void addComponents(){
|
|
pane.add(arrangementButton);
|
|
pane.add(button3);
|
|
|
|
setupSplitPane();
|
|
setupTabbedPane();
|
|
|
|
this.add(pane, BorderLayout.SOUTH);
|
|
this.add(splitpane, BorderLayout.CENTER);
|
|
this.add(menupanel, BorderLayout.NORTH);
|
|
}
|
|
|
|
private void setupSplitPane(){
|
|
splitpane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
|
|
splitpane.setResizeWeight(.5d);
|
|
splitpane.setContinuousLayout(true);
|
|
splitpane.setLeftComponent(output);
|
|
splitpane.setRightComponent(tabbedPane);
|
|
}
|
|
|
|
private void setCloseOperations(){
|
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
|
}
|
|
|
|
private void setDimensions(){
|
|
this.setSize(1900, 1000);
|
|
sidepanel.setMinimumSize(new Dimension(400,500));
|
|
arrangementDialog.setSize(new Dimension(800, 800));
|
|
output.setMinimumSize(new Dimension(400,500));
|
|
}
|
|
|
|
private void setLayouts(){
|
|
this.setLayout(new BorderLayout());
|
|
pane.setLayout(new FlowLayout());
|
|
}
|
|
|
|
private void initializeComponents(){
|
|
//Panels
|
|
pane = new JPanel();
|
|
sidepanel = new SidePanel();
|
|
menupanel = new MenuPanel();
|
|
|
|
//Dialogs
|
|
arrangementDialog = new JDialog();
|
|
|
|
//Panes
|
|
tabbedPane = new JTabbedPane();
|
|
output = new OutputPanel();
|
|
splitpane = new JSplitPane();
|
|
|
|
//Buttons
|
|
arrangementButton = new JButton();
|
|
button3 = new JButton();
|
|
}
|
|
|
|
private void setActionListeners(){
|
|
arrangementButton.addActionListener((ActionEvent e) -> {
|
|
Thread t = new Thread(() -> getPresenter().startArrangementVisualization());
|
|
t.start();
|
|
});
|
|
|
|
sidepanel.getStartButton().addActionListener((ActionEvent e) -> {
|
|
Thread t = new Thread(() -> this.getPresenter().startScatterPlotVisualization(sidepanel.getInput()));
|
|
t.start();
|
|
});
|
|
}
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
* log Methode
|
|
******************************************************************************************************************/
|
|
public void log(String s) {
|
|
SwingUtilities.invokeLater(() -> output.appendParagraph(s));
|
|
}
|
|
|
|
public void logError(String s){
|
|
SwingUtilities.invokeLater(() -> output.appendParagraphRed(s));
|
|
}
|
|
|
|
public void logSuccess(String s){
|
|
SwingUtilities.invokeLater(() -> output.appendParagraphGreen(s));
|
|
}
|
|
|
|
public void logHeading(String s){
|
|
SwingUtilities.invokeLater(() -> output.appendParagraphWithHeading(s));
|
|
}
|
|
|
|
public void createTable(List<String> heading, List<List<String>> rows){
|
|
SwingUtilities.invokeLater(() -> output.logTable(heading, rows));
|
|
}
|
|
/*******************************************************************************************************************
|
|
* Getter und Setter Methoden
|
|
******************************************************************************************************************/
|
|
|
|
public Boolean getLmsIsComplete() {
|
|
return lmsIsComplete;
|
|
}
|
|
|
|
public void setLmsIsComplete(Boolean lmsIsComplete) {
|
|
this.lmsIsComplete = lmsIsComplete;
|
|
}
|
|
|
|
public Boolean getRmIsComplete() {
|
|
return rmIsComplete;
|
|
}
|
|
|
|
public void setRmIsComplete(Boolean rmIsComplete) {
|
|
this.rmIsComplete = rmIsComplete;
|
|
}
|
|
|
|
public Boolean getTsIsComplete() {
|
|
return tsIsComplete;
|
|
}
|
|
|
|
public void setTsIsComplete(Boolean tsIsComplete) {
|
|
this.tsIsComplete = tsIsComplete;
|
|
}
|
|
|
|
public JButton getArrangementButton() {
|
|
return arrangementButton;
|
|
}
|
|
|
|
public void setArrangementButton(JButton arrangementButton) {
|
|
this.arrangementButton = arrangementButton;
|
|
}
|
|
|
|
public JButton getButton3() {
|
|
return button3;
|
|
}
|
|
|
|
public void setButton3(JButton button3) {
|
|
this.button3 = button3;
|
|
}
|
|
|
|
public JPanel getPane() {
|
|
return pane;
|
|
}
|
|
|
|
public void setPane(JPanel pane) {
|
|
this.pane = pane;
|
|
}
|
|
|
|
public JDialog getArrangementDialog() {
|
|
return arrangementDialog;
|
|
}
|
|
|
|
public void setArrangementDialog(JDialog arrangementDialog) {
|
|
this.arrangementDialog = arrangementDialog;
|
|
}
|
|
|
|
public OutputPanel getOutput() {
|
|
return output;
|
|
}
|
|
|
|
public void setOutput(OutputPanel output) {
|
|
this.output = output;
|
|
}
|
|
|
|
public JPanel getMenupanel() {
|
|
return menupanel;
|
|
}
|
|
|
|
public JPanel getSidepanel() {
|
|
return sidepanel;
|
|
}
|
|
|
|
public JSplitPane getSplitpane() {
|
|
return splitpane;
|
|
}
|
|
|
|
public void setSplitpane(JSplitPane splitpane) {
|
|
this.splitpane = splitpane;
|
|
}
|
|
|
|
public JScrollPane getScrollPane() {
|
|
return scrollPane;
|
|
}
|
|
|
|
public void setScrollPane(JScrollPane scrollPane) {
|
|
this.scrollPane = scrollPane;
|
|
}
|
|
|
|
|
|
public PlotDialog getPlot() {
|
|
return plot;
|
|
}
|
|
|
|
public void setPlot(PlotDialog plot) {
|
|
this.plot = plot;
|
|
}
|
|
|
|
public Presenter getPresenter() {
|
|
return presenter;
|
|
}
|
|
|
|
public void setPresenter(Presenter presenter) {
|
|
this.presenter = presenter;
|
|
}
|
|
}
|