Commit 24cdffeb authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add tread lines to stairs in Simulation and PostVis

parent f2f13f12
package org.vadere.gui.components.view;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Collection;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Stairs;
import org.vadere.util.geometry.Vector2D;
import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.math.MathUtil;
import org.vadere.util.potential.CellGrid;
......@@ -25,10 +14,21 @@ import org.vadere.util.voronoi.HalfEdge;
import org.vadere.util.voronoi.RectangleLimits;
import org.vadere.util.voronoi.VoronoiDiagram;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Collection;
public abstract class DefaultRenderer {
private IDefaultModel defaultModel;
private BufferedImage logo;
private static final double rotNeg90 = - Math.PI /2;
public DefaultRenderer(final IDefaultModel defaultModel) {
this(defaultModel, true, false);
......@@ -127,6 +127,43 @@ public abstract class DefaultRenderer {
g.setColor(tmpColor);
}
protected void renderStairs(final Iterable<Stairs> stairs, final Graphics2D g,
final Color color){
final Color tmpColor = g.getColor();
for (Stairs s : stairs) {
g.setColor(Color.black);
g.fill(s.getShape());
Area hatchArea = new Area(s.getShape());
double stroke = s.getTreadDepth() * 0.05;
double halfTreadDepth = s.getTreadDepth()/2;
for (Stairs.Tread tread : s.getTreads()) {
VLine tLine = tread.treadline;
Vector2D vec = tLine.asVector();
vec = vec.normalize(stroke);
vec = vec.rotate(rotNeg90);
Vector2D trans = vec.normalize(halfTreadDepth);
Path2D p = new Path2D.Double();
p.moveTo(tLine.x1, tLine.y1);
p.lineTo(tLine.x2, tLine.y2);
p.lineTo(tLine.x2 + vec.x, tLine.y2 + vec.y);
p.lineTo(tLine.x1 + vec.x, tLine.y1 + vec.y);
p.closePath();
p.transform(AffineTransform.getTranslateInstance(trans.x, trans.y));
hatchArea.subtract(new Area(p));
}
g.setColor(color);
g.fill(hatchArea);
}
g.setColor(tmpColor);
}
protected void renderSelectionShape(final Graphics2D graphics) {
graphics.setColor(defaultModel.getMouseSelectionMode().getSelectionColor());
graphics.setStroke(new BasicStroke(getSelectionBorderLineWidht()));
......
......@@ -81,7 +81,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
}
if (model.config.isShowStairs()) {
renderScenarioElement(model.getTopography().getStairs(), graphics, model.config.getStairColor());
renderStairs(model.getTopography().getStairs(), graphics, model.config.getStairColor());
}
if (model.config.isShowTargets()) {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......
......@@ -96,4 +96,9 @@ public class Vector2D extends VPoint {
return new Vector2D(this.x - p.x, this.y - p.y);
}
public Vector2D rotate(final double radAngle) {
return new Vector2D(x * Math.cos(radAngle) - y * Math.sin(radAngle),
x * Math.sin(radAngle) + y * Math.cos(radAngle));
}
}
......@@ -3,6 +3,7 @@ package org.vadere.util.geometry.shapes;
import java.awt.geom.Line2D;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.Vector2D;
@SuppressWarnings("serial")
public class VLine extends Line2D.Double {
......@@ -22,4 +23,8 @@ public class VLine extends Line2D.Double {
public double distance(VPoint point) {
return GeometryUtils.closestToSegment(this, point).distance(point);
}
public Vector2D asVector(){
return new Vector2D(x2 - x1, y2 - y1);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment