101 lines
3.2 KiB
Java
101 lines
3.2 KiB
Java
import model.LineModel;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.opencv.core.Core;
|
|
import presenter.Presenter;
|
|
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;
|
|
|
|
/**
|
|
* 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 loadLibrary() {
|
|
try {
|
|
InputStream in = null;
|
|
File fileOut = null;
|
|
String osName = System.getProperty("os.name");
|
|
|
|
int bitness = Integer.parseInt(System.getProperty("sun.arch.data.model"));
|
|
if(bitness == 32){
|
|
in = App.class.getResourceAsStream("/libs/x86/opencv_java2413.dll");
|
|
fileOut = File.createTempFile("tmp", ".dll");
|
|
}
|
|
else if (bitness == 64){
|
|
in = App.class.getResourceAsStream("/libs/x64/opencv_java2413.dll");
|
|
fileOut = File.createTempFile("tmp", ".dll");
|
|
}
|
|
|
|
OutputStream out = new FileOutputStream(fileOut);
|
|
IOUtils.copy(in, out);
|
|
in.close();
|
|
out.close();
|
|
System.load(fileOut.toString());
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("Failed to load opencv native library", e);
|
|
}
|
|
}
|
|
|
|
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"};
|
|
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);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
loadLibrary();
|
|
|
|
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);
|
|
});
|
|
|
|
}
|
|
|
|
}
|