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
4f85fecf
Commit
4f85fecf
authored
Dec 15, 2016
by
Jakob Schöttl
Browse files
Change implementation of clone in ScenarioElements
parent
8077e613
Changes
13
Hide whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/topographycreator/model/AgentWrapper.java
View file @
4f85fecf
...
...
@@ -22,7 +22,7 @@ import org.vadere.util.geometry.shapes.VShape;
*/
public
final
class
AgentWrapper
extends
ScenarioElement
{
/**
t
he wrapped store object. */
/**
T
he wrapped store object. */
private
Agent
agent
;
AgentWrapper
(
final
VPoint
position
)
{
...
...
@@ -70,4 +70,10 @@ public final class AgentWrapper extends ScenarioElement {
public
Attributes
getAttributes
()
{
return
agent
.
getAttributes
();
}
@Override
public
AgentWrapper
clone
()
{
return
new
AgentWrapper
((
Agent
)
agent
.
clone
());
}
}
VadereSimulator/src/org/vadere/simulator/models/osm/PedestrianOSM.java
View file @
4f85fecf
...
...
@@ -317,5 +317,10 @@ public class PedestrianOSM extends Pedestrian {
public
double
getMinStepLength
()
{
return
minStepLength
;
}
@Override
public
PedestrianOSM
clone
()
{
throw
new
RuntimeException
(
"clone is not supported for PedestrianOSM; it seems hard to implement."
);
}
}
VadereSimulator/src/org/vadere/simulator/models/queuing/TargetQueue.java
View file @
4f85fecf
...
...
@@ -13,4 +13,10 @@ public class TargetQueue extends Target {
public
boolean
isMovingTarget
()
{
return
true
;
}
@Override
public
TargetQueue
clone
()
{
throw
new
RuntimeException
(
"clone is not supported for TargetQueue; it seems hard to implement."
);
}
}
VadereState/src/org/vadere/state/attributes/Attributes.java
View file @
4f85fecf
...
...
@@ -21,5 +21,14 @@ public abstract class Attributes extends DefaultSealable implements Cloneable {
protected
static
final
int
ID_NOT_SET
=
-
1
;
public
Attributes
()
{}
@Override
public
Attributes
clone
()
{
try
{
return
(
Attributes
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
throw
new
RuntimeException
(
"This should never happen because the base class is Cloneable."
,
e
);
}
}
}
VadereState/src/org/vadere/state/scenario/Car.java
View file @
4f85fecf
...
...
@@ -68,4 +68,12 @@ public class Car extends Agent implements Comparable<Car> {
return
attributesCar
.
getId
();
}
@Override
public
Car
clone
()
{
throw
new
RuntimeException
(
"clone is not supported for Car; it seems hard to implement."
);
// return new Car(attributesCar, new Random());
// TODO get random from super class instead of creating a new one
// TODO attributesAgent in super class must be copied as well
}
}
VadereState/src/org/vadere/state/scenario/Obstacle.java
View file @
4f85fecf
...
...
@@ -70,4 +70,9 @@ public class Obstacle extends ScenarioElement {
public
Attributes
getAttributes
()
{
return
attributes
;
}
@Override
public
Obstacle
clone
()
{
return
new
Obstacle
((
AttributesObstacle
)
attributes
.
clone
());
}
}
VadereState/src/org/vadere/state/scenario/Pedestrian.java
View file @
4f85fecf
...
...
@@ -112,4 +112,10 @@ public class Pedestrian extends Agent {
public
void
setLikelyInjured
(
boolean
likelyInjured
)
{
this
.
isLikelyInjured
=
likelyInjured
;
}
@Override
public
Pedestrian
clone
()
{
return
new
Pedestrian
(
this
);
}
}
VadereState/src/org/vadere/state/scenario/ScenarioElement.java
View file @
4f85fecf
...
...
@@ -4,7 +4,7 @@ import org.vadere.state.attributes.Attributes;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.shapes.VShape
;
public
abstract
class
ScenarioElement
implements
Cloneable
{
public
abstract
class
ScenarioElement
{
public
abstract
VShape
getShape
();
...
...
@@ -19,17 +19,10 @@ public abstract class ScenarioElement implements Cloneable {
/**
* Redeclare the clone method as public to enable copy & paste of scenario
* elements in scenario editor.
* Subclasses must implement this method using a copy constructor.
*/
@Override
public
ScenarioElement
clone
()
{
try
{
return
(
ScenarioElement
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
// this case should never happen (because this base class is cloneable)
// unless a subclass contains not-cloneable fields or so
throw
new
RuntimeException
(
e
);
}
}
public
abstract
ScenarioElement
clone
();
public
abstract
Attributes
getAttributes
();
}
VadereState/src/org/vadere/state/scenario/Source.java
View file @
4f85fecf
...
...
@@ -71,4 +71,9 @@ public class Source extends ScenarioElement {
public
ScenarioElementType
getType
()
{
return
ScenarioElementType
.
SOURCE
;
}
@Override
public
Source
clone
()
{
return
new
Source
((
AttributesSource
)
attributes
.
clone
());
}
}
VadereState/src/org/vadere/state/scenario/Stairs.java
View file @
4f85fecf
...
...
@@ -126,4 +126,10 @@ public class Stairs extends ScenarioElement {
public
AttributesStairs
getAttributes
()
{
return
attributes
;
}
@Override
public
Stairs
clone
()
{
return
new
Stairs
((
AttributesStairs
)
attributes
.
clone
());
}
}
VadereState/src/org/vadere/state/scenario/Target.java
View file @
4f85fecf
...
...
@@ -141,4 +141,9 @@ public class Target extends ScenarioElement implements Comparable<Target> {
return
Collections
.
unmodifiableCollection
(
targetListeners
);
}
@Override
public
Target
clone
()
{
return
new
Target
((
AttributesTarget
)
attributes
.
clone
());
}
}
VadereState/src/org/vadere/state/scenario/TargetPedestrian.java
View file @
4f85fecf
...
...
@@ -60,4 +60,10 @@ public class TargetPedestrian extends Target implements DynamicElementRemoveList
return
true
;
}
@Override
public
TargetPedestrian
clone
()
{
throw
new
RuntimeException
(
"clone is not supported for TargetPedestrian; it seems hard to implement."
);
}
}
VadereState/src/org/vadere/state/scenario/Teleporter.java
View file @
4f85fecf
...
...
@@ -61,4 +61,10 @@ public class Teleporter extends ScenarioElement {
public
int
hashCode
()
{
return
attributes
!=
null
?
attributes
.
hashCode
()
:
0
;
}
@Override
public
Teleporter
clone
()
{
return
new
Teleporter
((
AttributesTeleporter
)
attributes
.
clone
());
}
}
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