2017-10-12 15:21:16 +00:00
|
|
|
import model.Line;
|
2017-09-10 15:45:47 +00:00
|
|
|
import model.LineModel;
|
2020-03-20 17:08:18 +00:00
|
|
|
import model.Point;
|
2017-09-10 15:45:47 +00:00
|
|
|
import presenter.Presenter;
|
2017-10-17 06:34:55 +00:00
|
|
|
import presenter.algorithms.advanced.LeastMedianOfSquaresEstimator;
|
2017-10-12 15:21:16 +00:00
|
|
|
import presenter.algorithms.advanced.RepeatedMedianEstimator;
|
2017-10-17 06:34:55 +00:00
|
|
|
import presenter.algorithms.advanced.TheilSenEstimator;
|
|
|
|
import presenter.algorithms.naiv.NaivLeastMedianOfSquaresEstimator;
|
|
|
|
import presenter.algorithms.naiv.NaivRepeatedMedianEstimator;
|
|
|
|
import presenter.algorithms.naiv.NaivTheilSenEstimator;
|
2017-10-12 15:21:16 +00:00
|
|
|
import presenter.generator.DatasetGenerator;
|
2020-03-20 17:08:18 +00:00
|
|
|
import presenter.util.IntersectionComputer;
|
2017-09-10 15:45:47 +00:00
|
|
|
import view.MainFrame;
|
2017-08-03 18:37:59 +00:00
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
2017-10-17 06:34:55 +00:00
|
|
|
import java.util.ArrayList;
|
2017-10-12 15:21:16 +00:00
|
|
|
import java.util.LinkedList;
|
|
|
|
|
2017-05-29 12:15:51 +00:00
|
|
|
/**
|
|
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
|
|
*
|
|
|
|
* @Author: Armin Wolf
|
|
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
|
|
* @Date: 28.05.2017.
|
|
|
|
*/
|
|
|
|
public class App {
|
|
|
|
|
2020-03-20 17:08:18 +00:00
|
|
|
/**
|
|
|
|
* Laden der native Library für OpenCV
|
|
|
|
*/
|
|
|
|
static {
|
|
|
|
nu.pattern.OpenCV.loadShared();
|
|
|
|
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
|
|
|
|
}
|
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Schriftart wird neu gesetzt
|
2020-03-20 17:08:18 +00:00
|
|
|
*
|
2017-10-17 06:34:55 +00:00
|
|
|
* @param f Schriftart
|
|
|
|
*/
|
2017-09-10 15:45:47 +00:00
|
|
|
private static void setUIFont(javax.swing.plaf.FontUIResource f) {
|
|
|
|
java.util.Enumeration<Object> keys = UIManager.getDefaults().keys();
|
|
|
|
while (keys.hasMoreElements()) {
|
|
|
|
Object key = keys.nextElement();
|
|
|
|
Object value = UIManager.get(key);
|
|
|
|
if (value instanceof javax.swing.plaf.FontUIResource) {
|
|
|
|
UIManager.put(key, f);
|
|
|
|
}
|
|
|
|
}
|
2017-06-21 15:41:40 +00:00
|
|
|
}
|
2017-06-23 16:17:11 +00:00
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Das LookAndFeel wird neu gesetzt.
|
2020-03-20 17:08:18 +00:00
|
|
|
*
|
|
|
|
* @param view View Klasse
|
2017-10-17 06:34:55 +00:00
|
|
|
*/
|
2017-09-10 15:45:47 +00:00
|
|
|
private static void setLookAndFeel(JFrame view) {
|
|
|
|
String[] laf = {"com.jtattoo.plaf.aluminium.AluminiumLookAndFeel",
|
2017-09-19 11:34:06 +00:00
|
|
|
"com.jtattoo.plaf.acryl.AcrylLookAndFeel",
|
|
|
|
"com.jtattoo.plaf.aero.AeroLookAndFeel",
|
|
|
|
"com.jtattoo.plaf.fast.FastLookAndFeel",
|
2017-10-13 09:53:45 +00:00
|
|
|
"com.jtattoo.plaf.graphite.GraphiteLookAndFeel",
|
|
|
|
"com.jtattoo.plaf.luna.LunaLookAndFeel",
|
|
|
|
"com.jtattoo.plaf.noire.NoireLookAndFeel"};
|
2017-09-10 15:45:47 +00:00
|
|
|
try {
|
|
|
|
UIManager.setLookAndFeel(laf[4]);
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (UnsupportedLookAndFeelException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
SwingUtilities.updateComponentTreeUI(view);
|
|
|
|
}
|
2017-05-29 12:15:51 +00:00
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
/**
|
|
|
|
* Die Methode rechnet für gegebene Größen die Algorithmen durch und gibt jeweils die benötigte Zeit
|
|
|
|
*/
|
2017-10-12 15:21:16 +00:00
|
|
|
public static void benchmark() {
|
|
|
|
int[] sizes = {50, 500, 1000, 3000, 5000, 10000};
|
|
|
|
|
|
|
|
for (int i = 5; i < sizes.length; i++) {
|
|
|
|
System.out.println("---- Datasetgröße: " + sizes[i] + " ----");
|
|
|
|
DatasetGenerator generator = new DatasetGenerator();
|
|
|
|
LinkedList<Line> lines = generator.generateDataCloud(sizes[i]);
|
2017-10-17 06:34:55 +00:00
|
|
|
IntersectionComputer computer = new IntersectionComputer(lines);
|
|
|
|
ArrayList<Point> points = computer.compute();
|
2017-10-12 15:21:16 +00:00
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
NaivLeastMedianOfSquaresEstimator naivLms = new NaivLeastMedianOfSquaresEstimator(lines);
|
|
|
|
naivLms.run();
|
2017-10-12 15:21:16 +00:00
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
NaivRepeatedMedianEstimator naivRm = new NaivRepeatedMedianEstimator(lines);
|
|
|
|
naivRm.run();
|
2017-10-12 15:21:16 +00:00
|
|
|
|
2017-10-17 06:34:55 +00:00
|
|
|
NaivTheilSenEstimator naivTs = new NaivTheilSenEstimator(lines);
|
|
|
|
naivTs.run();
|
|
|
|
|
2020-03-20 17:08:18 +00:00
|
|
|
LeastMedianOfSquaresEstimator lms = new LeastMedianOfSquaresEstimator(lines, points);
|
2017-10-17 06:34:55 +00:00
|
|
|
lms.run();
|
2017-10-12 15:21:16 +00:00
|
|
|
|
|
|
|
RepeatedMedianEstimator rm = new RepeatedMedianEstimator(lines);
|
|
|
|
rm.run();
|
|
|
|
|
2020-03-20 17:08:18 +00:00
|
|
|
TheilSenEstimator ts = new TheilSenEstimator(lines, points);
|
2017-10-17 06:34:55 +00:00
|
|
|
ts.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maim Methode
|
2020-03-20 17:08:18 +00:00
|
|
|
*
|
2017-10-17 06:34:55 +00:00
|
|
|
* @param args
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
2020-03-20 17:08:18 +00:00
|
|
|
if (args.length > 0 && args[0] == "--benchmark") {
|
2017-10-17 06:34:55 +00:00
|
|
|
benchmark();
|
|
|
|
} else {
|
|
|
|
final Presenter presenter = new Presenter(new LineModel(), null);
|
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
|
//JFrame.setDefaultLookAndFeelDecorated(true);
|
|
|
|
MainFrame view = new MainFrame();
|
|
|
|
setLookAndFeel(view);
|
|
|
|
setUIFont(new javax.swing.plaf.FontUIResource(new Font("SansSerif", Font.PLAIN, 12)));
|
|
|
|
|
|
|
|
view.setPresenter(presenter);
|
|
|
|
view.setActionListeners();
|
|
|
|
presenter.setView(view);
|
|
|
|
});
|
2017-10-12 15:21:16 +00:00
|
|
|
}
|
2017-09-10 15:45:47 +00:00
|
|
|
}
|
2017-05-29 12:15:51 +00:00
|
|
|
|
|
|
|
}
|