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
5ed719e3
Commit
5ed719e3
authored
Jul 30, 2020
by
Christina
Browse files
remove attributes from LocomotionModel in GUI
parent
c127609b
Pipeline
#301410
failed with stages
in 2 minutes and 8 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/projectview/view/ModelPresets.java
View file @
5ed719e3
...
...
@@ -77,13 +77,13 @@ public class ModelPresets {
// Behavioural Heuristics Model
list
.
clear
();
list
.
add
(
AttributesBHM
.
class
);
registerModelPreset
(
BehaviouralHeuristicsModel
.
class
,
list
);
registerModelPreset
(
BehaviouralHeuristicsModel
.
class
,
list
);
// Biomechanics Model
list
.
clear
();
list
.
add
(
AttributesBMM
.
class
);
list
.
add
(
AttributesBHM
.
class
);
registerModelPreset
(
BiomechanicsModel
.
class
,
list
);
registerModelPreset
(
BiomechanicsModel
.
class
,
list
);
// SelfCatThreat Model
list
.
clear
();
...
...
@@ -98,9 +98,9 @@ public class ModelPresets {
}
private
void
registerModelPreset
(
Class
<?
extends
MainModel
>
mainModelClass
,
List
<
Class
<?
extends
Attributes
>>
attributesClasses
)
{
List
<
Class
<?
extends
Attributes
>>
attributesClasses
)
{
ModelDefinition
definition
=
new
ModelDefinition
(
mainModelClass
.
getName
(),
null
,
null
);
ModelDefinition
definition
=
new
ModelDefinition
(
mainModelClass
.
getName
(),
null
);
definition
.
createAndSetDefaultAttributes
(
attributesClasses
);
modelDefinitionPresets
.
add
(
definition
);
}
...
...
VadereGui/src/org/vadere/gui/projectview/view/ScenarioPanel.java
View file @
5ed719e3
...
...
@@ -8,7 +8,6 @@ import org.vadere.gui.postvisualization.view.PostvisualizationWindow;
import
org.vadere.gui.projectview.control.IProjectChangeListener
;
import
org.vadere.gui.projectview.model.ProjectViewModel
;
import
org.vadere.gui.topographycreator.view.TopographyWindow
;
import
org.vadere.simulator.control.strategy.models.IStrategyModel
;
import
org.vadere.simulator.models.ModelHelper
;
import
org.vadere.simulator.projects.ProjectFinishedListener
;
import
org.vadere.simulator.projects.Scenario
;
...
...
@@ -134,8 +133,6 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
Messages
.
getString
(
"Tab.Model.confirmLoadTemplate.title"
),
JOptionPane
.
OK_CANCEL_OPTION
)
==
JOptionPane
.
OK_OPTION
)
{
try
{
String
strategyModelString
=
scenario
.
getScenarioStore
().
getStrategyModel
();
modelDefinition
.
setStrategyModel
(
strategyModelString
);
attributesModelView
.
setText
(
StateJsonConverter
.
serializeModelPreset
(
modelDefinition
));
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
...
...
VadereGui/src/org/vadere/gui/projectview/view/TextView.java
View file @
5ed719e3
...
...
@@ -180,7 +180,6 @@ public class TextView extends JPanel implements IJsonView {
case
MODEL:
ModelDefinition
modelDefinition
=
JsonConverter
.
deserializeModelDefinition
(
json
);
currentScenario
.
getScenarioStore
().
setMainModel
(
modelDefinition
.
getMainModel
());
currentScenario
.
getScenarioStore
().
setStrategyModel
(
modelDefinition
.
getStrategyModel
());
currentScenario
.
setAttributesModel
(
modelDefinition
.
getAttributesList
());
break
;
case
SIMULATION:
...
...
@@ -281,7 +280,7 @@ public class TextView extends JPanel implements IJsonView {
switch
(
attributeType
)
{
case
MODEL:
textfileTextarea
.
setText
(
StateJsonConverter
.
serializeMainModelAttributesModelBundle
(
scenario
.
getModelAttributes
(),
scenario
.
getScenarioStore
().
getMainModel
()
,
scenario
.
getScenarioStore
().
getStrategyModel
()
));
scenario
.
getModelAttributes
(),
scenario
.
getScenarioStore
().
getMainModel
()));
break
;
case
SIMULATION:
textfileTextarea
...
...
VadereSimulator/src/org/vadere/simulator/models/Model.java
View file @
5ed719e3
...
...
@@ -5,10 +5,8 @@ import org.vadere.state.attributes.Attributes;
import
org.vadere.state.attributes.exceptions.AttributesMultiplyDefinedException
;
import
org.vadere.state.attributes.exceptions.AttributesNotFoundException
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.util.data.FindByClass
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Random
;
...
...
@@ -26,7 +24,7 @@ public interface Model {
* list and creating sub models. It also sets attributes recursively for its sub models.
*/
void
initialize
(
List
<
Attributes
>
attributesList
,
Domain
domain
,
AttributesAgent
attributesPedestrian
,
Random
random
);
AttributesAgent
attributesPedestrian
,
Random
random
);
void
preLoop
(
final
double
simTimeInSec
);
...
...
VadereSimulator/src/org/vadere/simulator/projects/io/JsonConverter.java
View file @
5ed719e3
...
...
@@ -3,7 +3,6 @@ package org.vadere.simulator.projects.io;
import
java.io.IOException
;
import
java.util.List
;
import
org.vadere.simulator.control.strategy.models.IStrategyModel
;
import
org.vadere.util.version.Version
;
import
org.vadere.simulator.models.MainModel
;
import
org.vadere.simulator.projects.Scenario
;
...
...
@@ -41,19 +40,9 @@ public class JsonConverter {
@SuppressWarnings
(
"unused"
)
MainModel
dummyToProvokeClassCast
=
instantiator
.
createObject
(
mainModelString
);
}
JsonNode
strategyModel
=
node
.
get
(
"strategyModel"
);
String
strategyModelString
=
null
;
if
(!
strategyModel
.
isNull
()){
strategyModelString
=
strategyModel
.
toString
();
}
return
new
ModelDefinition
(
mainModelString
,
strategyModelString
,
StateJsonConverter
.
deserializeAttributesListFromNode
(
node
.
get
(
"attributesModel"
)));
return
new
ModelDefinition
(
mainModelString
,
StateJsonConverter
.
deserializeAttributesListFromNode
(
node
.
get
(
"attributesModel"
)));
}
public
static
Scenario
deserializeScenarioRunManagerFromNode
(
JsonNode
node
)
throws
IOException
,
IllegalArgumentException
{
JsonNode
rootNode
=
node
;
JsonNode
scenarioNode
=
rootNode
.
get
(
StateJsonConverter
.
SCENARIO_KEY
);
...
...
@@ -70,13 +59,10 @@ public class JsonConverter {
Topography
topography
=
StateJsonConverter
.
deserializeTopographyFromNode
(
scenarioNode
.
get
(
"topography"
));
StimulusInfoStore
stimulusInfoStore
=
StateJsonConverter
.
deserializeStimuliFromArrayNode
(
scenarioNode
.
get
(
"stimulusInfos"
));
String
strategyModel
=
scenarioNode
.
get
(
"strategyModel"
).
asText
();
ScenarioStore
scenarioStore
=
new
ScenarioStore
(
scenarioName
,
scenarioDescription
,
mainModel
,
attributesModel
,
attributesSimulation
,
attributesPsychology
,
topography
,
stimulusInfoStore
,
strategyModel
);
topography
,
stimulusInfoStore
);
Scenario
scenarioRunManager
=
new
Scenario
(
scenarioStore
);
scenarioRunManager
.
setDataProcessingJsonManager
(
DataProcessingJsonManager
.
deserializeFromNode
(
rootNode
.
get
(
DataProcessingJsonManager
.
DATAPROCCESSING_KEY
)));
...
...
@@ -123,7 +109,6 @@ public class JsonConverter {
ObjectNode
vadereNode
=
StateJsonConverter
.
createObjectNode
();
vadereNode
.
put
(
StateJsonConverter
.
MAIN_MODEL_KEY
,
scenarioStore
.
getMainModel
());
vadereNode
.
put
(
"strategyModel"
,
scenarioStore
.
getStrategyModel
());
ObjectNode
attributesModelNode
=
StateJsonConverter
.
serializeAttributesModelToNode
(
scenarioStore
.
getAttributesList
());
vadereNode
.
set
(
"attributesModel"
,
attributesModelNode
);
...
...
@@ -163,7 +148,6 @@ public class JsonConverter {
StateJsonConverter
.
deserializeAttributesSimulationFromNode
(
attributesSimulationNode
),
StateJsonConverter
.
deserializeAttributesPsychologyFromNode
(
attributesPsychologyNode
),
StateJsonConverter
.
deserializeTopographyFromNode
(
topographyNode
),
StateJsonConverter
.
deserializeStimuliFromArrayNode
(
stimulusInfosArrayNode
),
scenarioStore
.
getStrategyModel
());
StateJsonConverter
.
deserializeStimuliFromArrayNode
(
stimulusInfosArrayNode
));
}
}
VadereState/src/org/vadere/state/attributes/ModelDefinition.java
View file @
5ed719e3
...
...
@@ -12,17 +12,13 @@ import org.vadere.util.reflection.DynamicClassInstantiator;
public
class
ModelDefinition
{
private
String
mainModel
;
private
String
strategyModel
;
private
List
<
Attributes
>
attributesModel
;
public
ModelDefinition
(
String
mainModel
,
String
strategyModel
,
List
<
Attributes
>
attributesModel
)
{
public
ModelDefinition
(
String
mainModel
,
List
<
Attributes
>
attributesModel
)
{
this
.
mainModel
=
mainModel
;
this
.
strategyModel
=
strategyModel
;
this
.
attributesModel
=
attributesModel
;
}
public
void
createAndSetDefaultAttributes
(
List
<
Class
<?
extends
Attributes
>>
attributesClasses
)
{
DynamicClassInstantiator
<
Attributes
>
instantiator
=
new
DynamicClassInstantiator
<>();
attributesModel
=
new
ArrayList
<>(
attributesClasses
.
size
());
...
...
@@ -35,17 +31,9 @@ public class ModelDefinition {
return
mainModel
;
}
public
String
getStrategyModel
()
{
return
strategyModel
;
}
public
void
setMainModel
(
String
mainModel
)
{
this
.
mainModel
=
mainModel
;
}
public
void
setStrategyModel
(
String
strategyModel
)
{
this
.
strategyModel
=
strategyModel
;
}
public
List
<
Attributes
>
getAttributesList
()
{
return
attributesModel
;
...
...
VadereState/src/org/vadere/state/util/StateJsonConverter.java
View file @
5ed719e3
...
...
@@ -147,7 +147,6 @@ public abstract class StateJsonConverter {
return
deserializeTopographyFromNode
(
mapper
.
readTree
(
json
));
}
public
static
Topography
deserializeTopographyFromNode
(
JsonNode
node
)
throws
IllegalArgumentException
{
TopographyStore
store
=
mapper
.
convertValue
(
node
,
TopographyStore
.
class
);
Topography
topography
=
new
Topography
(
store
.
attributes
,
store
.
attributesPedestrian
,
store
.
attributesCar
);
...
...
@@ -247,8 +246,6 @@ public abstract class StateJsonConverter {
throws
JsonProcessingException
{
// may also throw one of the instantiator's exceptions
ObjectNode
node
=
mapper
.
createObjectNode
();
node
.
put
(
"strategyModel"
,
modelDefinition
.
getStrategyModel
());
node
.
put
(
MAIN_MODEL_KEY
,
modelDefinition
.
getMainModel
());
node
.
set
(
"attributesModel"
,
serializeAttributesModelToNode
(
modelDefinition
.
getAttributesList
()));
return
prettyWriter
.
writeValueAsString
(
node
);
...
...
@@ -361,16 +358,9 @@ public abstract class StateJsonConverter {
return
prettyWriter
.
writeValueAsString
(
serializeTopographyToNode
(
topography
));
}
public
static
String
serializeMainModelAttributesModelBundle
(
List
<
Attributes
>
attributesList
,
String
mainModel
,
String
strategyModel
)
public
static
String
serializeMainModelAttributesModelBundle
(
List
<
Attributes
>
attributesList
,
String
mainModel
)
throws
JsonProcessingException
{
ObjectNode
node
=
mapper
.
createObjectNode
();
if
(
strategyModel
.
equals
(
"null"
)){
node
.
set
(
"strategyModel"
,
null
);}
else
{
node
.
put
(
"strategyModel"
,
strategyModel
.
replaceAll
(
"\""
,
""
));
}
node
.
put
(
MAIN_MODEL_KEY
,
mainModel
);
node
.
set
(
"attributesModel"
,
serializeAttributesModelToNode
(
attributesList
));
return
prettyWriter
.
writeValueAsString
(
node
);
...
...
Write
Preview
Supports
Markdown
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