algorithms-for-computing-li.../LinearRegressionTool/src/main/java/de/wwwu/awolf/view/panels/tabs/TabPanel.java

110 lines
2.9 KiB
Java

package de.wwwu.awolf.view.panels.tabs;
import de.wwwu.awolf.view.panels.PlotPanel;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
/**
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
*
* @Author: Armin Wolf
* @Email: a_wolf28@uni-muenster.de
* @Date: 10.09.2017.
*/
public abstract class TabPanel extends JPanel {
private PlotPanel plotPanel;
private JPanel northPanel;
private JPanel centerPanel;
private JButton startButton;
/**
* Konstruktor
*/
public TabPanel() {
super();
this.centerPanel = new JPanel(new BorderLayout());
this.centerPanel.setBorder(new TitledBorder("Visualisierung"));
this.setLayout(new BorderLayout());
this.northPanel = new JPanel(new BorderLayout());
this.centerPanel = new JPanel(new BorderLayout());
this.northPanel.setBorder(new TitledBorder("Konfiguration"));
this.centerPanel.setBorder(new TitledBorder("Visualisierung"));
this.add(centerPanel, BorderLayout.CENTER);
this.add(northPanel, BorderLayout.NORTH);
this.startButton = new JButton("Start");
this.startButton.setFont(new Font("SansSerif", Font.PLAIN, 16));
}
/**
* Fügt in eine Zeile ein Überschrift(JLabel) und eine Eingabekomponente(JTextField)
*
* @param row Zeile
* @param name Überschrift
* @param value Standardwert
*/
protected void addTextfieldAndInput(int row, String name, Double value) {
//muss nicht obligatorisch implementiert werden
}
/**
* Hilftmethode um den Plotpanel erst bei Vorhandenen Ergebnissen hinzufügen zu können
*
* @param plotPanel Plotpanel
*/
public void setPlotPanel(PlotPanel plotPanel) {
this.plotPanel = plotPanel;
if (this.centerPanel.getComponents().length > 0)
this.centerPanel.remove(0);
this.centerPanel.add(plotPanel, BorderLayout.CENTER);
this.plotPanel.setVisible(true);
this.repaint();
this.revalidate();
}
/**
* @return gibt den Startbutton zurück
*/
public JButton getStartButton() {
return startButton;
}
/**
* @return gibt das obere Panel zurück
*/
public JPanel getNorthPanel() {
return northPanel;
}
/**
* @return gibt das untere Panel zurück
*/
public JPanel getCenterPanel() {
return centerPanel;
}
/**
* Hilfmethode zum prüfen ob die Eingabe numerisch ist.
*
* @param str Eingabe
* @return <code>true</code>, falls es sich bei der Eingabe um numerische Werte handelt
*/
public boolean isNumeric(String str) {
try {
double d = Double.parseDouble(str);
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
}