|
|
|
@ -2,23 +2,21 @@ package de.wwwu.awolf.view;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import de.wwwu.awolf.model.Line;
|
|
|
|
|
import de.wwwu.awolf.presenter.Presenter;
|
|
|
|
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
|
|
|
|
import de.wwwu.awolf.presenter.data.DataHandler;
|
|
|
|
|
import de.wwwu.awolf.presenter.util.Logging;
|
|
|
|
|
import de.wwwu.awolf.view.controller.AlgorithmTabController;
|
|
|
|
|
import de.wwwu.awolf.view.services.DataService;
|
|
|
|
|
import javafx.application.Platform;
|
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
|
import javafx.event.EventHandler;
|
|
|
|
|
import javafx.fxml.FXMLLoader;
|
|
|
|
|
import javafx.scene.Node;
|
|
|
|
|
import javafx.scene.Parent;
|
|
|
|
|
import javafx.scene.control.*;
|
|
|
|
|
import javafx.stage.FileChooser;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
|
|
@ -34,10 +32,15 @@ public class ViewController {
|
|
|
|
|
|
|
|
|
|
public TabPane tabPane;
|
|
|
|
|
public MenuBar menuBar;
|
|
|
|
|
public TextArea logArea;
|
|
|
|
|
private Map<Algorithm.Type, AlgorithmTabController> algorithmTabControllers;
|
|
|
|
|
|
|
|
|
|
public Map<Algorithm.Type, AlgorithmTabController> getAlgorithmTabControllers() {
|
|
|
|
|
return algorithmTabControllers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewController() {
|
|
|
|
|
super();
|
|
|
|
|
this.algorithmTabControllers = new EnumMap<>(Algorithm.Type.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initGui() {
|
|
|
|
@ -54,7 +57,6 @@ public class ViewController {
|
|
|
|
|
props.put("dsfsdfsdf", "dsadasd");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
for (Algorithm.Type value : Algorithm.Type.values()) {
|
|
|
|
|
FXMLLoader loader = new FXMLLoader();
|
|
|
|
@ -63,7 +65,9 @@ public class ViewController {
|
|
|
|
|
AlgorithmTabController controller = loader.getController();
|
|
|
|
|
controller.setAlgorithmType(value);
|
|
|
|
|
controller.setProperties(props);
|
|
|
|
|
controller.setModel(Presenter.getInstance().getModel());
|
|
|
|
|
controller.init();
|
|
|
|
|
this.algorithmTabControllers.put(value, controller);
|
|
|
|
|
Tab tab = new Tab(value.getName(), parent);
|
|
|
|
|
tab.setId(value.name());
|
|
|
|
|
tabPane.getTabs().add(tab);
|
|
|
|
@ -74,7 +78,6 @@ public class ViewController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initMenuBar() {
|
|
|
|
@ -84,18 +87,39 @@ public class ViewController {
|
|
|
|
|
Menu helpMenu = new Menu("Help");
|
|
|
|
|
|
|
|
|
|
// Create MenuItems
|
|
|
|
|
//export the data
|
|
|
|
|
MenuItem exportItem = new MenuItem("Export");
|
|
|
|
|
exportItem.setOnAction(actionEvent -> {
|
|
|
|
|
FileChooser fileChooser = new FileChooser();
|
|
|
|
|
File file = fileChooser.showOpenDialog(null);
|
|
|
|
|
if (file != null && file.canWrite() && file.canRead()) {
|
|
|
|
|
new DataService(DataHandler.ActionType.EXPORT, file).start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//start an import of data
|
|
|
|
|
MenuItem importItem = new MenuItem("Import");
|
|
|
|
|
importItem.setOnAction(actionEvent -> {
|
|
|
|
|
FileChooser fileChooser = new FileChooser();
|
|
|
|
|
File file = fileChooser.showOpenDialog(null);
|
|
|
|
|
if (file != null && file.canWrite() && file.canRead()) {
|
|
|
|
|
new DataService(DataHandler.ActionType.IMPORT, file).start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//exit menu item should stop the application
|
|
|
|
|
MenuItem exitItem = new MenuItem("Exit");
|
|
|
|
|
exitItem.setOnAction(actionEvent -> {
|
|
|
|
|
Platform.exit();
|
|
|
|
|
System.exit(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// about the application
|
|
|
|
|
MenuItem aboutItem = new MenuItem("About");
|
|
|
|
|
|
|
|
|
|
MenuItem generationItem = new MenuItem("Generate");
|
|
|
|
|
generationItem.setOnAction(new EventHandler<ActionEvent>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(ActionEvent actionEvent) {
|
|
|
|
|
//TODO
|
|
|
|
|
new DataService(DataHandler.DataType.LINE, 100).start();
|
|
|
|
|
}
|
|
|
|
|
generationItem.setOnAction(actionEvent -> {
|
|
|
|
|
new DataService(DataHandler.ActionType.GENERATE, DataHandler.DataType.LINE, 1000).start();
|
|
|
|
|
});
|
|
|
|
|
MenuItem evaluationItem = new MenuItem("Evaluate");
|
|
|
|
|
|
|
|
|
@ -156,11 +180,6 @@ public class ViewController {
|
|
|
|
|
*/
|
|
|
|
|
public void appendEvalResult(Map<Algorithm.Type, Map<String, String>> tableEntries) {
|
|
|
|
|
|
|
|
|
|
// SwingUtilities.invokeLater(() -> {
|
|
|
|
|
// evaluationPanel.addRow(tableEntries);
|
|
|
|
|
// evaluationPanel.repaint();
|
|
|
|
|
// evaluationPanel.revalidate();
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -172,154 +191,16 @@ public class ViewController {
|
|
|
|
|
appendEvalResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
|
|
|
* init GUI
|
|
|
|
|
******************************************************************************************************************/
|
|
|
|
|
/**
|
|
|
|
|
* Komponenten werden in Container gesetzt
|
|
|
|
|
*/
|
|
|
|
|
private void addComponents() {
|
|
|
|
|
// toolBar.add(importButton);
|
|
|
|
|
// toolBar.add(exportButton);
|
|
|
|
|
// toolBar.add(generateButton);
|
|
|
|
|
// toolBar.setFloatable(false);
|
|
|
|
|
//
|
|
|
|
|
// setJMenuBar(menu.getMenuBar());
|
|
|
|
|
// add(toolBar);
|
|
|
|
|
//
|
|
|
|
|
// setupSplitPane();
|
|
|
|
|
// setupTabbedPane();
|
|
|
|
|
// ((JPanel) progressDialog.getContentPane()).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
|
|
|
|
|
//
|
|
|
|
|
// this.add(toolBar, BorderLayout.NORTH);
|
|
|
|
|
// this.add(splitpane, BorderLayout.CENTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialisierung der Komponenten
|
|
|
|
|
*/
|
|
|
|
|
private void initializeComponents(Collection<Node> list) {
|
|
|
|
|
|
|
|
|
|
// //panels
|
|
|
|
|
// toolBar = new JToolBar();
|
|
|
|
|
// lmsPanel = new LMSPanel();
|
|
|
|
|
// rmPanel = new RMPanel();
|
|
|
|
|
// tsPanel = new TSPanel();
|
|
|
|
|
// menu = new MenuBar();
|
|
|
|
|
//
|
|
|
|
|
// //Dialogs
|
|
|
|
|
// progressDialog = new JDialog();
|
|
|
|
|
// progressDialog.setLocationRelativeTo(null);
|
|
|
|
|
// progressContent = progressDialog.getContentPane();
|
|
|
|
|
// progressBar = new JProgressBar();
|
|
|
|
|
//
|
|
|
|
|
// //Panes
|
|
|
|
|
// tabbedPane = new JTabbedPane();
|
|
|
|
|
// output = new InfoPanel();
|
|
|
|
|
// splitpane = new JSplitPane();
|
|
|
|
|
//
|
|
|
|
|
// //Buttons
|
|
|
|
|
// importButton = new JButton();
|
|
|
|
|
// generateButton = new JButton();
|
|
|
|
|
// exportButton = new JButton();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Icons werden passend gesetzt
|
|
|
|
|
*/
|
|
|
|
|
private void setIcons() {
|
|
|
|
|
// try {
|
|
|
|
|
// ClassLoader classLoader = getClass().getClassLoader();
|
|
|
|
|
// Image imgImport = ImageIO.read(classLoader.getResource("import.png")).getScaledInstance(16, 16, Image.SCALE_SMOOTH);
|
|
|
|
|
// Image imgStart = ImageIO.read(classLoader.getResource("start.png")).getScaledInstance(32, 32, Image.SCALE_SMOOTH);
|
|
|
|
|
// Image imgGenerate = ImageIO.read(classLoader.getResource("generate.png")).getScaledInstance(16, 16, Image.SCALE_SMOOTH);
|
|
|
|
|
// Image imgExport = ImageIO.read(classLoader.getResource("export.png")).getScaledInstance(16, 16, Image.SCALE_SMOOTH);
|
|
|
|
|
// Image imgFrame = ImageIO.read(classLoader.getResource("frame.png")).getScaledInstance(32, 23, Image.SCALE_SMOOTH);
|
|
|
|
|
//
|
|
|
|
|
// importButton.setIcon(new ImageIcon(imgImport));
|
|
|
|
|
// exportButton.setIcon(new ImageIcon(imgExport));
|
|
|
|
|
// generateButton.setIcon(new ImageIcon(imgGenerate));
|
|
|
|
|
// lmsPanel.getStartButton().setIcon(new ImageIcon(imgStart));
|
|
|
|
|
// rmPanel.getStartButton().setIcon(new ImageIcon(imgStart));
|
|
|
|
|
// tsPanel.getStartButton().setIcon(new ImageIcon(imgStart));
|
|
|
|
|
// this.setIconImage(imgFrame);
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// Logging.logError(e.getMessage(), e);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Funktionalitรคten werden hinzugefรผgt
|
|
|
|
|
*/
|
|
|
|
|
public void setActionListeners() {
|
|
|
|
|
// //action listener fรผr MenuItems
|
|
|
|
|
// menu.addActionListeners();
|
|
|
|
|
//
|
|
|
|
|
// //action listener fรผr diese Klasse
|
|
|
|
|
// lmsPanel.getStartButton().addActionListener(new StartAlgorithmListener(((Presenter) getPresenter()), lmsPanel));
|
|
|
|
|
// rmPanel.getStartButton().addActionListener(new StartAlgorithmListener(((Presenter) getPresenter()), rmPanel));
|
|
|
|
|
// tsPanel.getStartButton().addActionListener(new StartAlgorithmListener(((Presenter) getPresenter()), tsPanel));
|
|
|
|
|
// importButton.addActionListener(new ImportDataListener((Presenter) this.getPresenter()));
|
|
|
|
|
// exportButton.addActionListener(new ExportDataListener((Presenter) this.getPresenter()));
|
|
|
|
|
// generateButton.addActionListener(new GenerateDataListener((Presenter) this.getPresenter()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Funktionalitรคten werden aktiviert.
|
|
|
|
|
*/
|
|
|
|
|
public void enableFunctionality() {
|
|
|
|
|
// this.getLmsPanel().getStartButton().setEnabled(true);
|
|
|
|
|
// this.getRmPanel().getStartButton().setEnabled(true);
|
|
|
|
|
// this.getTsPanel().getStartButton().setEnabled(true);
|
|
|
|
|
// this.getExportButton().setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Funktionalitรคten werden deaktiviert.
|
|
|
|
|
*/
|
|
|
|
|
public void disableFunctionality() {
|
|
|
|
|
// this.getLmsPanel().getStartButton().setEnabled(false);
|
|
|
|
|
// this.getRmPanel().getStartButton().setEnabled(false);
|
|
|
|
|
// this.getTsPanel().getStartButton().setEnabled(false);
|
|
|
|
|
// this.getExportButton().setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
|
|
|
* log Methode
|
|
|
|
|
******************************************************************************************************************/
|
|
|
|
|
/**
|
|
|
|
|
* @param s Text der ausgegeben wird
|
|
|
|
|
*/
|
|
|
|
|
public void logInfo(String s) {
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
logArea.appendText(s + "\n");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param s Fehlertext der ausgegeben wird
|
|
|
|
|
*/
|
|
|
|
|
public void logError(String s) {
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
logArea.appendText(s + "\n");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param s Text der in grรผner Farbe ausgegeben wird
|
|
|
|
|
*/
|
|
|
|
|
public void logWarning(String s) {
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
logArea.appendText(s + "\n");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************************************************
|
|
|
|
|
* Getter und Setter Methoden
|
|
|
|
|
******************************************************************************************************************/
|
|
|
|
|
}
|
|
|
|
|