Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
vadere
vadere
Commits
fd2924ab
Commit
fd2924ab
authored
Jul 02, 2018
by
Daniel Lehmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] implement setAttributes of all inheriting classes of ScenarioElement
parent
939c6119
Pipeline
#59468
passed with stage
in 51 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
8 deletions
+59
-8
VadereGui/src/org/vadere/gui/components/view/ScenarioElementView.java
...c/org/vadere/gui/components/view/ScenarioElementView.java
+1
-1
VadereGui/src/org/vadere/gui/topographycreator/control/ReflectionAttributeModifier.java
...opographycreator/control/ReflectionAttributeModifier.java
+1
-0
VadereGui/src/org/vadere/gui/topographycreator/model/AgentWrapper.java
.../org/vadere/gui/topographycreator/model/AgentWrapper.java
+5
-0
VadereSimulator/src/org/vadere/simulator/entrypoints/ScenarioBuilder.java
...src/org/vadere/simulator/entrypoints/ScenarioBuilder.java
+6
-1
VadereState/src/org/vadere/state/scenario/Agent.java
VadereState/src/org/vadere/state/scenario/Agent.java
+7
-1
VadereState/src/org/vadere/state/scenario/Car.java
VadereState/src/org/vadere/state/scenario/Car.java
+6
-1
VadereState/src/org/vadere/state/scenario/Obstacle.java
VadereState/src/org/vadere/state/scenario/Obstacle.java
+8
-1
VadereState/src/org/vadere/state/scenario/Source.java
VadereState/src/org/vadere/state/scenario/Source.java
+9
-1
VadereState/src/org/vadere/state/scenario/Target.java
VadereState/src/org/vadere/state/scenario/Target.java
+9
-1
VadereState/src/org/vadere/state/scenario/Teleporter.java
VadereState/src/org/vadere/state/scenario/Teleporter.java
+7
-1
No files found.
VadereGui/src/org/vadere/gui/components/view/ScenarioElementView.java
View file @
fd2924ab
...
...
@@ -143,7 +143,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
}
else
{
try
{
Attributes
attributes
=
StateJsonConverter
.
deserializeScenarioElementType
(
json
,
element
.
getType
());
ReflectionAttributeModifier
.
setAttributes
(
element
,
attributes
);
element
.
setAttributes
(
attributes
);
// Replaces previous
ReflectionAttributeModifier.setAttributes
(see #91)
ScenarioPanel
.
removeJsonParsingErrorMsg
();
ProjectView
.
getMainWindow
().
refreshScenarioNames
();
jsonValidIndicator
.
setValid
();
...
...
VadereGui/src/org/vadere/gui/topographycreator/control/ReflectionAttributeModifier.java
View file @
fd2924ab
...
...
@@ -3,6 +3,7 @@ package org.vadere.gui.topographycreator.control;
import
java.lang.reflect.Field
;
import
org.vadere.gui.topographycreator.model.AgentWrapper
;
import
org.vadere.simulator.projects.Scenario
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.scenario.ScenarioElement
;
import
org.vadere.util.geometry.shapes.VPoint
;
...
...
VadereGui/src/org/vadere/gui/topographycreator/model/AgentWrapper.java
View file @
fd2924ab
...
...
@@ -71,6 +71,11 @@ public final class AgentWrapper extends ScenarioElement {
return
agent
.
getAttributes
();
}
@Override
public
void
setAttributes
(
Attributes
attributes
){
this
.
agent
.
setAttributes
(
attributes
);
}
@Override
public
AgentWrapper
clone
()
{
return
new
AgentWrapper
((
Agent
)
agent
.
clone
());
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/ScenarioBuilder.java
View file @
fd2924ab
...
...
@@ -252,7 +252,12 @@ public class ScenarioBuilder {
AttributesBuilder
<
Attributes
>
attBuilder
=
new
AttributesBuilder
<>(
element
.
getAttributes
());
attBuilder
.
setField
(
fieldName
,
value
);
E
clone
=
(
E
)
element
.
clone
();
reflectionAttributeModifier
.
setAttributes
(
clone
,
attBuilder
.
build
());
//NOTE see issue #91:
//This class is not tested - revert change by uncommenting reflextion and comment in
//clone.setAttributes
//reflectionAttributeModifier.setAttributes(clone, attBuilder.build());
clone
.
setAttributes
(
attBuilder
.
build
());
return
clone
;
}
...
...
VadereState/src/org/vadere/state/scenario/Agent.java
View file @
fd2924ab
...
...
@@ -7,6 +7,7 @@ import java.util.Random;
import
org.apache.commons.math3.random.JDKRandomGenerator
;
import
org.apache.commons.math3.random.RandomGenerator
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.util.geometry.Vector2D
;
import
org.vadere.util.geometry.shapes.VCircle
;
...
...
@@ -31,7 +32,7 @@ public abstract class Agent extends DynamicElement {
private
double
freeFlowSpeed
;
private
final
AttributesAgent
attributes
;
private
AttributesAgent
attributes
;
public
Agent
(
AttributesAgent
attributesAgent
)
{
position
=
new
VPoint
(
0
,
0
);
...
...
@@ -184,6 +185,11 @@ public abstract class Agent extends DynamicElement {
// Setters...
@Override
public
void
setAttributes
(
Attributes
attributes
){
this
.
attributes
=
(
AttributesAgent
)
attributes
;
}
/**
* Set the index pointing to the next target in the target list.
*
...
...
VadereState/src/org/vadere/state/scenario/Car.java
View file @
fd2924ab
...
...
@@ -2,6 +2,7 @@ package org.vadere.state.scenario;
import
java.util.Random
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesCar
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.Vector2D
;
...
...
@@ -11,7 +12,7 @@ import org.vadere.util.geometry.shapes.VRectangle;
public
class
Car
extends
Agent
implements
Comparable
<
Car
>
{
private
final
AttributesCar
attributesCar
;
private
AttributesCar
attributesCar
;
public
Car
(
AttributesCar
attributesCar
,
Random
random
)
{
super
(
attributesCar
,
random
);
...
...
@@ -63,6 +64,10 @@ public class Car extends Agent implements Comparable<Car> {
return
this
.
attributesCar
;
}
public
void
setAttributes
(
Attributes
attributes
)
{
this
.
attributesCar
=
(
AttributesCar
)
attributes
;
}
@Override
public
int
getId
()
{
return
attributesCar
.
getId
();
...
...
VadereState/src/org/vadere/state/scenario/Obstacle.java
View file @
fd2924ab
package
org.vadere.state.scenario
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.state.attributes.scenario.AttributesObstacle
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.shapes.VShape
;
public
class
Obstacle
extends
ScenarioElement
{
private
final
AttributesObstacle
attributes
;
private
AttributesObstacle
attributes
;
public
Obstacle
(
AttributesObstacle
attributes
)
{
if
(
attributes
==
null
)
...
...
@@ -71,6 +72,12 @@ public class Obstacle extends ScenarioElement {
return
attributes
;
}
@Override
public
void
setAttributes
(
Attributes
attributes
){
this
.
attributes
=
(
AttributesObstacle
)
attributes
;
}
@Override
public
Obstacle
clone
()
{
return
new
Obstacle
((
AttributesObstacle
)
attributes
.
clone
());
...
...
VadereState/src/org/vadere/state/scenario/Source.java
View file @
fd2924ab
package
org.vadere.state.scenario
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesSource
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.shapes.VShape
;
public
class
Source
extends
ScenarioElement
{
private
final
AttributesSource
attributes
;
private
AttributesSource
attributes
;
public
Source
(
AttributesSource
attributes
)
{
this
.
attributes
=
attributes
;
...
...
@@ -32,6 +33,13 @@ public class Source extends ScenarioElement {
return
attributes
;
}
@Override
public
void
setAttributes
(
Attributes
attributes
){
this
.
attributes
=
(
AttributesSource
)
attributes
;
}
public
double
getStartTime
()
{
return
attributes
.
getStartTime
();
}
...
...
VadereState/src/org/vadere/state/scenario/Target.java
View file @
fd2924ab
...
...
@@ -6,13 +6,14 @@ import java.util.HashMap;
import
java.util.LinkedList
;
import
java.util.Map
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesTarget
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.shapes.VShape
;
public
class
Target
extends
ScenarioElement
implements
Comparable
<
Target
>
{
private
final
AttributesTarget
attributes
;
private
AttributesTarget
attributes
;
private
final
Map
<
Integer
,
Double
>
enteringTimes
;
/**
...
...
@@ -113,6 +114,13 @@ public class Target extends ScenarioElement implements Comparable<Target> {
return
attributes
;
}
@Override
public
void
setAttributes
(
Attributes
attributes
){
this
.
attributes
=
(
AttributesTarget
)
attributes
;
}
/** Is this target actually a pedestrian? @see scenario.TargetPedestrian */
public
boolean
isTargetPedestrian
()
{
return
false
;
...
...
VadereState/src/org/vadere/state/scenario/Teleporter.java
View file @
fd2924ab
package
org.vadere.state.scenario
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.scenario.AttributesTeleporter
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.Vector2D
;
...
...
@@ -8,7 +9,7 @@ import org.vadere.util.geometry.shapes.VShape;
public
class
Teleporter
extends
ScenarioElement
{
private
final
AttributesTeleporter
attributes
;
private
AttributesTeleporter
attributes
;
public
Teleporter
(
AttributesTeleporter
attributes
)
{
this
.
attributes
=
attributes
;
...
...
@@ -37,6 +38,11 @@ public class Teleporter extends ScenarioElement {
return
attributes
;
}
@Override
public
void
setAttributes
(
Attributes
attributes
)
{
this
.
attributes
=
(
AttributesTeleporter
)
attributes
;
}
@Override
public
ScenarioElementType
getType
()
{
return
ScenarioElementType
.
TELEPORTER
;
...
...
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