2017-09-10 15:45:47 +00:00
|
|
|
package view.panels.tabs;
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
|
|
*
|
|
|
|
* @Author: Armin Wolf
|
|
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
|
|
* @Date: 02.06.2017.
|
|
|
|
*/
|
|
|
|
public class LMSPanel extends TabPanel {
|
|
|
|
|
|
|
|
|
|
|
|
private JLabel[] labels;
|
|
|
|
private JTextField[] input;
|
|
|
|
private JPanel continer;
|
|
|
|
|
|
|
|
private GridBagConstraints gbc;
|
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Konstruktor
|
|
|
|
*/
|
2017-09-10 15:45:47 +00:00
|
|
|
public LMSPanel() {
|
|
|
|
super();
|
|
|
|
this.labels = new JLabel[2];
|
|
|
|
this.input = new JTextField[2];
|
|
|
|
|
|
|
|
this.continer = new JPanel();
|
|
|
|
this.continer.setLayout(new GridBagLayout());
|
|
|
|
|
|
|
|
this.gbc = new GridBagConstraints();
|
|
|
|
this.gbc.anchor = GridBagConstraints.NORTH;
|
|
|
|
this.gbc.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
|
|
|
addTextfieldAndInput(0, "Konstante", 0.5);
|
|
|
|
addTextfieldAndInput(1, "Fehler", 0.05);
|
|
|
|
|
|
|
|
addButton(2, getStartButton());
|
|
|
|
|
|
|
|
getNorthPanel().add(continer, BorderLayout.CENTER);
|
|
|
|
this.add(getNorthPanel(), BorderLayout.NORTH);
|
|
|
|
this.add(getCenterPanel(), BorderLayout.CENTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void addTextfieldAndInput(int row, String name, Double value) {
|
|
|
|
this.labels[row] = new JLabel(name);
|
|
|
|
this.labels[row].setFont(new Font("SansSerif", Font.PLAIN, 12));
|
|
|
|
this.input[row] = new JTextField();
|
|
|
|
this.input[row].setText("" + value);
|
|
|
|
|
|
|
|
gbc.insets = new Insets(0, 5, 0, 0);
|
|
|
|
gbc.gridx = 0;
|
|
|
|
gbc.gridy = row;
|
|
|
|
gbc.weightx = 0.05;
|
|
|
|
gbc.weighty = 0.05;
|
|
|
|
continer.add(this.labels[row], gbc);
|
|
|
|
|
|
|
|
gbc.gridx = 1;
|
|
|
|
gbc.gridy = row;
|
|
|
|
gbc.weightx = 0.9;
|
|
|
|
gbc.weighty = 0.05;
|
|
|
|
gbc.insets = new Insets(0, 0, 0, 5);
|
|
|
|
continer.add(this.input[row], gbc);
|
|
|
|
}
|
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Hilftmethode um einen Botton an die passende Stelle zu platzieren
|
|
|
|
* @param row Zeile
|
|
|
|
* @param button Button
|
|
|
|
*/
|
2017-09-10 15:45:47 +00:00
|
|
|
private void addButton(int row, JButton button) {
|
|
|
|
JPanel buttonPanel = new JPanel();
|
|
|
|
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
|
|
|
gbc.insets = new Insets(30, 0, 5, 0);
|
|
|
|
|
|
|
|
gbc.gridx = 0;
|
|
|
|
gbc.gridy = row;
|
|
|
|
gbc.weightx = 0.05;
|
|
|
|
gbc.weighty = 0.05;
|
|
|
|
gbc.gridwidth = 1;
|
|
|
|
buttonPanel.add(button);
|
|
|
|
continer.add(buttonPanel, gbc);
|
|
|
|
}
|
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Liefert die Eingaben in Form eines Feldes zurück. Die Parameter werden für den Alg. benötigt.
|
|
|
|
* @return Eingabe
|
|
|
|
*/
|
2017-09-10 15:45:47 +00:00
|
|
|
public String[] getInput() {
|
|
|
|
String[] input = new String[3];
|
|
|
|
input[0] = this.input[0].getText();
|
|
|
|
input[1] = this.input[1].getText();
|
|
|
|
|
|
|
|
if (isNumeric(input[0]) && isNumeric(input[1])) {
|
|
|
|
return input;
|
|
|
|
} else {
|
|
|
|
JOptionPane.showMessageDialog(this, "Bitte geben Sie numerische Werte als Parameter an.", "Fehler bei der Eingabe", JOptionPane.ERROR_MESSAGE);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|