Commit 90029522 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Current version

parent ce5b0342
...@@ -52,6 +52,8 @@ public class RoadNetworkEdge { ...@@ -52,6 +52,8 @@ public class RoadNetworkEdge {
private final EdgeController _edgeController; private final EdgeController _edgeController;
private List<RoadNetworkEdgeListener> _listeners = new ArrayList<>();
public RoadNetworkEdge(SerializableRoadNetworkEdge pEdge, EdgeController pEdgeController) { public RoadNetworkEdge(SerializableRoadNetworkEdge pEdge, EdgeController pEdgeController) {
_edgeController = pEdgeController; _edgeController = pEdgeController;
...@@ -73,12 +75,20 @@ public class RoadNetworkEdge { ...@@ -73,12 +75,20 @@ public class RoadNetworkEdge {
_angle = pAngle; _angle = pAngle;
} }
public void registerEdgeListener(RoadNetworkEdgeListener pListener) {
_listeners.add(pListener);
}
public void addRoadProperty(RoadProperty pProperty) { public void addRoadProperty(RoadProperty pProperty) {
_activeProperties.add(pProperty); _activeProperties.add(pProperty);
if (pProperty instanceof JamProperty) { if (pProperty instanceof JamProperty) {
setMaxSpeed(((JamProperty) pProperty).getAverageSpeed()); setMaxSpeed(((JamProperty) pProperty).getAverageSpeed());
} }
for (RoadNetworkEdgeListener roadNetworkEdgeListener : _listeners) {
roadNetworkEdgeListener.edgeActivated(this, pProperty);
}
} }
/** /**
...@@ -115,7 +125,7 @@ public class RoadNetworkEdge { ...@@ -115,7 +125,7 @@ public class RoadNetworkEdge {
* @return * @return
*/ */
public static double getCorrespondingState(double pExpectation) { public static double getCorrespondingState(double pExpectation) {
return ((int) (pExpectation / VectoralJamProperty.SCALING)) * VectoralJamProperty.SCALING; return ((int) Math.round(pExpectation / VectoralJamProperty.SCALING)) * VectoralJamProperty.SCALING;
} }
public void removeRoadProperty(RoadProperty pProperty) { public void removeRoadProperty(RoadProperty pProperty) {
...@@ -124,6 +134,10 @@ public class RoadNetworkEdge { ...@@ -124,6 +134,10 @@ public class RoadNetworkEdge {
if (pProperty instanceof JamProperty) { if (pProperty instanceof JamProperty) {
setMaxSpeed(getOriginalMaxSpeed()); setMaxSpeed(getOriginalMaxSpeed());
} }
for (RoadNetworkEdgeListener roadNetworkEdgeListener : _listeners) {
roadNetworkEdgeListener.edgeDeactivated(this, pProperty);
}
} }
/** /**
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
public interface RoadNetworkEdgeListener {
void edgeActivated(RoadNetworkEdge pEdge, RoadProperty pProperty);
void edgeDeactivated(RoadNetworkEdge pEdge, RoadProperty pProperty);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment