Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
24cdffeb
Commit
24cdffeb
authored
Aug 30, 2018
by
Stefan Schuhbaeck
Browse files
add tread lines to stairs in Simulation and PostVis
parent
f2f13f12
Changes
12
Hide whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/components/view/DefaultRenderer.java
View file @
24cdffeb
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
()));
...
...
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
View file @
24cdffeb
...
...
@@ -81,7 +81,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
}
if
(
model
.
config
.
isShowStairs
())
{
renderS
cenarioElement
(
model
.
getTopography
().
getStairs
(),
graphics
,
model
.
config
.
getStairColor
());
renderS
tairs
(
model
.
getTopography
().
getStairs
(),
graphics
,
model
.
config
.
getStairColor
());
}
if
(
model
.
config
.
isShowTargets
())
{
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_1_+1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_1_-1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_2_+1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_3_+1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_both_3_4_+1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_diagonal_both_3_4_-1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_upward_direction_up_+1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereModelTests/TestStairs/scenarios/stairs_upward_direction_up_-1.scenario
View file @
24cdffeb
...
...
@@ -77,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" :
0
"simulationSeed" :
1
},
"topography" : {
"attributes" : {
...
...
VadereUtils/src/org/vadere/util/geometry/Vector2D.java
View file @
24cdffeb
...
...
@@ -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
));
}
}
VadereUtils/src/org/vadere/util/geometry/shapes/VLine.java
View file @
24cdffeb
...
...
@@ -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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment