|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
package View.Panels;
|
|
|
|
|
|
|
|
|
|
import Model.Line;
|
|
|
|
|
import View.MainFrame;
|
|
|
|
|
|
|
|
|
|
import View.PlotDialog;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.border.TitledBorder;
|
|
|
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
@ -15,83 +19,161 @@ public class EvaluationPanel extends JPanel{
|
|
|
|
|
private final MainFrame view;
|
|
|
|
|
private JTable table;
|
|
|
|
|
private JButton start;
|
|
|
|
|
private JButton stop;
|
|
|
|
|
private JRadioButton evalTypeOne; //1: Alg - N: Data
|
|
|
|
|
private JRadioButton evalTypeTwo; //N: Alg - 1: Data
|
|
|
|
|
private ButtonGroup radiobuttonGroup;
|
|
|
|
|
private ButtonGroup checkboxGroup;
|
|
|
|
|
|
|
|
|
|
private JCheckBox lms; //1: Alg - N: Data
|
|
|
|
|
private JCheckBox rm; //N: Alg - 1: Data
|
|
|
|
|
private JCheckBox ts; //1: Alg - N: Data
|
|
|
|
|
|
|
|
|
|
private JPanel comp;
|
|
|
|
|
private JTextField iIteration;
|
|
|
|
|
private JTextField iSlope;
|
|
|
|
|
private JTextField iYinterception;
|
|
|
|
|
private JLabel lIteration;
|
|
|
|
|
private JLabel lSlope;
|
|
|
|
|
private JLabel lYinterception;
|
|
|
|
|
private JPanel algorithmPanel;
|
|
|
|
|
private JPanel leftSidePanel;
|
|
|
|
|
private JPanel datasetCount;
|
|
|
|
|
private JComboBox<Integer> datasetCountChoice;
|
|
|
|
|
private JLabel datasetCountLabel;
|
|
|
|
|
|
|
|
|
|
private JSplitPane splitPane;
|
|
|
|
|
|
|
|
|
|
private DefaultTableModel model;
|
|
|
|
|
private JPanel buttonPanel;
|
|
|
|
|
private PlotDialog plotDialog;
|
|
|
|
|
|
|
|
|
|
public EvaluationPanel(MainFrame view){
|
|
|
|
|
super();
|
|
|
|
|
this.view = view;
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
this.setBorder(new TitledBorder("Evaluation der Algorithmen"));
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
addComponents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addComponents(){
|
|
|
|
|
lIteration = new JLabel("Interationen");
|
|
|
|
|
lSlope = new JLabel("Steigung");
|
|
|
|
|
lYinterception = new JLabel("y-Achsenabschnitt");
|
|
|
|
|
private void init(){
|
|
|
|
|
datasetCountLabel = new JLabel("Anzahl der Datensätze");
|
|
|
|
|
Integer[] choice = {1,2,3,4,5,6,7,8,9,10};
|
|
|
|
|
datasetCountChoice = new JComboBox(choice);
|
|
|
|
|
|
|
|
|
|
iIteration = new JTextField();
|
|
|
|
|
iSlope = new JTextField();
|
|
|
|
|
iYinterception = new JTextField();
|
|
|
|
|
start = new JButton("Start");
|
|
|
|
|
stop = new JButton("Stop");
|
|
|
|
|
|
|
|
|
|
evalTypeOne = new JRadioButton("1 Algorithmus - N Datensätze");
|
|
|
|
|
evalTypeTwo = new JRadioButton("N Algorithmen - 1 Datensatz");
|
|
|
|
|
lms = new JCheckBox ("Least Median of Squares");
|
|
|
|
|
rm = new JCheckBox ("Repeated Median");
|
|
|
|
|
ts = new JCheckBox ("Theil-Sen");
|
|
|
|
|
radiobuttonGroup = new ButtonGroup();
|
|
|
|
|
checkboxGroup = new ButtonGroup();
|
|
|
|
|
buttonPanel = new JPanel(new FlowLayout());
|
|
|
|
|
leftSidePanel = new JPanel(new BorderLayout());
|
|
|
|
|
comp = new JPanel(new GridLayout(0,1));
|
|
|
|
|
plotDialog = new PlotDialog();
|
|
|
|
|
model = new DefaultTableModel(){
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCellEditable(int row, int column) {
|
|
|
|
|
//all cells false
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
table = new JTable(model);
|
|
|
|
|
splitPane = new JSplitPane();
|
|
|
|
|
algorithmPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
datasetCount = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addComponents(){
|
|
|
|
|
evalTypeOne.setSelected(true);
|
|
|
|
|
checkboxGroup.add(lms);
|
|
|
|
|
checkboxGroup.add(rm);
|
|
|
|
|
checkboxGroup.add(ts);
|
|
|
|
|
evalTypeOne.addActionListener(e -> {
|
|
|
|
|
checkboxGroup.add(lms);
|
|
|
|
|
checkboxGroup.add(rm);
|
|
|
|
|
checkboxGroup.add(ts);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
evalTypeTwo.addActionListener(e -> {
|
|
|
|
|
checkboxGroup.remove(lms);
|
|
|
|
|
checkboxGroup.remove(rm);
|
|
|
|
|
checkboxGroup.remove(ts);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
radiobuttonGroup.add(evalTypeOne);
|
|
|
|
|
radiobuttonGroup.add(evalTypeTwo);
|
|
|
|
|
buttonPanel.add(start);
|
|
|
|
|
//buttonPanel.add(stop);
|
|
|
|
|
|
|
|
|
|
comp = new JPanel();
|
|
|
|
|
comp.setLayout(new GridLayout(0,2));
|
|
|
|
|
comp.add(lIteration);
|
|
|
|
|
comp.add(iIteration);
|
|
|
|
|
comp.add(lSlope);
|
|
|
|
|
comp.add(iSlope);
|
|
|
|
|
comp.add(lYinterception);
|
|
|
|
|
comp.add(iYinterception);
|
|
|
|
|
algorithmPanel.add(lms);
|
|
|
|
|
algorithmPanel.add(rm);
|
|
|
|
|
algorithmPanel.add(ts);
|
|
|
|
|
|
|
|
|
|
datasetCount.add(datasetCountLabel);
|
|
|
|
|
datasetCount.add(datasetCountChoice);
|
|
|
|
|
|
|
|
|
|
comp.add(evalTypeOne);
|
|
|
|
|
comp.add(evalTypeTwo);
|
|
|
|
|
comp.add(algorithmPanel);
|
|
|
|
|
comp.add(datasetCount);
|
|
|
|
|
|
|
|
|
|
start.addActionListener(e -> {
|
|
|
|
|
String[] params = {iSlope.getText(), iYinterception.getText(), iIteration.getText() };
|
|
|
|
|
view.getPresenter().startEvaluation(params);
|
|
|
|
|
view.getPresenter().startEvaluation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
stop.addActionListener(e -> {
|
|
|
|
|
view.getPresenter().stopEvaluation();
|
|
|
|
|
});
|
|
|
|
|
comp.setBorder(new TitledBorder("Konfiguration"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Tabelle
|
|
|
|
|
String[] selections = { "Approximationsgüte","Theil-Sen", "Repeated-Median", "Least Median of Squares"};
|
|
|
|
|
model = new DefaultTableModel(){
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCellEditable(int row, int column) {
|
|
|
|
|
//all cells false
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
model.setColumnIdentifiers(selections);
|
|
|
|
|
|
|
|
|
|
table = new JTable(model);
|
|
|
|
|
table.setDragEnabled(true);
|
|
|
|
|
|
|
|
|
|
JScrollPane scrollPane = new JScrollPane(table);
|
|
|
|
|
scrollPane.setWheelScrollingEnabled(true);
|
|
|
|
|
this.add(scrollPane, BorderLayout.CENTER);
|
|
|
|
|
this.add(comp, BorderLayout.NORTH);
|
|
|
|
|
scrollPane.setBorder(new TitledBorder("Ergebnisse"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Plot
|
|
|
|
|
plotDialog.createPlot(new LinkedList<>());
|
|
|
|
|
plotDialog.setBorder(new TitledBorder("Plot"));
|
|
|
|
|
|
|
|
|
|
leftSidePanel.add(comp, BorderLayout.NORTH);
|
|
|
|
|
leftSidePanel.add(scrollPane, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
|
|
//Splitpane
|
|
|
|
|
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
|
|
|
|
|
splitPane.setResizeWeight(.5d);
|
|
|
|
|
splitPane.setContinuousLayout(true);
|
|
|
|
|
splitPane.setLeftComponent(leftSidePanel);
|
|
|
|
|
splitPane.setRightComponent(plotDialog);
|
|
|
|
|
|
|
|
|
|
this.add(splitPane, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
|
|
this.add(buttonPanel, BorderLayout.SOUTH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void appendData(Object[] row){
|
|
|
|
|
model.addRow(row);
|
|
|
|
|
this.repaint();
|
|
|
|
|
this.revalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void drawLines(Object[] results){
|
|
|
|
|
String[] castedResults = Arrays.copyOf(results, results.length, String[].class);
|
|
|
|
|
Paint[] color = {Color.ORANGE,Color.ORANGE, Color.RED,Color.RED, Color.MAGENTA,Color.MAGENTA};
|
|
|
|
|
String[] name = {"LMS","", "RM","", "TS"};
|
|
|
|
|
for (int i=0;i<6;i=i+2){
|
|
|
|
|
Double m = Double.parseDouble(castedResults[i]);
|
|
|
|
|
Double b = Double.parseDouble(castedResults[i+1]);
|
|
|
|
|
plotDialog.addLineToPlot(m,b,color[i],name[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDualPoints(LinkedList<Line> points){
|
|
|
|
|
plotDialog = new PlotDialog();
|
|
|
|
|
plotDialog.setBorder(new TitledBorder("Plot"));
|
|
|
|
|
splitPane.setRightComponent(plotDialog);
|
|
|
|
|
plotDialog.createPlot(points);
|
|
|
|
|
plotDialog.repaint();
|
|
|
|
|
plotDialog.revalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|