125 lines
4.3 KiB
Java
125 lines
4.3 KiB
Java
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
|
|
import model.Line;
|
|
import model.LineModel;
|
|
import nu.pattern.OpenCV;
|
|
import org.apache.commons.io.IOUtils;
|
|
import presenter.Presenter;
|
|
import presenter.algorithms.advanced.RepeatedMedianEstimator;
|
|
import presenter.generator.DatasetGenerator;
|
|
import view.MainFrame;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.util.LinkedList;
|
|
|
|
import static nu.pattern.OpenCV.loadShared;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 28.05.2017.
|
|
*/
|
|
public class App {
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void setLookAndFeel(JFrame view) {
|
|
String[] laf = {"com.jtattoo.plaf.aluminium.AluminiumLookAndFeel",
|
|
"com.jtattoo.plaf.acryl.AcrylLookAndFeel",
|
|
"com.jtattoo.plaf.aero.AeroLookAndFeel",
|
|
"com.jtattoo.plaf.fast.FastLookAndFeel",
|
|
"com.jtattoo.plaf.graphite.GraphiteLookAndFeel",
|
|
"com.jtattoo.plaf.luna.LunaLookAndFeel",
|
|
"com.jtattoo.plaf.noire.NoireLookAndFeel"};
|
|
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);
|
|
}
|
|
|
|
static {
|
|
nu.pattern.OpenCV.loadShared();
|
|
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
|
|
final String[] options = {"Normal", "Benchmark"};
|
|
String chosen = (String) JOptionPane.showInputDialog(null,
|
|
"Bitte wählen Sie eine Ansicht!",
|
|
"Ausführungsoptionen",
|
|
JOptionPane.QUESTION_MESSAGE,
|
|
null,
|
|
options,
|
|
options[0]);
|
|
if (chosen == "Normal"){
|
|
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("Verdana", Font.PLAIN, 12)));
|
|
view.setPresenter(presenter);
|
|
view.setActionListeners();
|
|
presenter.setView(view);
|
|
});} else {
|
|
benchmark();
|
|
}
|
|
}
|
|
|
|
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]);
|
|
// IntersectionComputer computer = new IntersectionComputer(lines);
|
|
// ArrayList<Point> points = computer.compute();
|
|
|
|
//algorithms
|
|
//NaivLeastMedianOfSquaresEstimator naivLms = new NaivLeastMedianOfSquaresEstimator(lines);
|
|
//naivLms.run();
|
|
|
|
// NaivRepeatedMedianEstimator naivRm = new NaivRepeatedMedianEstimator(lines);
|
|
// naivRm.run();
|
|
//
|
|
// NaivTheilSenEstimator naivTs = new NaivTheilSenEstimator(lines);
|
|
// naivTs.run();
|
|
|
|
// LeastMedianOfSquaresEstimator lms = new LeastMedianOfSquaresEstimator(lines,points);
|
|
// lms.run();
|
|
|
|
RepeatedMedianEstimator rm = new RepeatedMedianEstimator(lines);
|
|
rm.run();
|
|
|
|
// TheilSenEstimator ts = new TheilSenEstimator(lines,points);
|
|
// ts.run();
|
|
}
|
|
}
|
|
|
|
}
|