Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
1ac3188a
Commit
1ac3188a
authored
Sep 30, 2016
by
Benedikt Zoennchen
Browse files
GUI-PostVis: pedestrian colors can now depend on the number of time steps a pedestrian is alive
parent
c34802ce
Changes
7
Hide whitespace changes
Inline
Side-by-side
VadereGui/resources/messages.properties
View file @
1ac3188a
...
...
@@ -176,6 +176,7 @@ ProjectView.mntmOutputToSceneario.text=Generate scenario
ProjectView.mntmRunOutput.text
=
Run offline again
PostVis.chbShowPedestrianIds.text
=
Show PedestrianIds
PostVis.chShowEvacTimeColor.text
=
Color Pedestrians regarding to Evacuation Times
PostVis.btnPlay.tooltip
=
Play
PostVis.btnPause.tooltip
=
Pause
PostVis.btnStop.tooltip
=
Stop
...
...
VadereGui/resources/messages_de.properties
View file @
1ac3188a
...
...
@@ -176,6 +176,7 @@ ProjectView.mntmOutputToSceneario.text=Generiere Szenario
ProjectView.mntmRunOutput.text
=
Offline erneut starten
PostVis.chbShowPedestrianIds.text
=
Fu
\u
00dfg
\u
00E4nger-Ids anzeigen
PostVis.chShowEvacTimeColor.text
=
F
\u
00e4rbe Fu
\u
00dfg
\u
00E4nger nach ihrer Evakuierungszeit
PostVis.btnPlay.tooltip
=
Start
PostVis.btnPause.tooltip
=
Pause
PostVis.btnStop.tooltip
=
Stopp
...
...
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationConfig.java
View file @
1ac3188a
...
...
@@ -16,6 +16,7 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
private
boolean
showFaydedPedestrians
=
false
;
private
boolean
showPedestrianIds
=
false
;
private
boolean
loadTopographyInformationsOnly
=
false
;
private
boolean
useEvacuationTimeColor
=
false
;
private
double
gridWidth
=
Double
.
valueOf
(
resources
.
getProperty
(
"PostVis.cellWidth"
));
private
int
fps
=
Integer
.
valueOf
(
resources
.
getProperty
(
"PostVis.framesPerSecond"
));
...
...
@@ -47,6 +48,7 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
this
.
loadTopographyInformationsOnly
=
config
.
loadTopographyInformationsOnly
;
this
.
showPedestrianIds
=
config
.
showPedestrianIds
;
this
.
observable
=
config
.
observable
;
this
.
useEvacuationTimeColor
=
config
.
useEvacuationTimeColor
;
}
public
boolean
isShowAllTrajectories
()
{
...
...
@@ -58,6 +60,15 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
setChanged
();
}
public
boolean
isUseEvacuationTimeColor
()
{
return
useEvacuationTimeColor
;
}
public
void
setUseEvacuationTimeColor
(
boolean
useEvacuationTimeColor
)
{
this
.
useEvacuationTimeColor
=
useEvacuationTimeColor
;
setChanged
();
}
public
void
setGridWidth
(
double
gridWidth
)
{
this
.
gridWidth
=
gridWidth
;
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
View file @
1ac3188a
...
...
@@ -2,6 +2,7 @@ package org.vadere.gui.postvisualization.model;
import
java.awt.Color
;
import
java.io.IOException
;
import
java.security.cert.PKIXRevocationChecker
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -98,6 +99,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
public
void
init
(
final
Map
<
Step
,
List
<
Agent
>>
agentsByStep
,
final
ScenarioRunManager
vadere
)
{
logger
.
info
(
"start init postvis model"
);
init
(
vadere
);
this
.
vadere
=
vadere
;
this
.
agentsByStep
=
agentsByStep
;
Map
<
Integer
,
Step
>
map
=
agentsByStep
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationRenderer.java
View file @
1ac3188a
...
...
@@ -9,6 +9,7 @@ import java.util.stream.Stream;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.vadere.gui.components.utils.ColorHelper
;
import
org.vadere.gui.components.view.DefaultRenderer
;
import
org.vadere.gui.components.view.SimulationRenderer
;
import
org.vadere.gui.postvisualization.model.PostvisualizationModel
;
...
...
@@ -27,11 +28,14 @@ public class PostvisualizationRenderer extends SimulationRenderer {
private
final
Map
<
Integer
,
VPoint
>
pedestrianDirections
;
private
ColorHelper
colorHelper
;
public
PostvisualizationRenderer
(
final
PostvisualizationModel
model
)
{
super
(
model
);
this
.
model
=
model
;
this
.
pedestrianDirections
=
new
HashMap
<>();
this
.
lastPedestrianPositions
=
new
HashMap
<>();
this
.
colorHelper
=
new
ColorHelper
(
model
.
getStepCount
());
}
public
PostvisualizationModel
getModel
()
{
...
...
@@ -40,6 +44,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
@Override
protected
void
renderSimulationContent
(
final
Graphics2D
g
)
{
this
.
colorHelper
=
new
ColorHelper
(
model
.
getStepCount
());
renderPedestrians
(
g
,
null
);
}
...
...
@@ -72,9 +77,13 @@ public class PostvisualizationRenderer extends SimulationRenderer {
int
targetId
=
pedestrian
.
hasNextTarget
()
?
pedestrian
.
getNextTargetId
()
:
-
1
;
// choose the color
Optional
<
Color
>
c
=
model
.
config
.
isUseEvacuationTimeColor
()
?
Optional
.
of
(
colorHelper
.
numberToColor
(
trajectory
.
getLifeTime
().
orElse
(
0
)))
:
Optional
.
empty
();
g
.
setColor
(
model
.
getColor
(
pedestrian
)
.
orElse
(
model
.
config
.
getColorByTargetId
(
targetId
)
.
orElseGet
(
model
.
config
::
getPedestrianDefaultColor
)));
.
orElse
(
c
.
orElseGet
(
model
.
config
::
getPedestrianDefaultColor
))));
// renderImage the pedestrian
if
(
model
.
config
.
isShowPedestrians
())
{
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/SettingsDialog.java
View file @
1ac3188a
...
...
@@ -21,6 +21,9 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.prefs.Preferences
;
/**
* @author Benedikt Zoennchen
*/
public
class
SettingsDialog
extends
JDialog
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
SettingsDialog
.
class
);
private
static
Resources
resources
=
Resources
.
getInstance
(
"postvisualization"
);
...
...
@@ -75,7 +78,7 @@ public class SettingsDialog extends JDialog {
FormLayout
additionalLayout
=
new
FormLayout
(
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"
,
// col
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"
);
// rows
FormLayout
colorLayout
=
new
FormLayout
(
"5dlu, pref, 2dlu, pref:grow, 2dlu, pref, 2dlu, pref, 5dlu"
,
// col
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"
);
// rows
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref,
2dlu, pref,
5dlu"
);
// rows
colorLayeredPane
.
setLayout
(
colorLayout
);
additionalLayeredPane
.
setLayout
(
additionalLayout
);
...
...
@@ -238,6 +241,14 @@ public class SettingsDialog extends JDialog {
PedestrianColorPanel
pedestrianColorPanel
=
new
PedestrianColorPanel
(
model
.
getPedestrianColorTableModel
());
colorLayeredPane
.
add
(
pedestrianColorPanel
,
cc
.
xyw
(
2
,
20
,
8
));
JCheckBox
chShowEvacTimeColor
=
new
JCheckBox
(
Messages
.
getString
(
"PostVis.chShowEvacTimeColor.text"
));
colorLayeredPane
.
add
(
chShowEvacTimeColor
,
cc
.
xyw
(
2
,
22
,
8
));
chShowEvacTimeColor
.
addItemListener
(
e
->
{
model
.
config
.
setUseEvacuationTimeColor
(!
model
.
config
.
isUseEvacuationTimeColor
());
model
.
notifyObservers
();
});
additionalLayeredPane
.
add
(
chCleanPed
,
cc
.
xyw
(
2
,
2
,
5
));
additionalLayeredPane
.
add
(
chCleanTrajecties
,
cc
.
xyw
(
2
,
4
,
5
));
additionalLayeredPane
.
add
(
chCleanSnapshot
,
cc
.
xyw
(
2
,
6
,
5
));
...
...
VadereState/src/org/vadere/state/simulation/Trajectory.java
View file @
1ac3188a
...
...
@@ -7,6 +7,7 @@ import java.util.Optional;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
org.apache.commons.math3.optim.OptimizationData
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.util.geometry.shapes.VPoint
;
...
...
@@ -60,6 +61,12 @@ public class Trajectory {
}
}
public
Optional
<
Integer
>
getLifeTime
()
{
return
getEndStep
().
isPresent
()
&&
getStartStep
().
isPresent
()
?
Optional
.
of
(
getEndStep
().
get
().
getStepNumber
()
-
getStartStep
().
get
().
getStepNumber
())
:
Optional
.
empty
();
}
/**
* Returns the pedestrian id that specified this trajectory.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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