further refactoring, renaming. Added dynamic parameter visualization to GUI.
This commit is contained in:
parent
100f26e983
commit
ce4c5c97d5
|
@ -1,9 +1,9 @@
|
||||||
package de.wwwu.awolf.model.communication;
|
package de.wwwu.awolf.model.communication;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
|
||||||
public class AlgorithmData implements Data {
|
public class AlgorithmMessage implements Message {
|
||||||
|
|
||||||
private SubscriberType type;
|
private SubscriberType type;
|
||||||
private Algorithm.Type algorithmType;
|
private Algorithm.Type algorithmType;
|
|
@ -1,12 +1,12 @@
|
||||||
package de.wwwu.awolf.model.communication;
|
package de.wwwu.awolf.model.communication;
|
||||||
|
|
||||||
public class TypeData implements Data {
|
public class DataProviderMessage implements Message {
|
||||||
|
|
||||||
private SubscriberType type;
|
private SubscriberType type;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubscriberType getType() {
|
public SubscriberType getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -5,7 +5,7 @@ import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class EvaluationData implements Data {
|
public class EvaluationMessage implements Message {
|
||||||
|
|
||||||
private SubscriberType type;
|
private SubscriberType type;
|
||||||
private List<Algorithm.Type> algorithmtypes;
|
private List<Algorithm.Type> algorithmtypes;
|
|
@ -1,43 +0,0 @@
|
||||||
package de.wwwu.awolf.model.communication;
|
|
||||||
|
|
||||||
public class GeneratorData implements Data {
|
|
||||||
|
|
||||||
private SubscriberType type;
|
|
||||||
private String message;
|
|
||||||
private double m;
|
|
||||||
private double b;
|
|
||||||
|
|
||||||
public double getM() {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setM(double m) {
|
|
||||||
this.m = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getB() {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setB(double b) {
|
|
||||||
this.b = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubscriberType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setType(SubscriberType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package de.wwwu.awolf.model.communication;
|
|
||||||
|
|
||||||
public class ImportData implements Data {
|
|
||||||
|
|
||||||
private SubscriberType type;
|
|
||||||
private int numberOfLines;
|
|
||||||
private int current;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubscriberType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setType(SubscriberType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfLines() {
|
|
||||||
return numberOfLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfLines(int numberOfLines) {
|
|
||||||
this.numberOfLines = numberOfLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrent() {
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrent(int current) {
|
|
||||||
this.current = current;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.model.communication;
|
package de.wwwu.awolf.model.communication;
|
||||||
|
|
||||||
public interface Data {
|
public interface Message {
|
||||||
|
|
||||||
SubscriberType getType();
|
SubscriberType getType();
|
||||||
|
|
|
@ -2,12 +2,7 @@ package de.wwwu.awolf.model.communication;
|
||||||
|
|
||||||
public enum SubscriberType {
|
public enum SubscriberType {
|
||||||
|
|
||||||
EVAL_D,
|
EVALUATION,
|
||||||
EVALUATION_TABLE_DATA,
|
|
||||||
EVAL_T,
|
|
||||||
LINES_RES,
|
|
||||||
LINES_RES_MULT,
|
|
||||||
ALGORITHM,
|
ALGORITHM,
|
||||||
PICTURE,
|
DATA_PROVIDER
|
||||||
GENERATOR
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.wwwu.awolf.model;
|
package de.wwwu.awolf.model.dao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
@ -1,4 +1,4 @@
|
||||||
package de.wwwu.awolf.model;
|
package de.wwwu.awolf.model.dao;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.apache.commons.math3.util.Precision;
|
import org.apache.commons.math3.util.Precision;
|
|
@ -1,4 +1,4 @@
|
||||||
package de.wwwu.awolf.model;
|
package de.wwwu.awolf.model.dao;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
||||||
package de.wwwu.awolf.model;
|
package de.wwwu.awolf.model.dao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
@ -1,4 +1,4 @@
|
||||||
package de.wwwu.awolf.model;
|
package de.wwwu.awolf.model.dao;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.apache.commons.math3.util.Precision;
|
import org.apache.commons.math3.util.Precision;
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.model.evaluation;
|
package de.wwwu.awolf.model.evaluation;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.wwwu.awolf.presenter;
|
package de.wwwu.awolf.presenter;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.LineModel;
|
import de.wwwu.awolf.model.dao.LineModel;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||||
|
@ -24,7 +24,7 @@ import javafx.beans.property.BooleanProperty;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 10.09.2017.
|
* @Date: 10.09.2017.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
public abstract class AbstractPresenter implements Flow.Subscriber<Message> {
|
||||||
|
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
private LineModel model;
|
private LineModel model;
|
||||||
|
@ -56,25 +56,23 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(Data data) {
|
public void onNext(Message message) {
|
||||||
Logging.logDebug("Presenter received message. Type: " + data.getType());
|
Logging.logDebug("Presenter received message. Type: " + message.getType());
|
||||||
switch (data.getType()) {
|
switch (message.getType()) {
|
||||||
case EVALUATION_TABLE_DATA:
|
case EVALUATION:
|
||||||
evaluatedDatas(data);
|
evaluatedDatas(message);
|
||||||
break;
|
break;
|
||||||
case ALGORITHM:
|
case ALGORITHM:
|
||||||
visualizeAlgorithm(data);
|
visualizeAlgorithm(message);
|
||||||
|
break;
|
||||||
|
case DATA_PROVIDER:
|
||||||
|
enableStartAlgorithmButton();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void visualizeAlgorithm(Data data);
|
|
||||||
|
|
||||||
protected abstract void evaluatedDatas(Data data);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable throwable) {
|
public void onError(Throwable throwable) {
|
||||||
|
|
||||||
|
@ -121,23 +119,14 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return das zu grunde legende Modell
|
|
||||||
*/
|
|
||||||
public LineModel getModel() {
|
public LineModel getModel() {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return die zu grunde legende View
|
|
||||||
*/
|
|
||||||
public ViewController getView() {
|
public ViewController getView() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param view die zu grunde legende View
|
|
||||||
*/
|
|
||||||
public void registerView(ViewController view) {
|
public void registerView(ViewController view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
Logging.logDebug("View has been set.");
|
Logging.logDebug("View has been set.");
|
||||||
|
@ -146,9 +135,6 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
||||||
Platform.runLater(() -> this.view.initGui());
|
Platform.runLater(() -> this.view.initGui());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Evaluation
|
|
||||||
*/
|
|
||||||
EvaluatationHandler getEvaluatationHandler() {
|
EvaluatationHandler getEvaluatationHandler() {
|
||||||
return evaluatationHandler;
|
return evaluatationHandler;
|
||||||
}
|
}
|
||||||
|
@ -157,12 +143,17 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
||||||
return dataHandler;
|
return dataHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the instance of the ExecutorService
|
|
||||||
*
|
|
||||||
* @return ExecutorService instance
|
|
||||||
*/
|
|
||||||
public ExecutorService getExecutor() {
|
public ExecutorService getExecutor() {
|
||||||
return Objects.requireNonNullElseGet(executor, Executors::newCachedThreadPool);
|
return Objects.requireNonNullElseGet(executor, Executors::newCachedThreadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AlgorithmHandler getAlgorithmHandler() {
|
||||||
|
return algorithmHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void enableStartAlgorithmButton();
|
||||||
|
|
||||||
|
protected abstract void visualizeAlgorithm(Message message);
|
||||||
|
|
||||||
|
protected abstract void evaluatedDatas(Message message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package de.wwwu.awolf.presenter;
|
package de.wwwu.awolf.presenter;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.communication.EvaluationData;
|
|
||||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||||
import de.wwwu.awolf.presenter.evaluation.EvaluatationHandler;
|
import de.wwwu.awolf.presenter.evaluation.EvaluatationHandler;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +26,11 @@ public class Presenter extends AbstractPresenter {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton access method
|
||||||
|
*
|
||||||
|
* @return instance
|
||||||
|
*/
|
||||||
public static Presenter getInstance() {
|
public static Presenter getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new Presenter();
|
instance = new Presenter();
|
||||||
|
@ -37,26 +40,25 @@ public class Presenter extends AbstractPresenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void visualizeAlgorithm(Data data) {
|
protected void enableStartAlgorithmButton() {
|
||||||
AlgorithmData algorithmData = (AlgorithmData) data;
|
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(tab -> tab.getStartButton().setDisable(false)));
|
||||||
|
|
||||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().get(algorithmData.getAlgorithmType()).updatePlot(getModel(), algorithmData.getLineData())
|
|
||||||
);
|
|
||||||
Logging.logInfo("Type: " + algorithmData.getType() + ". Result: " + algorithmData.getLineData().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void evaluatedDatas(Data data) {
|
protected void visualizeAlgorithm(Message message) {
|
||||||
EvaluationData evaluationData = (EvaluationData) data;
|
AlgorithmMessage algorithmMessage = (AlgorithmMessage) message;
|
||||||
SwingUtilities
|
Platform.runLater(() -> getView().getAlgorithmTabControllers().get(algorithmMessage.getAlgorithmType()).updatePlot(getModel(), algorithmMessage.getLineData()));
|
||||||
.invokeLater(
|
Logging.logInfo("Type: " + algorithmMessage.getType() + ". Result: " + algorithmMessage.getLineData().toString());
|
||||||
() -> getView().appendEvalResults(evaluationData.getMultipleColumnResult()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************************************************
|
@Override
|
||||||
* Hilfsmethoden
|
protected void evaluatedDatas(Message message) {
|
||||||
***************************************************************************************************************************/
|
//TODO
|
||||||
|
// EvaluationData evaluationData = (EvaluationData) data;
|
||||||
|
// SwingUtilities
|
||||||
|
// .invokeLater(
|
||||||
|
// () -> getView().appendEvalResults(evaluationData.getMultipleColumnResult()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startet den Export des akteullen Datensatzes (nur der Geraden)
|
* Startet den Export des akteullen Datensatzes (nur der Geraden)
|
||||||
|
@ -87,8 +89,7 @@ public class Presenter extends AbstractPresenter {
|
||||||
getModel().setLines(data);
|
getModel().setLines(data);
|
||||||
//Berechnung der Schnittpunkte und vis. der Ergebnisse (anz. Geraden, anz. Schnittpunkte)
|
//Berechnung der Schnittpunkte und vis. der Ergebnisse (anz. Geraden, anz. Schnittpunkte)
|
||||||
Logging.logInfo("Import was successful! ");
|
Logging.logInfo("Import was successful! ");
|
||||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null))
|
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null)));
|
||||||
);
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +103,7 @@ public class Presenter extends AbstractPresenter {
|
||||||
Set<Line> data = getDataHandler().getData(type, n);
|
Set<Line> data = getDataHandler().getData(type, n);
|
||||||
getModel().setLines(data);
|
getModel().setLines(data);
|
||||||
Logging.logInfo("Generate was successful!");
|
Logging.logInfo("Generate was successful!");
|
||||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null))
|
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null)));
|
||||||
);
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms;
|
package de.wwwu.awolf.presenter.algorithms;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
@ -14,7 +15,7 @@ import java.util.concurrent.Flow;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 28.05.2017.
|
* @Date: 28.05.2017.
|
||||||
*/
|
*/
|
||||||
public interface Algorithm extends Callable<Line>, Flow.Publisher<Data> {
|
public interface Algorithm extends Callable<Line>, Flow.Publisher<Message> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startet die Berechnung des jeweiligen Algorithmus.
|
* Startet die Berechnung des jeweiligen Algorithmus.
|
||||||
|
@ -28,6 +29,10 @@ public interface Algorithm extends Callable<Line>, Flow.Publisher<Data> {
|
||||||
|
|
||||||
void setPresenter(AbstractPresenter presenter);
|
void setPresenter(AbstractPresenter presenter);
|
||||||
|
|
||||||
|
Map<String, Object> getParameter();
|
||||||
|
|
||||||
|
void setParameter(Map<String, Object> parameter);
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
LMS("Least Median of Squares"),
|
LMS("Least Median of Squares"),
|
||||||
RM("Repeated Median"),
|
RM("Repeated Median"),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms;
|
package de.wwwu.awolf.presenter.algorithms;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.Presenter;
|
import de.wwwu.awolf.presenter.Presenter;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
@ -17,6 +17,7 @@ public class AlgorithmHandler {
|
||||||
|
|
||||||
private static AlgorithmHandler instance;
|
private static AlgorithmHandler instance;
|
||||||
private Map<Algorithm.Type, Algorithm> algorithmMapping;
|
private Map<Algorithm.Type, Algorithm> algorithmMapping;
|
||||||
|
private Map<Algorithm.Type, Map<String, Object>> algorithmParameters;
|
||||||
|
|
||||||
|
|
||||||
private AlgorithmHandler() {
|
private AlgorithmHandler() {
|
||||||
|
@ -88,10 +89,15 @@ public class AlgorithmHandler {
|
||||||
ServiceLoader<Algorithm> load = ServiceLoader.load(Algorithm.class);
|
ServiceLoader<Algorithm> load = ServiceLoader.load(Algorithm.class);
|
||||||
load.reload();
|
load.reload();
|
||||||
algorithmMapping = new EnumMap<>(Algorithm.Type.class);
|
algorithmMapping = new EnumMap<>(Algorithm.Type.class);
|
||||||
|
algorithmParameters = new EnumMap<>(Algorithm.Type.class);
|
||||||
load.forEach(algorithm -> {
|
load.forEach(algorithm -> {
|
||||||
algorithmMapping.put(algorithm.getType(), algorithm);
|
algorithmMapping.put(algorithm.getType(), algorithm);
|
||||||
|
algorithmParameters.put(algorithm.getType(), algorithm.getParameter());
|
||||||
Logging.logDebug("Found: " + algorithm.getClass().getSimpleName());
|
Logging.logDebug("Found: " + algorithm.getClass().getSimpleName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAlgorithmParametersByType(Algorithm.Type type) {
|
||||||
|
return algorithmParameters.get(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Interval;
|
import de.wwwu.awolf.model.dao.Interval;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.Point;
|
import de.wwwu.awolf.model.dao.Point;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
@ -14,8 +14,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -43,11 +45,21 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
private Line sigmaMin;
|
private Line sigmaMin;
|
||||||
private double heightsigmaMin;
|
private double heightsigmaMin;
|
||||||
private double intersectionsPoint;
|
private double intersectionsPoint;
|
||||||
private double constant = 0.5;
|
private double constant;
|
||||||
|
|
||||||
private double slope;
|
private double slope;
|
||||||
private double yInterception;
|
private double yInterception;
|
||||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
public LeastMedianOfSquaresEstimator() {
|
||||||
|
quantileError = 0.1;
|
||||||
|
constant = 0.5;
|
||||||
|
|
||||||
|
parameter = new HashMap<>();
|
||||||
|
parameter.put("Quantile Error", quantileError);
|
||||||
|
parameter.put("Constant", constant);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Algorithmus zum berechnen des LMS-Schätzers
|
* Algorithmus zum berechnen des LMS-Schätzers
|
||||||
|
@ -57,9 +69,9 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Line call() {
|
public Line call() {
|
||||||
|
|
||||||
this.n = setOfLines.size();
|
this.n = setOfLines.size();
|
||||||
double qPlus = 0.5;
|
double qPlus = 0.5;
|
||||||
quantileError = 0.1;
|
|
||||||
double qMinus = qPlus * (1 - quantileError);
|
double qMinus = qPlus * (1 - quantileError);
|
||||||
kMinus = (int) Math.ceil(n * qMinus);
|
kMinus = (int) Math.ceil(n * qMinus);
|
||||||
kPlus = (int) Math.ceil(n * qPlus);
|
kPlus = (int) Math.ceil(n * qPlus);
|
||||||
|
@ -155,6 +167,16 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
subscribe(presenter);
|
subscribe(presenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liefert die Anzahl der Schnittpunkte in einem Intervall
|
* Liefert die Anzahl der Schnittpunkte in einem Intervall
|
||||||
|
@ -373,7 +395,7 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
slope = m;
|
slope = m;
|
||||||
yInterception = b;
|
yInterception = b;
|
||||||
|
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(m, b));
|
data.setLineData(new Line(m, b));
|
||||||
|
@ -460,7 +482,7 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Interval;
|
import de.wwwu.awolf.model.dao.Interval;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.Point;
|
import de.wwwu.awolf.model.dao.Point;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
@ -14,9 +14,11 @@ import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import de.wwwu.awolf.presenter.util.RandomSampler;
|
import de.wwwu.awolf.presenter.util.RandomSampler;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
|
||||||
|
@ -57,8 +59,15 @@ public class RepeatedMedianEstimator implements Algorithm {
|
||||||
|
|
||||||
private double slope;
|
private double slope;
|
||||||
private double yInterception;
|
private double yInterception;
|
||||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
public RepeatedMedianEstimator() {
|
||||||
|
beta = 0.5;
|
||||||
|
|
||||||
|
parameter = new HashMap<>();
|
||||||
|
parameter.put("Beta", beta);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Führt den Algortihmus zur Berechnung des RM-Schätzers durch.
|
* Führt den Algortihmus zur Berechnung des RM-Schätzers durch.
|
||||||
|
@ -70,7 +79,7 @@ public class RepeatedMedianEstimator implements Algorithm {
|
||||||
n = setOfLines.size();
|
n = setOfLines.size();
|
||||||
interval = new Interval(-10000, 10000);
|
interval = new Interval(-10000, 10000);
|
||||||
original = new Interval(-10000, 10000);
|
original = new Interval(-10000, 10000);
|
||||||
beta = 0.5;
|
|
||||||
|
|
||||||
intersectionsInLeftSlab = new HashSet<>();
|
intersectionsInLeftSlab = new HashSet<>();
|
||||||
intersectionsInCenterSlab = new HashSet<>();
|
intersectionsInCenterSlab = new HashSet<>();
|
||||||
|
@ -253,7 +262,7 @@ public class RepeatedMedianEstimator implements Algorithm {
|
||||||
Math.floor(potentialYInterceptions.size() * 0.5));
|
Math.floor(potentialYInterceptions.size() * 0.5));
|
||||||
|
|
||||||
if (this.subscriber != null) {
|
if (this.subscriber != null) {
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(getSlope(), getyInterception()));
|
data.setLineData(new Line(getSlope(), getyInterception()));
|
||||||
|
@ -348,9 +357,19 @@ public class RepeatedMedianEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Interval;
|
import de.wwwu.awolf.model.dao.Interval;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.Point;
|
import de.wwwu.awolf.model.dao.Point;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
@ -17,6 +17,7 @@ import java.util.Collection;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
|
||||||
|
@ -50,8 +51,9 @@ public class TheilSenEstimator implements Algorithm {
|
||||||
private double bVariant;
|
private double bVariant;
|
||||||
private double slope;
|
private double slope;
|
||||||
private double yInterception;
|
private double yInterception;
|
||||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||||
private AbstractPresenter presenter;
|
private AbstractPresenter presenter;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +219,7 @@ public class TheilSenEstimator implements Algorithm {
|
||||||
yInterception = b;
|
yInterception = b;
|
||||||
|
|
||||||
if (this.subscriber != null) {
|
if (this.subscriber != null) {
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(m, b));
|
data.setLineData(new Line(m, b));
|
||||||
|
@ -242,7 +244,17 @@ public class TheilSenEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
@ -10,8 +10,10 @@ import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
|
||||||
|
@ -22,16 +24,20 @@ import java.util.concurrent.Flow;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 15.09.2017.
|
* @Date: 15.09.2017.
|
||||||
*/
|
*/
|
||||||
public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
public class NaiveLeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
|
|
||||||
private static final Algorithm.Type type = Type.NAIVE_LMS;
|
private static final Algorithm.Type type = Type.NAIVE_LMS;
|
||||||
private List<Line> setOfLines = new ArrayList<>();
|
private List<Line> setOfLines = new ArrayList<>();
|
||||||
|
|
||||||
private int n;
|
private int n;
|
||||||
private double ds, b, m;
|
private double ds, b, m;
|
||||||
private Flow.Subscriber<? super Data> subscriber;
|
private Flow.Subscriber<? super Message> subscriber;
|
||||||
private AbstractPresenter presenter;
|
private AbstractPresenter presenter;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
public NaiveLeastMedianOfSquaresEstimator() {
|
||||||
|
parameter = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crude Algorithmus zum berechnen des LSM-Schätzers.
|
* Crude Algorithmus zum berechnen des LSM-Schätzers.
|
||||||
|
@ -77,7 +83,7 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
Logging.logInfo("=== E N D - naiv L M S ===");
|
Logging.logInfo("=== E N D - naiv L M S ===");
|
||||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||||
|
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||||
|
@ -137,7 +143,17 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.Point;
|
import de.wwwu.awolf.model.dao.Point;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.Flow;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 15.09.2017.
|
* @Date: 15.09.2017.
|
||||||
*/
|
*/
|
||||||
public class NaivRepeatedMedianEstimator implements Algorithm {
|
public class NaiveRepeatedMedianEstimator implements Algorithm {
|
||||||
|
|
||||||
private static final Algorithm.Type type = Type.NAIVE_RM;
|
private static final Algorithm.Type type = Type.NAIVE_RM;
|
||||||
|
|
||||||
|
@ -34,8 +34,13 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
||||||
private List<Double> yMedians;
|
private List<Double> yMedians;
|
||||||
private double medianX;
|
private double medianX;
|
||||||
private double medianY;
|
private double medianY;
|
||||||
private Flow.Subscriber<? super Data> subscriber;
|
private Flow.Subscriber<? super Message> subscriber;
|
||||||
private AbstractPresenter presenter;
|
private AbstractPresenter presenter;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
public NaiveRepeatedMedianEstimator() {
|
||||||
|
parameter = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Line call() {
|
public Line call() {
|
||||||
|
@ -90,7 +95,7 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
||||||
end = System.currentTimeMillis();
|
end = System.currentTimeMillis();
|
||||||
Logging.logInfo("=== E N D - naiv R M ===");
|
Logging.logInfo("=== E N D - naiv R M ===");
|
||||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||||
|
@ -144,6 +149,16 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
||||||
return new Point(m, b);
|
return new Point(m, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Steigung
|
* @return Steigung
|
||||||
*/
|
*/
|
||||||
|
@ -159,7 +174,7 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,15 +1,17 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
|
||||||
|
@ -20,15 +22,20 @@ import java.util.concurrent.Flow;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 15.09.2017.
|
* @Date: 15.09.2017.
|
||||||
*/
|
*/
|
||||||
public class NaivTheilSenEstimator implements Algorithm {
|
public class NaiveTheilSenEstimator implements Algorithm {
|
||||||
|
|
||||||
private static final Algorithm.Type type = Type.NAIVE_TS;
|
private static final Algorithm.Type type = Type.NAIVE_TS;
|
||||||
|
|
||||||
private List<Line> setOfLines;
|
private List<Line> setOfLines;
|
||||||
private double slope;
|
private double slope;
|
||||||
private double yInterception;
|
private double yInterception;
|
||||||
private Flow.Subscriber<? super Data> subscriber;
|
private Flow.Subscriber<? super Message> subscriber;
|
||||||
private AbstractPresenter presenter;
|
private AbstractPresenter presenter;
|
||||||
|
private Map<String, Object> parameter;
|
||||||
|
|
||||||
|
public NaiveTheilSenEstimator() {
|
||||||
|
parameter = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Line call() {
|
public Line call() {
|
||||||
|
@ -68,7 +75,7 @@ public class NaivTheilSenEstimator implements Algorithm {
|
||||||
end = System.currentTimeMillis();
|
end = System.currentTimeMillis();
|
||||||
Logging.logInfo("=== E N D - naiv T S ===");
|
Logging.logInfo("=== E N D - naiv T S ===");
|
||||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||||
AlgorithmData data = new AlgorithmData();
|
AlgorithmMessage data = new AlgorithmMessage();
|
||||||
data.setAlgorithmType(getType());
|
data.setAlgorithmType(getType());
|
||||||
data.setType(SubscriberType.ALGORITHM);
|
data.setType(SubscriberType.ALGORITHM);
|
||||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||||
|
@ -92,6 +99,16 @@ public class NaivTheilSenEstimator implements Algorithm {
|
||||||
subscribe(presenter);
|
subscribe(presenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getParameter() {
|
||||||
|
return this.parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(Map<String, Object> parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Steigung
|
* @return Steigung
|
||||||
|
@ -108,7 +125,7 @@ public class NaivTheilSenEstimator implements Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
package de.wwwu.awolf.presenter.data;
|
package de.wwwu.awolf.presenter.data;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.communication.DataProviderMessage;
|
||||||
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||||
import de.wwwu.awolf.presenter.data.generator.CircleDatasetGenerator;
|
import de.wwwu.awolf.presenter.data.generator.CircleDatasetGenerator;
|
||||||
import de.wwwu.awolf.presenter.data.generator.CloudDatasetGenerator;
|
import de.wwwu.awolf.presenter.data.generator.CloudDatasetGenerator;
|
||||||
|
@ -13,19 +16,22 @@ import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorCompletionService;
|
import java.util.concurrent.ExecutorCompletionService;
|
||||||
|
import java.util.concurrent.Flow;
|
||||||
|
import java.util.concurrent.Flow.Subscriber;
|
||||||
|
|
||||||
public class DataHandler {
|
public class DataHandler implements Flow.Publisher<Message> {
|
||||||
|
|
||||||
private final AbstractPresenter presenter;
|
private final AbstractPresenter presenter;
|
||||||
|
private Subscriber<? super Message> subscriber;
|
||||||
|
|
||||||
public DataHandler(AbstractPresenter presenter) {
|
public DataHandler(AbstractPresenter presenter) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
subscribe(presenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Line> getData(final File file) {
|
public Set<Line> getData(final File file) {
|
||||||
//Presenter soll die Klasse überwachen
|
//Presenter soll die Klasse überwachen
|
||||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(
|
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(this.presenter.getExecutor());
|
||||||
this.presenter.getExecutor());
|
|
||||||
Logging.logDebug("Importing Data: " + file.getAbsolutePath());
|
Logging.logDebug("Importing Data: " + file.getAbsolutePath());
|
||||||
completionService.submit(new DataImporter(file));
|
completionService.submit(new DataImporter(file));
|
||||||
//wait until future is ready
|
//wait until future is ready
|
||||||
|
@ -35,14 +41,17 @@ public class DataHandler {
|
||||||
Logging.logError("Interrupted while importing... ", e);
|
Logging.logError("Interrupted while importing... ", e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
} finally {
|
||||||
|
DataProviderMessage message = new DataProviderMessage();
|
||||||
|
message.setType(SubscriberType.DATA_PROVIDER);
|
||||||
|
this.subscriber.onNext(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<Line> getData(final DataType type, final int dataSize) {
|
public Set<Line> getData(final DataType type, final int dataSize) {
|
||||||
//Presenter soll die Klasse überwachen
|
//Presenter soll die Klasse überwachen
|
||||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(
|
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(this.presenter.getExecutor());
|
||||||
this.presenter.getExecutor());
|
|
||||||
Logging.logDebug("Generating Data: Size: " + dataSize + ", dataType: " + type.name());
|
Logging.logDebug("Generating Data: Size: " + dataSize + ", dataType: " + type.name());
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -65,6 +74,10 @@ public class DataHandler {
|
||||||
Logging.logError("Interrupted while generating... ", e);
|
Logging.logError("Interrupted while generating... ", e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
} finally {
|
||||||
|
DataProviderMessage message = new DataProviderMessage();
|
||||||
|
message.setType(SubscriberType.DATA_PROVIDER);
|
||||||
|
this.subscriber.onNext(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +85,11 @@ public class DataHandler {
|
||||||
this.presenter.getExecutor().submit(new DataExporter(lines, file));
|
this.presenter.getExecutor().submit(new DataExporter(lines, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void subscribe(Subscriber<? super Message> subscriber) {
|
||||||
|
this.subscriber = subscriber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
CLOUD,
|
CLOUD,
|
||||||
|
|
|
@ -2,7 +2,7 @@ package de.wwwu.awolf.presenter.data.generator;
|
||||||
|
|
||||||
import static de.wwwu.awolf.presenter.data.generator.DatasetGenerator.generateDataLines;
|
import static de.wwwu.awolf.presenter.data.generator.DatasetGenerator.generateDataLines;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.data.generator;
|
package de.wwwu.awolf.presenter.data.generator;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.data.generator;
|
package de.wwwu.awolf.presenter.data.generator;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.data.generator;
|
package de.wwwu.awolf.presenter.data.generator;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.wwwu.awolf.presenter.data.io;
|
package de.wwwu.awolf.presenter.data.io;
|
||||||
|
|
||||||
import com.opencsv.CSVWriter;
|
import com.opencsv.CSVWriter;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.wwwu.awolf.presenter.data.io;
|
package de.wwwu.awolf.presenter.data.io;
|
||||||
|
|
||||||
import com.opencsv.CSVReader;
|
import com.opencsv.CSVReader;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.evaluation;
|
package de.wwwu.awolf.presenter.evaluation;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package de.wwwu.awolf.presenter.evaluation;
|
package de.wwwu.awolf.presenter.evaluation;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.LineModel;
|
import de.wwwu.awolf.model.dao.LineModel;
|
||||||
import de.wwwu.awolf.model.communication.Data;
|
import de.wwwu.awolf.model.communication.Message;
|
||||||
import de.wwwu.awolf.model.communication.EvaluationData;
|
import de.wwwu.awolf.model.communication.EvaluationMessage;
|
||||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||||
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
||||||
import de.wwwu.awolf.presenter.Presenter;
|
import de.wwwu.awolf.presenter.Presenter;
|
||||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.Flow;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 01.08.2017.
|
* @Date: 01.08.2017.
|
||||||
*/
|
*/
|
||||||
public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
public class EvaluatationHandler implements Runnable, Flow.Publisher<Message> {
|
||||||
|
|
||||||
private LineModel arrangement;
|
private LineModel arrangement;
|
||||||
private DatasetGenerator generator;
|
private DatasetGenerator generator;
|
||||||
|
@ -40,7 +40,7 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
||||||
private int type;
|
private int type;
|
||||||
private int iterations;
|
private int iterations;
|
||||||
private int alg;
|
private int alg;
|
||||||
private Flow.Subscriber<? super Data> subscriber;
|
private Flow.Subscriber<? super Message> subscriber;
|
||||||
private Map<Algorithm.Type, Map<String, String>> resultMapping;
|
private Map<Algorithm.Type, Map<String, String>> resultMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,8 +173,8 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
||||||
*/
|
*/
|
||||||
private void sendTableApproximationData(Map<Algorithm.Type, Map<String, String>> result) {
|
private void sendTableApproximationData(Map<Algorithm.Type, Map<String, String>> result) {
|
||||||
|
|
||||||
EvaluationData data = new EvaluationData();
|
EvaluationMessage data = new EvaluationMessage();
|
||||||
data.setType(SubscriberType.EVALUATION_TABLE_DATA);
|
data.setType(SubscriberType.EVALUATION);
|
||||||
data.setMultipleColumnResult(result);
|
data.setMultipleColumnResult(result);
|
||||||
data.setRowsPerColumn(result.keySet().size());
|
data.setRowsPerColumn(result.keySet().size());
|
||||||
this.subscriber.onNext(data);
|
this.subscriber.onNext(data);
|
||||||
|
@ -276,7 +276,7 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||||
this.subscriber = subscriber;
|
this.subscriber = subscriber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.evaluation.measures;
|
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.evaluation.measures;
|
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.evaluation.measures;
|
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.util.Comparators;
|
package de.wwwu.awolf.presenter.util.Comparators;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.util.Comparators;
|
package de.wwwu.awolf.presenter.util.Comparators;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.wwwu.awolf.presenter.util;
|
package de.wwwu.awolf.presenter.util;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.Point;
|
import de.wwwu.awolf.model.dao.Point;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package de.wwwu.awolf.view;
|
package de.wwwu.awolf.view;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.Presenter;
|
import de.wwwu.awolf.presenter.Presenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
|
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||||
import de.wwwu.awolf.presenter.util.Logging;
|
import de.wwwu.awolf.presenter.util.Logging;
|
||||||
import de.wwwu.awolf.view.controller.AlgorithmTabController;
|
import de.wwwu.awolf.view.controller.AlgorithmTabController;
|
||||||
|
@ -10,7 +11,6 @@ import de.wwwu.awolf.view.services.DataService;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -56,22 +56,15 @@ public class ViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTabbedPane() {
|
private void initTabbedPane() {
|
||||||
//TODO
|
AlgorithmHandler algorithmHandler = Presenter.getInstance().getAlgorithmHandler();
|
||||||
Map<String, String> props = new HashMap<>();
|
|
||||||
props.put("sfsdf", "dsadasd");
|
|
||||||
props.put("dfd", "dsadasd");
|
|
||||||
props.put("sdfdsfg", "dsadasd");
|
|
||||||
props.put("dsfsdfsdf", "dsadasd");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Algorithm.Type value : Algorithm.Type.values()) {
|
for (Algorithm.Type value : Algorithm.Type.values()) {
|
||||||
FXMLLoader loader = new FXMLLoader();
|
FXMLLoader loader = new FXMLLoader();
|
||||||
loader.setLocation(
|
loader.setLocation(AlgorithmTabController.class.getResource("/views/AlgorithmTab.fxml"));
|
||||||
AlgorithmTabController.class.getResource("/views/AlgorithmTab.fxml"));
|
|
||||||
Parent parent = loader.load();
|
Parent parent = loader.load();
|
||||||
AlgorithmTabController controller = loader.getController();
|
AlgorithmTabController controller = loader.getController();
|
||||||
controller.setAlgorithmType(value);
|
controller.setAlgorithmType(value);
|
||||||
controller.setProperties(props);
|
controller.setProperties(algorithmHandler.getAlgorithmParametersByType(value));
|
||||||
controller.setModel(Presenter.getInstance().getModel());
|
controller.setModel(Presenter.getInstance().getModel());
|
||||||
controller.init();
|
controller.init();
|
||||||
this.algorithmTabControllers.put(value, controller);
|
this.algorithmTabControllers.put(value, controller);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.wwwu.awolf.view.controller;
|
package de.wwwu.awolf.view.controller;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.LineModel;
|
import de.wwwu.awolf.model.dao.LineModel;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import de.wwwu.awolf.view.services.ButtonClickService;
|
import de.wwwu.awolf.view.services.ButtonClickService;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -22,13 +22,14 @@ public class AlgorithmTabController {
|
||||||
private final XYChart.Series<Double, Double> dataSerie;
|
private final XYChart.Series<Double, Double> dataSerie;
|
||||||
private final XYChart.Series<Double, Double> lineSerie;
|
private final XYChart.Series<Double, Double> lineSerie;
|
||||||
@FXML
|
@FXML
|
||||||
public LineChart<Double, Double> chart;
|
private LineChart<Double, Double> chart;
|
||||||
@FXML
|
@FXML
|
||||||
public VBox vBox;
|
private VBox vBox;
|
||||||
@FXML
|
@FXML
|
||||||
public Button startButton;
|
private Button startButton;
|
||||||
|
|
||||||
private Algorithm.Type algorithmType;
|
private Algorithm.Type algorithmType;
|
||||||
private Map<String, String> properties;
|
private Map<String, Object> properties;
|
||||||
private LineModel model;
|
private LineModel model;
|
||||||
|
|
||||||
public AlgorithmTabController() {
|
public AlgorithmTabController() {
|
||||||
|
@ -48,25 +49,27 @@ public class AlgorithmTabController {
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
// add GUI elements to maintain the parameters
|
// add GUI elements to maintain the parameters
|
||||||
properties.forEach((key, value) -> {
|
if (properties != null) {
|
||||||
//Pane component for the layout
|
properties.forEach((key, value) -> {
|
||||||
BorderPane borderPane = new BorderPane();
|
//Pane component for the layout
|
||||||
borderPane.setPadding(new Insets(10, 0, 10, 0));
|
BorderPane borderPane = new BorderPane();
|
||||||
|
borderPane.setPadding(new Insets(10, 0, 10, 0));
|
||||||
|
|
||||||
//text field for the input
|
//text field for the input
|
||||||
TextField textField = new TextField(value);
|
TextField textField = new TextField(String.valueOf(value));
|
||||||
|
|
||||||
//label
|
//label
|
||||||
Label label = new Label(key);
|
Label label = new Label(key);
|
||||||
label.setAlignment(Pos.BASELINE_LEFT);
|
label.setAlignment(Pos.BASELINE_LEFT);
|
||||||
label.setLabelFor(textField);
|
label.setLabelFor(textField);
|
||||||
label.setPadding(new Insets(2, 10, 0, 0));
|
label.setPadding(new Insets(2, 10, 0, 0));
|
||||||
|
|
||||||
//add components
|
//add components
|
||||||
borderPane.setLeft(label);
|
borderPane.setLeft(label);
|
||||||
borderPane.setRight(textField);
|
borderPane.setRight(textField);
|
||||||
vBox.getChildren().add(borderPane);
|
vBox.getChildren().add(borderPane);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
BooleanProperty booleanProperty = startButton.disableProperty();
|
BooleanProperty booleanProperty = startButton.disableProperty();
|
||||||
startButton.setOnAction(event -> {
|
startButton.setOnAction(event -> {
|
||||||
|
@ -107,13 +110,15 @@ public class AlgorithmTabController {
|
||||||
this.algorithmType = algorithmType;
|
this.algorithmType = algorithmType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, Object> getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(Map<String, String> properties) {
|
public void setProperties(Map<String, Object> properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Button getStartButton() {
|
||||||
|
return startButton;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.view.services;
|
package de.wwwu.awolf.view.services;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.Presenter;
|
import de.wwwu.awolf.presenter.Presenter;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
@ -12,7 +12,7 @@ public class ButtonClickService extends Service<Boolean> {
|
||||||
private final BooleanProperty startButtonDisabled;
|
private final BooleanProperty startButtonDisabled;
|
||||||
private Algorithm.Type type;
|
private Algorithm.Type type;
|
||||||
|
|
||||||
public ButtonClickService(Algorithm.Type algorithmType, BooleanProperty startButtonDisabled) {
|
public ButtonClickService(final Algorithm.Type algorithmType, final BooleanProperty startButtonDisabled) {
|
||||||
this.startButtonDisabled = startButtonDisabled;
|
this.startButtonDisabled = startButtonDisabled;
|
||||||
this.type = algorithmType;
|
this.type = algorithmType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@ public class DataService extends Service<Boolean> {
|
||||||
private DataHandler.ActionType actionType;
|
private DataHandler.ActionType actionType;
|
||||||
private int n;
|
private int n;
|
||||||
|
|
||||||
public DataService(final DataHandler.ActionType actionType, final DataHandler.DataType type,
|
public DataService(final DataHandler.ActionType actionType, final DataHandler.DataType type, final int n) {
|
||||||
final int n) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
this.n = n;
|
this.n = n;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
de.wwwu.awolf.presenter.algorithms.advanced.LeastMedianOfSquaresEstimator
|
de.wwwu.awolf.presenter.algorithms.advanced.LeastMedianOfSquaresEstimator
|
||||||
de.wwwu.awolf.presenter.algorithms.advanced.RepeatedMedianEstimator
|
de.wwwu.awolf.presenter.algorithms.advanced.RepeatedMedianEstimator
|
||||||
de.wwwu.awolf.presenter.algorithms.advanced.TheilSenEstimator
|
de.wwwu.awolf.presenter.algorithms.advanced.TheilSenEstimator
|
||||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivLeastMedianOfSquaresEstimator
|
de.wwwu.awolf.presenter.algorithms.naive.NaiveLeastMedianOfSquaresEstimator
|
||||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivRepeatedMedianEstimator
|
de.wwwu.awolf.presenter.algorithms.naive.NaiveRepeatedMedianEstimator
|
||||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivTheilSenEstimator
|
de.wwwu.awolf.presenter.algorithms.naive.NaiveTheilSenEstimator
|
|
@ -1,61 +1,54 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.chart.LineChart?>
|
<?import javafx.scene.*?>
|
||||||
<?import javafx.scene.chart.NumberAxis?>
|
<?import javafx.scene.chart.*?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.Cursor?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
|
||||||
<?import javafx.scene.layout.FlowPane?>
|
<BorderPane prefHeight="400.0" prefWidth="600.0" styleClass="algoPane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.wwwu.awolf.view.controller.AlgorithmTabController">
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="600.0"
|
|
||||||
styleClass="algoPane" xmlns="http://javafx.com/javafx/10.0.2-internal"
|
|
||||||
fx:controller="de.wwwu.awolf.view.controller.AlgorithmTabController">
|
|
||||||
<center>
|
<center>
|
||||||
<LineChart BorderPane.alignment="CENTER" prefHeight="398.0" prefWidth="390.0" title="Plot"
|
<LineChart fx:id="chart" prefHeight="398.0" prefWidth="390.0" title="Plot" BorderPane.alignment="CENTER">
|
||||||
fx:id="chart">
|
|
||||||
<xAxis>
|
<xAxis>
|
||||||
<NumberAxis label="X" side="BOTTOM">
|
<NumberAxis label="X" side="BOTTOM">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</NumberAxis>
|
</NumberAxis>
|
||||||
</xAxis>
|
</xAxis>
|
||||||
<yAxis>
|
<yAxis>
|
||||||
<NumberAxis label="Y" side="LEFT">
|
<NumberAxis label="Y" side="LEFT">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</NumberAxis>
|
</NumberAxis>
|
||||||
</yAxis>
|
</yAxis>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</center>
|
</center>
|
||||||
<left>
|
<left>
|
||||||
<VBox BorderPane.alignment="CENTER" alignment="TOP_CENTER" prefHeight="200.0" prefWidth="200.0"
|
<VBox fx:id="vBox" alignment="TOP_CENTER" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
fx:id="vBox">
|
|
||||||
<BorderPane.margin>
|
<BorderPane.margin>
|
||||||
<Insets left="10.0"/>
|
<Insets left="10.0" />
|
||||||
</BorderPane.margin>
|
</BorderPane.margin>
|
||||||
<children>
|
<children>
|
||||||
</children>
|
</children>
|
||||||
<cursor>
|
<cursor>
|
||||||
<Cursor fx:constant="HAND"/>
|
<Cursor fx:constant="HAND" />
|
||||||
</cursor>
|
</cursor>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets top="10.0"/>
|
<Insets top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</VBox>
|
</VBox>
|
||||||
</left>
|
</left>
|
||||||
<top>
|
<top>
|
||||||
<FlowPane BorderPane.alignment="CENTER" hgap="5.0" prefHeight="25.0" prefWidth="200.0">
|
<FlowPane hgap="5.0" prefHeight="25.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<BorderPane.margin>
|
<BorderPane.margin>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</BorderPane.margin>
|
</BorderPane.margin>
|
||||||
<children>
|
<children>
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" defaultButton="true" pickOnBounds="false"
|
<Button fx:id="startButton" alignment="CENTER" contentDisplay="CENTER" defaultButton="true" disable="true" pickOnBounds="false" text="Start">
|
||||||
text="Start" fx:id="startButton">
|
|
||||||
<cursor>
|
<cursor>
|
||||||
<Cursor fx:constant="HAND"/>
|
<Cursor fx:constant="HAND" />
|
||||||
</cursor>
|
</cursor>
|
||||||
</Button>
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package de.wwwu.awolf.presenter.util;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import de.wwwu.awolf.model.Line;
|
import de.wwwu.awolf.model.dao.Line;
|
||||||
import de.wwwu.awolf.model.LineModel;
|
import de.wwwu.awolf.model.dao.LineModel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
Loading…
Reference in New Issue