gui parameter übermitteln an Algorithmus
This commit is contained in:
parent
72e7348b42
commit
962960c509
|
@ -34,35 +34,42 @@ public class MainFrame extends JFrame{
|
||||||
|
|
||||||
//TODO refactoring
|
//TODO refactoring
|
||||||
private JButton arrangementButton;
|
private JButton arrangementButton;
|
||||||
private JButton plotButton;
|
|
||||||
private JButton button3;
|
private JButton button3;
|
||||||
|
|
||||||
|
private OutputPanel output;
|
||||||
|
private MenuPanel menupanel;
|
||||||
|
private SidePanel sidepanel;
|
||||||
private JPanel pane;
|
private JPanel pane;
|
||||||
|
|
||||||
|
private ArrangementDialog arrangement;
|
||||||
private JDialog arrangementDialog;
|
private JDialog arrangementDialog;
|
||||||
private JDialog plotDialog;
|
private JDialog plotDialog;
|
||||||
private OutputPanel output;
|
|
||||||
private JPanel menupanel;
|
|
||||||
private JPanel sidepanel;
|
|
||||||
private JSplitPane splitpane;
|
|
||||||
private JScrollPane scrollPane;
|
|
||||||
private ArrangementDialog arrangement;
|
|
||||||
private JTabbedPane tabbedPane;
|
|
||||||
private PlotDialog plot;
|
private PlotDialog plot;
|
||||||
|
|
||||||
|
|
||||||
|
private JSplitPane splitpane;
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
|
||||||
|
private JTabbedPane tabbedPane;
|
||||||
|
|
||||||
public MainFrame() {
|
public MainFrame() {
|
||||||
initGUI();
|
initializeComponents();
|
||||||
|
setDimensions();
|
||||||
|
setLayouts();
|
||||||
|
setTitles();
|
||||||
|
|
||||||
|
addComponents();
|
||||||
|
|
||||||
|
setCloseOperations();
|
||||||
|
setActionListeners();
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Presenter getPresenter() {
|
|
||||||
return presenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPresenter(Presenter presenter) {
|
/*******************************************************************************************************************
|
||||||
this.presenter = presenter;
|
* visualisierungs methoden
|
||||||
}
|
******************************************************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
* visualisierungs methoden
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void createArrangement() {
|
public void createArrangement() {
|
||||||
if (arrangement == null) {
|
if (arrangement == null) {
|
||||||
|
@ -78,90 +85,112 @@ public class MainFrame extends JFrame{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createPlot(double m, double b) {
|
public void createPlot(double m, double b) {
|
||||||
plot = new PlotDialog();
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
plot = new PlotDialog();
|
||||||
plot.createPlot(getPresenter().getLines());
|
SwingUtilities.invokeLater(() -> {
|
||||||
plot.addLineToPlot(m, b);
|
plot.createPlot(getPresenter().getLines());
|
||||||
plotDialog.add(plot);
|
plot.addLineToPlot(m, b);
|
||||||
plotDialog.setVisible(true);
|
plotDialog.add(plot);
|
||||||
});
|
plotDialog.setVisible(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************************************************/
|
|
||||||
/**
|
|
||||||
* init GUI
|
/*******************************************************************************************************************
|
||||||
*/
|
* init GUI
|
||||||
protected void initGUI() {
|
******************************************************************************************************************/
|
||||||
|
private void setTitles(){
|
||||||
this.setTitle("MainFrame");
|
this.setTitle("MainFrame");
|
||||||
this.setSize(1900, 1000);
|
|
||||||
this.setLayout(new BorderLayout());
|
|
||||||
pane = new JPanel();
|
|
||||||
sidepanel = new SidePanel();
|
|
||||||
sidepanel.setMinimumSize(new Dimension(400,500));
|
|
||||||
pane.setLayout(new FlowLayout());
|
|
||||||
|
|
||||||
menupanel = new MenuPanel();
|
|
||||||
tabbedPane = new JTabbedPane();
|
|
||||||
|
|
||||||
arrangementDialog = new JDialog();
|
|
||||||
plotDialog = new JDialog();
|
|
||||||
arrangementDialog.setSize(new Dimension(800, 800));
|
|
||||||
plotDialog.setSize(new Dimension(700, 470));
|
|
||||||
arrangementDialog.setTitle("Dual Representation - Dialog");
|
arrangementDialog.setTitle("Dual Representation - Dialog");
|
||||||
plotDialog.setTitle("Scatter Plot - Dialog");
|
plotDialog.setTitle("Scatter Plot - Dialog");
|
||||||
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
button3.setText("Import");
|
||||||
plotDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
arrangementButton.setText("Dualraum");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupTabbedPane(){
|
||||||
|
|
||||||
output = new OutputPanel();
|
|
||||||
splitpane = new JSplitPane();
|
|
||||||
output.setMinimumSize(new Dimension(400,500));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
arrangementButton = new JButton("Arrangement");
|
|
||||||
plotButton = new JButton("Plot");
|
|
||||||
button3 = new JButton("Import");
|
|
||||||
|
|
||||||
|
|
||||||
arrangementButton.addActionListener((ActionEvent e) -> {
|
|
||||||
Thread t = new Thread(() -> getPresenter().startArrangementVisualization());
|
|
||||||
t.start();
|
|
||||||
});
|
|
||||||
plotButton.addActionListener((ActionEvent e) -> {
|
|
||||||
plotButton.setEnabled(false);
|
|
||||||
Thread t = new Thread(() -> getPresenter().startScatterPlotVisualization());
|
|
||||||
t.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
pane.add(arrangementButton);
|
|
||||||
pane.add(plotButton);
|
|
||||||
pane.add(button3);
|
|
||||||
tabbedPane.add("LMS", sidepanel);
|
tabbedPane.add("LMS", sidepanel);
|
||||||
tabbedPane.add("RM", new JPanel());
|
tabbedPane.add("RM", new JPanel());
|
||||||
tabbedPane.add("TS", 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.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
|
||||||
splitpane.setResizeWeight(.5d);
|
splitpane.setResizeWeight(.5d);
|
||||||
splitpane.setContinuousLayout(true);
|
splitpane.setContinuousLayout(true);
|
||||||
splitpane.setLeftComponent(output);
|
splitpane.setLeftComponent(output);
|
||||||
splitpane.setRightComponent(tabbedPane);
|
splitpane.setRightComponent(tabbedPane);
|
||||||
this.add(pane, BorderLayout.SOUTH);
|
}
|
||||||
this.add(splitpane, BorderLayout.CENTER);
|
|
||||||
this.add(menupanel, BorderLayout.NORTH);
|
private void setCloseOperations(){
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setVisible(true);
|
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||||
|
plotDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDimensions(){
|
||||||
|
this.setSize(1900, 1000);
|
||||||
|
sidepanel.setMinimumSize(new Dimension(400,500));
|
||||||
|
arrangementDialog.setSize(new Dimension(800, 800));
|
||||||
|
plotDialog.setSize(new Dimension(700, 470));
|
||||||
|
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();
|
||||||
|
plotDialog = 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()));
|
||||||
* log Methode
|
t.start();
|
||||||
*/
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************************************************
|
||||||
|
* log Methode
|
||||||
|
******************************************************************************************************************/
|
||||||
|
|
||||||
public void log(String s) {
|
public void log(String s) {
|
||||||
SwingUtilities.invokeLater(() -> output.appendParagraph(s));
|
SwingUtilities.invokeLater(() -> output.appendParagraph(s));
|
||||||
|
@ -182,11 +211,9 @@ public class MainFrame extends JFrame{
|
||||||
public void createTable(List<String> heading, List<List<String>> rows){
|
public void createTable(List<String> heading, List<List<String>> rows){
|
||||||
SwingUtilities.invokeLater(() -> output.logTable(heading, rows));
|
SwingUtilities.invokeLater(() -> output.logTable(heading, rows));
|
||||||
}
|
}
|
||||||
|
/*******************************************************************************************************************
|
||||||
/******************************************************************************************************************/
|
* Getter und Setter Methoden
|
||||||
/**
|
******************************************************************************************************************/
|
||||||
* Getter und Setter Methoden!
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Boolean getLmsIsComplete() {
|
public Boolean getLmsIsComplete() {
|
||||||
return lmsIsComplete;
|
return lmsIsComplete;
|
||||||
|
@ -220,14 +247,6 @@ public class MainFrame extends JFrame{
|
||||||
this.arrangementButton = arrangementButton;
|
this.arrangementButton = arrangementButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JButton getPlotButton() {
|
|
||||||
return plotButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlotButton(JButton plotButton) {
|
|
||||||
this.plotButton = plotButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getButton3() {
|
public JButton getButton3() {
|
||||||
return button3;
|
return button3;
|
||||||
}
|
}
|
||||||
|
@ -272,18 +291,10 @@ public class MainFrame extends JFrame{
|
||||||
return menupanel;
|
return menupanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMenupanel(JPanel menupanel) {
|
|
||||||
this.menupanel = menupanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getSidepanel() {
|
public JPanel getSidepanel() {
|
||||||
return sidepanel;
|
return sidepanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSidepanel(JPanel sidepanel) {
|
|
||||||
this.sidepanel = sidepanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSplitPane getSplitpane() {
|
public JSplitPane getSplitpane() {
|
||||||
return splitpane;
|
return splitpane;
|
||||||
}
|
}
|
||||||
|
@ -308,4 +319,12 @@ public class MainFrame extends JFrame{
|
||||||
public void setPlot(PlotDialog plot) {
|
public void setPlot(PlotDialog plot) {
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Presenter getPresenter() {
|
||||||
|
return presenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPresenter(Presenter presenter) {
|
||||||
|
this.presenter = presenter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class PlotDialog extends JPanel {
|
||||||
this.setPreferredSize(new Dimension(800, 500));
|
this.setPreferredSize(new Dimension(800, 500));
|
||||||
this.setMinimumSize(new Dimension(800, 500));
|
this.setMinimumSize(new Dimension(800, 500));
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPlot(LinkedList<Line> points) {
|
public void createPlot(LinkedList<Line> points) {
|
||||||
|
@ -95,8 +96,8 @@ public class PlotDialog extends JPanel {
|
||||||
public void addLineToPlot(double m, double b) {
|
public void addLineToPlot(double m, double b) {
|
||||||
linesA = new XYSeries("linesA");
|
linesA = new XYSeries("linesA");
|
||||||
JOptionPane.showMessageDialog(null, "m: "+m+" b: "+b);
|
JOptionPane.showMessageDialog(null, "m: "+m+" b: "+b);
|
||||||
linesA.add(min.intValue(), min.intValue() * (-1) * m + b );
|
linesA.add(min.intValue(), min.intValue() * m + b );
|
||||||
linesA.add(max.intValue(), max.intValue() * (-1) * m + b );
|
linesA.add(max.intValue(), max.intValue() * m + b );
|
||||||
|
|
||||||
datapoints.addSeries(linesA);
|
datapoints.addSeries(linesA);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package View;
|
package View;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.LineBorder;
|
|
||||||
import javax.swing.border.MatteBorder;
|
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
@ -17,15 +15,15 @@ public class SidePanel extends JPanel {
|
||||||
|
|
||||||
|
|
||||||
private JLabel[] labels;
|
private JLabel[] labels;
|
||||||
private JTextField[] text;
|
private JTextField[] input;
|
||||||
|
private JButton startButton;
|
||||||
private JPanel continer;
|
private JPanel continer;
|
||||||
private GridBagConstraints gbc;
|
private GridBagConstraints gbc;
|
||||||
|
|
||||||
public SidePanel(){
|
public SidePanel(){
|
||||||
|
|
||||||
this.setBorder(new TitledBorder("Eingabefelder"));
|
this.setBorder(new TitledBorder("Eingabefelder"));
|
||||||
this.labels = new JLabel[10];
|
this.labels = new JLabel[10];
|
||||||
this.text = new JTextField[10];
|
this.input = new JTextField[10];
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
this.continer = new JPanel();
|
this.continer = new JPanel();
|
||||||
continer.setLayout(new GridBagLayout());;
|
continer.setLayout(new GridBagLayout());;
|
||||||
|
@ -33,19 +31,19 @@ public class SidePanel extends JPanel {
|
||||||
gbc.anchor = GridBagConstraints.NORTH;
|
gbc.anchor = GridBagConstraints.NORTH;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
|
||||||
|
addTextfieldAndInput(0, "Konstante", 1.0);
|
||||||
|
addTextfieldAndInput(1, "Fehler", 0.005);
|
||||||
|
|
||||||
addElement(0, "Konstante");
|
startButton = new JButton("start");
|
||||||
addElement(1, "Fehler");
|
addButton(2, startButton);
|
||||||
addElement(2,"Quantile");
|
|
||||||
|
|
||||||
this.add(continer, BorderLayout.NORTH);
|
this.add(continer, BorderLayout.NORTH);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addElement(int row, String name){
|
private void addTextfieldAndInput(int row, String name, Double value){
|
||||||
this.labels[row] = new JLabel(name);
|
this.labels[row] = new JLabel(name);
|
||||||
this.text[row] = new JTextField();
|
this.input[row] = new JTextField();
|
||||||
|
this.input[row].setText(""+value);
|
||||||
|
|
||||||
gbc.insets = new Insets(0, 5,0,0);
|
gbc.insets = new Insets(0, 5,0,0);
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
|
@ -59,6 +57,32 @@ public class SidePanel extends JPanel {
|
||||||
gbc.weightx = 0.9;
|
gbc.weightx = 0.9;
|
||||||
gbc.weighty = 0.05;
|
gbc.weighty = 0.05;
|
||||||
gbc.insets = new Insets(0, 0,0,5);
|
gbc.insets = new Insets(0, 0,0,5);
|
||||||
continer.add(this.text[row], gbc);
|
continer.add(this.input[row], gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addButton(int row, JButton button){
|
||||||
|
|
||||||
|
gbc.insets = new Insets(30, 5,0,0);
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.weightx = 0.05;
|
||||||
|
gbc.weighty = 0.05;
|
||||||
|
|
||||||
|
continer.add(button, gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getStartButton() {
|
||||||
|
return startButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getInput() {
|
||||||
|
String[] input = new String[3];
|
||||||
|
input[0] = this.input[0].getText();
|
||||||
|
input[1] = this.input[1].getText();
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(JTextField[] input) {
|
||||||
|
this.input = input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue