Commit 3b5f89bd authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Merge branch 'master' into salient_behavior

parents d23293c8 45ebccbe
......@@ -45,12 +45,12 @@ Please contact us and we will send you an invitation.
### Use the Issue Tracker
Please, use the [issue tracker](https://gitlab.lrz.de/vadere/vadere/issues) for both
Please, use the [issue tracker](https://gitlab.lrz.de/vadere/vadere/issues?sort=label_priority) for both
- to request a feature or to report a bug (see [how to write new issues](https://gitlab.lrz.de/vadere/vadere/issues/179))
- to work on a feature (see [how to work on an issue](https://gitlab.lrz.de/vadere/vadere/issues/184))
**Tip:** Sort the issues in the [issue tracker](https://gitlab.lrz.de/vadere/vadere/issues) by `Label priority`.
**Tip:** Sort the issues in the [issue tracker](https://gitlab.lrz.de/vadere/vadere/issues?sort=label_priority) by `Label priority`.
### Steps for External Contributors
......
The java_migration branch has used the following steps to compile and run vadere with JDK-11 on Windows 10:
0. Ensure that JDK-11 and Git is set in the environment variables
0. Ensure that OpenJDK11 and Git is set in the environment variables
1. Adjust the IDE (IntelliJ)
-> Make sure that you have the latest version of IntelliJ (in some older versions, Java 11 is not supported!)
......@@ -47,12 +47,15 @@ The java_migration branch has used the following steps to compile and run vadere
</plugins>
</build>
3. Compile
3.1 Run "mvn -e clean test-compile compile" (-e for error stack trace)
3.* possibly required updates: "mvn versions:display-dependency-updates" and "mvn versions:display-plugin-updates"
3. Remove local Maven repository to avoid conflicts with older Java packages
3.1 rm -R "~/.m2"
4. Create local runtime
4.1 Run "jdeps --list-deps VadereGui/target/vadere.jar"
4.2 Run "jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.prefs,java.rmi,java.scripting,java.sql,java.xml --output java-runtime"
4. Compile
4.1 Run "mvn -e clean test-compile compile" (-e for error stack trace)
4.* possibly required updates: "mvn versions:display-dependency-updates" and "mvn versions:display-plugin-updates"
5. Optional: Create local runtime for Vadere which omits unnecessary Java packages
5.1 Run "jdeps --list-deps VadereGui/target/vadere.jar"
5.2 Run "jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.prefs,java.rmi,java.scripting,java.sql,java.xml --output java-runtime"
// The main output of jdeps is used as the parameter for jlink --add-modules.
4.3 Run "java-runtime/bin/java -jar VadereGui/target/vadere.jar"
\ No newline at end of file
5.3 Run "java-runtime/bin/java -jar VadereGui/target/vadere.jar"
......@@ -25,4 +25,6 @@ public @interface DataProcessorClass {
String label() default "";
String description() default "";
String[] processorFlags() default {};
}
......@@ -5,6 +5,8 @@ import com.google.auto.service.AutoService;
import org.vadere.annotation.factories.BaseFactoryProcessor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import javax.annotation.processing.Processor;
......@@ -12,6 +14,10 @@ import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
@SupportedAnnotationTypes("org.vadere.annotation.factories.dataprocessors.DataProcessorClass")
@SupportedSourceVersion(SourceVersion.RELEASE_11)
......@@ -32,10 +38,23 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
protected void addLastConstructor(Set<? extends Element> elements, PrintWriter writer) {
for (Element e : elements) {
writer.append(" addMember(");
writer.append(e.getSimpleName().toString()).append(".class, ");
writer.append("this::").append("get").append(name(e)).append(", ");
writer.append(quote(label(e))).append(", ");
writer.append(quote(descr(e))).println("); ");
writer.append(quote(descr(e))).append(", ");
writer.append(e.getSimpleName().toString()).append(".class");
//if flags are provides here...
String[] flags = processorFlags(e);
if (flags.length > 0){
writer.append(", ");
for (int i = 0; i < flags.length -1; i++) {
writer.append(quote(flags[i])).append(", ");
}
writer.append(quote(flags[flags.length-1]));
writer.println("); ");
} else {
writer.println("); ");
}
}
}
......@@ -76,4 +95,29 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
return dataProcessorClass.description();
}
private String[] processorFlags(Element element){
DataProcessorClass dataProcessorClass = element.getAnnotation(DataProcessorClass.class);
Elements elementUtil = processingEnv.getElementUtils();
Types typeUtil = processingEnv.getTypeUtils();
ArrayList<String> flags = new ArrayList<>();
TypeMirror processorFlag = elementUtil
.getTypeElement("org.vadere.simulator.projects.dataprocessing.flags.ProcessorFlag")
.asType();
// cast possible becuse element is a class
TypeElement e = (TypeElement)element;
for (TypeMirror anInterface : e.getInterfaces()) {
if (typeUtil.isAssignable(anInterface, processorFlag)){
flags.add(typeUtil.asElement(anInterface).getSimpleName().toString());
}
}
flags.addAll(Arrays.asList(dataProcessorClass.processorFlags()));
return flags.toArray(String[]::new);
}
}
......@@ -7,10 +7,10 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@FactoryType(
factoryClassName = "JoltTransformationFactory",
extendedClassName = "JoltTransformationBaseFactory",
factoryImports = {"org.vadere.simulator.projects.migration.jolttranformation.JoltTransformationBaseFactory"},
factoryPackage = "org.vadere.simulator.projects.migration.jolttranformation"
factoryClassName = "JsonTransformationFactory",
extendedClassName = "JsonTransformationBaseFactory",
factoryImports = {"org.vadere.simulator.projects.migration.jsontranformation.JsonTransformationBaseFactory"},
factoryPackage = "org.vadere.simulator.projects.migration.jsontranformation"
)
public @interface MigrationTransformation {
......
......@@ -21,7 +21,6 @@ public class DefaultModeAdapter implements IMode {
@Override
public void mouseClicked(final MouseEvent event) {
panelModel.setMousePosition(event.getPoint());
panelModel.setSelectedElement(panelModel.getMousePosition());
panelModel.notifyObservers();
}
......@@ -65,6 +64,7 @@ public class DefaultModeAdapter implements IMode {
@Override
public void mouseMoved(MouseEvent e) {
panelModel.setMousePosition(e.getPoint());
panelModel.setSelectedElement(panelModel.getMousePosition());
panelModel.notifyObservers();
}
......
......@@ -127,6 +127,9 @@ public class TikzGenerator {
Color stairColor = model.getConfig().getStairColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "StairColor", stairColor.getRed(), stairColor.getGreen(), stairColor.getBlue());
Color measurementAreaColor = model.getConfig().getMeasurementAreaColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "MeasurementAreaColor", measurementAreaColor.getRed(), measurementAreaColor.getGreen(), measurementAreaColor.getBlue());
Color agentColor = model.getConfig().getPedestrianDefaultColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "AgentColor", agentColor.getRed(), agentColor.getGreen(), agentColor.getBlue());
......@@ -142,16 +145,18 @@ public class TikzGenerator {
String drawSettings = "% Draw Settings\n";
double agentRadius = model.getConfig().getPedestrianTorso() / 2.0;
double opacityBetweenZeroAndOne = model.getConfig().getMeasurementAreaAlpha() / 255.0;
drawSettings += String.format(Locale.US,"\\newcommand{\\AgentRadius}{%f}\n", agentRadius);
drawSettings += String.format(Locale.US,"\\newcommand{\\LineWidth}{%d}\n", 1);
drawSettings += String.format(Locale.US,"\\newcommand{\\MeasurementAreaOpacity}{%f}\n", opacityBetweenZeroAndOne);
drawSettings += "\n";
return drawSettings;
}
private String convertScenarioElementsToTikz() {
private String convertScenarioElementsToTikz() {
String generatedCode = "";
DefaultSimulationConfig config = model.getConfig();
......@@ -221,6 +226,15 @@ public class TikzGenerator {
generatedCode += "% Stairs (not enabled in config)\n";
}
if (config.isShowMeasurementArea()) {
generatedCode += "% Measurement Areas\n";
for (MeasurementArea measurementArea : topography.getMeasurementAreas()) {
generatedCode += String.format(Locale.US, "\\fill[MeasurementAreaColor,opacity=\\MeasurementAreaOpacity] %s;\n", generatePathForScenarioElement(measurementArea));
}
} else {
generatedCode += "% Measurement Areas (not enabled in config)\n";
}
if (config.isShowTrajectories()) {
generatedCode += "% Trajectories\n";
......
package org.vadere.gui.topographycreator.control;
import java.awt.Point;
import java.awt.event.MouseEvent;
import javax.swing.undo.UndoableEdit;
import javax.swing.undo.UndoableEditSupport;
import org.lwjgl.system.CallbackI;
import org.vadere.gui.components.control.DefaultSelectionMode;
import org.vadere.gui.components.control.IMode;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import javax.swing.undo.UndoableEdit;
import javax.swing.undo.UndoableEditSupport;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Optional;
/**
* In this mode the user can select a ScenarioElement with his mouse (click) and he can move
* elements around (press -> drag -> release).
......@@ -21,11 +23,27 @@ import org.vadere.util.geometry.shapes.VShape;
public class SelectElementMode extends DefaultSelectionMode {
private final UndoableEditSupport undoSupport;
private final IDrawPanelModel panelModel;
private boolean resizeElement;
private boolean isModifying;
private static final int[] DIRECTIONAL_CURSOR_CODES;
static{
DIRECTIONAL_CURSOR_CODES = new int[8];
DIRECTIONAL_CURSOR_CODES[0] = Cursor.E_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[1] = Cursor.NE_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[2] = Cursor.N_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[3] = Cursor.NW_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[4] = Cursor.W_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[5] = Cursor.SW_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[6] = Cursor.S_RESIZE_CURSOR;
DIRECTIONAL_CURSOR_CODES[7] = Cursor.SE_RESIZE_CURSOR;
}
public SelectElementMode(final IDrawPanelModel panelModel, final UndoableEditSupport undoSupport) {
super(panelModel);
this.undoSupport = undoSupport;
this.panelModel = panelModel;
this.resizeElement = false;
}
private Point startPoint;
......@@ -51,15 +69,25 @@ public class SelectElementMode extends DefaultSelectionMode {
startPoint = e.getPoint();
panelModel.setPrototypeShape(panelModel.getSelectedElement().getShape());
panelModel.showPrototypeShape();
resizeElement = panelModel.getSelectedElement().getShape().atBorder(panelModel.translateVectorCoordinates(startPoint));
isModifying = true;
} else {
super.mousePressed(e);
}
}
@Override
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
panelModel.setMouseSelectionMode(this);
}
@Override
public void mouseDragged(final MouseEvent e) {
if (isMouseOnPrototypeShape()) {
VShape shape =
if (isMouseOnPrototypeShape() || isModifying) {
//VShape shape = panelModel.translate(new Point(e.getPoint().x - startPoint.x, e.getPoint().y - startPoint.y));
VShape shape = resizeElement ?
panelModel.resize(startPoint, e.getPoint()) :
panelModel.translate(new Point(e.getPoint().x - startPoint.x, e.getPoint().y - startPoint.y));
panelModel.setPrototypeShape(shape);
panelModel.showPrototypeShape();
......@@ -72,20 +100,26 @@ public class SelectElementMode extends DefaultSelectionMode {
@Override
public void mouseReleased(final MouseEvent e) {
ScenarioElement element = panelModel.getSelectedElement();
if (isMouseOnPrototypeShape()) {
if (isMouseOnPrototypeShape() || isModifying) {
VShape oldShape = element.getShape();
VShape newShape =
VShape newShape = resizeElement ?
panelModel.resize(startPoint, e.getPoint()) :
panelModel.translate(new Point(e.getPoint().x - startPoint.x, e.getPoint().y - startPoint.y));
AttributeModifier.setShapeToAttributes(element, newShape);
// tell the panelModel that the selected element has changed!
panelModel.setSelectedElement(element);
element.getId();
UndoableEdit edit = new EditUpdateElementShape(panelModel, element, oldShape);
undoSupport.postEdit(edit);
} else {
super.mouseReleased(e);
}
resizeElement = false;
isModifying = false;
startPoint = null;
panelModel.hidePrototypeShape();
panelModel.notifyObservers();
}
......@@ -93,13 +127,31 @@ public class SelectElementMode extends DefaultSelectionMode {
private boolean isMouseOnSelectedElement() {
ScenarioElement element = panelModel.getSelectedElement();
VPoint cursor = panelModel.getMousePosition();
return element != null && element.getShape().intersects(cursor.x, cursor.y, 0.001, 0.001);
return element != null && element.getShape().intersects(cursor.x - 0.01, cursor.y - 0.01, 0.02, 0.02);
//return element != null && element.getShape().contains(cursor);
}
private boolean isMouseOnPrototypeShape() {
VShape shape = panelModel.getPrototypeShape();
VPoint cursor = panelModel.getMousePosition();
return panelModel.isPrototypeVisble() && shape.intersects(cursor.x, cursor.y, 0.001, 0.001);
return panelModel.isPrototypeVisble() && shape.intersects(cursor.x - 0.01, cursor.y - 0.01, 0.02, 0.02);
}
@Override
public Cursor getCursor(){
VShape selectedShape = panelModel.getSelectedElement() == null ? null : panelModel.getSelectedElement().getShape();
VPoint mousePosition = panelModel.getMousePosition();
boolean directionalCursorCondition = isMouseOnSelectedElement() && (resizeElement || selectedShape.atBorder(mousePosition));
if (directionalCursorCondition) {
return Cursor.getPredefinedCursor(
DIRECTIONAL_CURSOR_CODES[
selectedShape.getDirectionalCode(
startPoint == null ? mousePosition : new VPoint(startPoint),
DIRECTIONAL_CURSOR_CODES.length
)]
);
}
return super.getCursor();
}
@Override
......
package org.vadere.gui.topographycreator.model;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Point;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Observer;
import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.control.IMode;
import org.vadere.gui.components.model.DefaultConfig;
......@@ -24,6 +15,12 @@ import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.geometry.shapes.VShape;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Observer;
import java.util.function.Predicate;
public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<T>, Iterable<ScenarioElement> {
@Override
......@@ -163,6 +160,8 @@ public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<
VShape translate(Point vector);
VShape resize(Point start, Point end);
boolean isPrototypeVisble();
VShape getPrototypeShape();
......@@ -190,4 +189,9 @@ public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<
List<MeasurementArea> getMeasurementAreas();
Rectangle2D.Double getBounds();
default VPoint translateVectorCoordinates(Point point) {
return new VPoint(point.x / getScaleFactor(), getTopography().getBounds().height - point.y / getScaleFactor());
}
}
package org.vadere.gui.topographycreator.model;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D.Double;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Observer;
import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.control.IMode;
import org.vadere.gui.components.model.DefaultConfig;
......@@ -26,6 +16,16 @@ import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.geometry.shapes.VShape;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D.Double;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Observer;
import java.util.function.Predicate;
/**
* The data of the DrawPanel. Its holds the whole data of one scenario.
......@@ -355,6 +355,13 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
setChanged();
}
@Override
public VShape resize(final Point start, final Point end) {
VPoint startVector = translateVectorCoordinates(start);
VPoint endVector = translateVectorCoordinates(end);
return getSelectedElement().getShape().resize(startVector, endVector);
}
@Override
public VShape translate(final Point vector) {
VPoint worldVector = new VPoint(vector.x / getScaleFactor(), -vector.y / getScaleFactor());
......
{
"name" : "Neues_Szenario",
"description" : "",
"release" : "0.7",
"release" : "0.8",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
......@@ -75,20 +75,8 @@
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor",
"attributes" : {
"measurementArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"voronoiArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
"measurementAreaId" : 1,
"voronoiMeasurementAreaId" : 1
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.AreaSpeedProcessor",
......@@ -148,26 +136,14 @@
"id" : 15,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor",
"attributes" : {
"waitingArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
"waitingAreaId" : 1
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingEndTimeProcessor",
"id" : 16,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor",
"attributes" : {
"waitingArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
"waitingAreaId" : 1
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor",
......@@ -341,7 +317,17 @@
"acceleration" : 2.0
},
"dynamicElements" : [ ],
"attributesCar" : null
"attributesCar" : null,
"measurementAreas" : [ {
"shape" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"id" : 1
} ]
}
}
}
\ No newline at end of file
{
"name" : "01_unsupported_event_exception_for_unsupported_models",
"description" : "",
"release" : "0.7",
"release" : "0.8",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -112,6 +112,7 @@
"bounded" : true
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
......
{
"name" : "02_bang_event_one_agent",
"description" : "",
"release" : "0.7",
"release" : "0.8",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -112,6 +112,7 @@
"bounded" : true
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {