Commit 9b0377c2 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add tread rendering to tikzGenerator.

The stairs consist of multiple paths. Each tread is one path. The black
'line' is not a path but an empty space filled by a black background
behind the stairs.
parent 1a068542
Pipeline #67952 passed with stages
in 59 minutes and 1 second
......@@ -134,12 +134,7 @@ public abstract class DefaultRenderer {
}
}
protected void renderStair(ScenarioElement element, final Graphics2D graphics, Color color){
Stairs stairs = (Stairs) element;
final Color tmpColor = graphics.getColor();
graphics.setColor(Color.black);
graphics.fill(stairs.getShape());
public static Area getStairShapeWithThreads(Stairs stairs){
Area hatchArea = new Area(stairs.getShape());
double stroke = stairs.getTreadDepth() * 0.05;
double halfTreadDepth = stairs.getTreadDepth()/2;
......@@ -159,9 +154,19 @@ public abstract class DefaultRenderer {
p.closePath();
p.transform(AffineTransform.getTranslateInstance(trans.x, trans.y));
hatchArea.subtract(new Area(p));
}
return hatchArea;
}
protected void renderStair(ScenarioElement element, final Graphics2D graphics, Color color){
Stairs stairs = (Stairs) element;
final Color tmpColor = graphics.getColor();
graphics.setColor(Color.black);
graphics.fill(stairs.getShape());
Area hatchArea = getStairShapeWithThreads(stairs);
graphics.setColor(color);
graphics.fill(hatchArea);
......
......@@ -5,6 +5,7 @@ import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor;
......@@ -175,7 +176,8 @@ public class TikzGenerator {
if (config.isShowStairs()) {
generatedCode += "% Stairs\n";
for (Stairs stair : topography.getStairs()) {
generatedCode += String.format("\\fill[StairColor] %s;\n", generatePathForScenarioElement(stair));
generatedCode += String.format("\\fill[black] %s;\n", generatePathForScenarioElement(stair));
generatedCode += String.format("\\fill[StairColor] %s;\n", generatePathForStairs(stair));
}
} else {
generatedCode += "% Stairs (not enabled in config)\n";
......@@ -302,6 +304,24 @@ public class TikzGenerator {
return generatedPath.trim();
}
private String generatePathForStairs(Stairs element) {
String generatedPath = "";
AffineTransform noTransformation = new AffineTransform();
Shape shape = DefaultRenderer.getStairShapeWithThreads(element);
PathIterator pathIterator = shape.getPathIterator(noTransformation);
while (!pathIterator.isDone()) {
float[] coords = new float[6];
int type = pathIterator.currentSegment(coords);
generatedPath += convertJavaToTikzPath(type, coords);
pathIterator.next();
}
return generatedPath.trim();
}
private String generatePathForShape(Shape shape) {
String generatedPath = "";
......
Supports Markdown
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