Commit f9b5d672 authored by Julian Zobel's avatar Julian Zobel
Browse files

POM Update & Updated lib usage

parent 282df4c4
......@@ -48,8 +48,7 @@
<repositories>
<!-- simonstrator-repository -->
<!--
<!-- simonstrator-repository -->
<repository>
<id>simonstrator</id>
<url>https://dev.kom.e-technik.tu-darmstadt.de/mvn/</url>
......@@ -60,13 +59,14 @@
<updatePolicy>always</updatePolicy>
</releases>
</repository>
-->
<!-- local kom repository -->
<!-- <repository>
<!--
<repository>
<id>maven.kom</id>
<url>http://www.kom.tu-darmstadt.de/~stingl/PeerfactSim.KOM-Libraries/maven2/</url>
</repository> -->
</repository> -->
<!-- -->
<!-- jgrapht can be found there -->
<!--
......@@ -83,6 +83,8 @@
<url>http://uk.maven.org/maven2</url>
</repository>
-->
<repository>
<id>Google Maven Central</id>
<url>https://maven-central.storage.googleapis.com/repos/central/data/</url>
......@@ -95,35 +97,35 @@
</repository>
</repositories>
<dependencies>
<!-- XML -->
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<!--
<!-- https://mvnrepository.com/artifact/javax.xml/jsr173 -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
<groupId>javax.xml</groupId>
<artifactId>jsr173</artifactId>
<version>1.0</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/stax/stax -->
<dependency>
<groupId>stax</groupId>
<artifactId>stax</artifactId>
<version>1.2.0</version>
</dependency>
<!--
<dependency>
<groupId>stax</groupId>
<artifactId>utils</artifactId>
<version>1.0.0</version>
</dependency>
-->
<dependency>
<groupId>xerces</groupId>
......@@ -153,10 +155,7 @@
<version>1.4</version>
</dependency>
<!-- Logging -->
<!-- unused <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> -->
<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
......@@ -220,8 +219,11 @@
<version>4.3.10.Final</version>
</dependency>
<dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version> </dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>
</dependency>
<!-- Glab Database -->
<dependency>
......@@ -413,7 +415,6 @@
<version>0.1-SNAPSHOT</version>
</dependency>
-->
</dependencies>
</project>
......@@ -24,11 +24,13 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultWeightedEdge;
import de.tud.kom.p2psim.api.topology.obstacles.ObstacleModel;
import de.tud.kom.p2psim.api.util.geo.maps.Map;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.Tuple;
......@@ -80,7 +82,7 @@ public interface WaypointModel {
* @param waypoint
* @return
*/
public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint);
public abstract List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint);
/**
* Returns a list of Tuple<Waypoint, Path> of a specific type that are connected to the given waypoint.
......@@ -89,14 +91,14 @@ public interface WaypointModel {
* @param type
* @return
*/
public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint, Class type);
public abstract List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint, Class type);
/**
* Returns all paths that are part of the waypoint model.
*
* @return
*/
public abstract Set<Path> getPaths();
public abstract Set<PathEdge> getPaths();
/**
* Returns the shortest path between the two given waypoints.
......@@ -105,7 +107,7 @@ public interface WaypointModel {
* @param end
* @return
*/
public abstract List<Path> getShortestPath(Waypoint start, Waypoint end);
public abstract List<PathEdge> getShortestPath(Waypoint start, Waypoint end);
/**
* Returns the total number of waypoints.
......@@ -153,7 +155,7 @@ public interface WaypointModel {
/*
public abstract void setStrongWaypointStrategy(StrongWaypointStrategy strongWaypointStrategy);
*/
public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph();
public Graph<Waypoint, PathEdge> getGraph();
/**
* Indicates if this model is scaled to the required world coordinates.
......
......@@ -20,11 +20,11 @@
package de.tud.kom.p2psim.api.topology.waypoints;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
public interface WaypointModelListener {
public void addedPath(Path path);
public void addedPath(PathEdge path);
public void addedWaypoint(Waypoint waypoint);
public void modifiedWaypoints();
}
......@@ -23,10 +23,10 @@ package de.tud.kom.p2psim.api.util.geo.maps;
import java.util.Collection;
import java.util.List;
import org.jgrapht.Graph;
import de.tud.kom.p2psim.api.topology.obstacles.Obstacle;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.geo.maps.MapChangeListener;
......@@ -39,9 +39,8 @@ public interface Map {
* @return
*/
public PositionVector getDimensions();
// TODO: Extract required functionality
public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph();
public Graph<Waypoint, PathEdge> getGraph();
public void addWaypoint(Waypoint waypoint);
......
......@@ -24,9 +24,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;
import org.jgrapht.graph.DefaultWeightedEdge;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.WeakWaypoint;
import de.tud.kom.p2psim.impl.util.Either;
......@@ -114,7 +116,7 @@ public class ShortestPathWaypointMovement extends AbstractLocalMovementStrategy
Waypoint closestWaypointToDestination = waypointModel
.getClosestWaypoint(finalDestination, WeakWaypoint.class);
List<Path> shortestPath = waypointModel.getShortestPath(
List<PathEdge> shortestPath = waypointModel.getShortestPath(
closestWaypointToCurrentPosition, closestWaypointToDestination);
List<Waypoint> waypointList = buildWaypointList(
......@@ -133,13 +135,13 @@ public class ShortestPathWaypointMovement extends AbstractLocalMovementStrategy
* @return
*/
protected List<Waypoint> buildWaypointList(Waypoint start,
List<Path> shortestPath) {
List<PathEdge> shortestPath) {
List<Waypoint> waypointList = new ArrayList<Waypoint>();
Waypoint lastWaypoint = start;
waypointList.add(start);
for (Path p : shortestPath) {
for (PathEdge p : shortestPath) {
lastWaypoint = p.getOtherEnd(lastWaypoint);
waypointList.add(lastWaypoint);
}
......
......@@ -36,7 +36,7 @@ import de.tud.kom.p2psim.api.topology.waypoints.WaypointModel;
import de.tud.kom.p2psim.api.topology.waypoints.WaypointModelListener;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.StrongWaypoint;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
......@@ -137,7 +137,7 @@ public class StrongWaypointComponentVis extends JComponent
}
@Override
public void addedPath(Path path) {
public void addedPath(PathEdge path) {
needsRedraw = true;
}
......
......@@ -35,12 +35,13 @@ import java.util.Set;
import javax.swing.JComponent;
import org.jgrapht.Graph;
import de.tud.kom.p2psim.api.topology.waypoints.WaypointModel;
import de.tud.kom.p2psim.api.topology.waypoints.WaypointModelListener;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.WeakWaypoint;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
......@@ -125,11 +126,11 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
}
protected void drawColoredGraph(Graphics2D g2) {
ArrayList<Path> usedWaypoints = new ArrayList<Path>();
ArrayList<PathEdge> usedWaypoints = new ArrayList<PathEdge>();
ArrayList<Waypoint> starts = new ArrayList<Waypoint>();
Collection<Waypoint> waypoints = model.getWaypoints();
DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> graph = model.getGraph();
Graph<Waypoint, PathEdge> graph = model.getGraph();
if (waypoints == null || waypoints.isEmpty() || graph == null) {
throw new RuntimeException() {
......@@ -141,13 +142,13 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
if (starts.contains(wp)) continue;
starts.add(wp);
ArrayList<Path> workList = new ArrayList<Path>();
ArrayList<PathEdge> workList = new ArrayList<PathEdge>();
workList.addAll(graph.edgesOf(wp));
Color pathColor = getRandomColor();
while (!workList.isEmpty()) {
Path p = workList.remove(0);
PathEdge p = workList.remove(0);
Waypoint target = p.getTarget();
starts.add(target);
......@@ -173,8 +174,8 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
}
}
private boolean containsPath(ArrayList<Path> workList, Path p1) {
for (Path p : workList) {
private boolean containsPath(ArrayList<PathEdge> workList, PathEdge p1) {
for (PathEdge p : workList) {
if (p.equals(p1)) {
return true;
}
......@@ -187,7 +188,7 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
}
protected void drawPaths(Graphics2D g2) {
Set<Path> paths = model.getPaths();
Set<PathEdge> paths = model.getPaths();
if (paths.isEmpty()) {
throw new RuntimeException() {
......@@ -195,7 +196,7 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
};
}
for (Path p : paths) {
for (PathEdge p : paths) {
PositionVector sourcePos = p.getSource().getPosition();
PositionVector targetPos = p.getTarget().getPosition();
......@@ -227,7 +228,7 @@ public class WeakWaypointComponentVis extends JComponent implements WaypointMode
}
@Override
public void addedPath(Path path) {
public void addedPath(PathEdge path) {
needsRedraw = true;
}
......
......@@ -25,7 +25,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.jgrapht.alg.DijkstraShortestPath;
import org.jgrapht.Graph;
import org.jgrapht.GraphPath;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
import com.google.common.collect.Sets;
......@@ -38,8 +40,7 @@ import de.tud.kom.p2psim.api.util.geo.maps.Map;
import de.tud.kom.p2psim.impl.scenario.simcfg2.annotations.After;
import de.tud.kom.p2psim.impl.scenario.simcfg2.annotations.Configure;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.Tuple;
import de.tud.kom.p2psim.impl.util.geo.maps.MapChangeListener;
......@@ -221,26 +222,26 @@ public abstract class AbstractWaypointModel implements WaypointModel {
}
@Override
public List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint) {
public List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint) {
return getConnectedWaypoints(waypoint, Waypoint.class);
}
@Override
public List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint,
public List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint,
Class type) {
Set<Path> paths = map.getGraph().edgesOf(waypoint);
ArrayList<Tuple<Waypoint, Path>> waypointsAndPaths = new ArrayList<Tuple<Waypoint, Path>>();
Set<PathEdge> paths = map.getGraph().edgesOf(waypoint);
ArrayList<Tuple<Waypoint, PathEdge>> waypointsAndPaths = new ArrayList<Tuple<Waypoint, PathEdge>>();
for (Path p : paths) {
for (PathEdge p : paths) {
Waypoint destinationWaypoint = null;
if (p.getSource().equals(waypoint))
destinationWaypoint = p.getTarget();
else if (p.getTarget().equals(waypoint))
destinationWaypoint = p.getSource();
if (map.getGraph().getEdgeSource(p).equals(waypoint))
destinationWaypoint = map.getGraph().getEdgeTarget(p);
else if (map.getGraph().getEdgeTarget(p).equals(waypoint))
destinationWaypoint = map.getGraph().getEdgeSource(p);
if (destinationWaypoint.getClass().equals(type))
waypointsAndPaths.add(new Tuple<Waypoint, Path>(
waypointsAndPaths.add(new Tuple<Waypoint, PathEdge>(
destinationWaypoint, p));
}
......@@ -278,7 +279,7 @@ public abstract class AbstractWaypointModel implements WaypointModel {
}
}
private void notifyAddedPath(Path path) {
private void notifyAddedPath(PathEdge path) {
for (WaypointModelListener l : listeners) {
l.addedPath(path);
}
......@@ -302,19 +303,18 @@ public abstract class AbstractWaypointModel implements WaypointModel {
}
@Override
public Set<Path> getPaths() {
return map.getGraph().getAllEdges();
public Set<PathEdge> getPaths() {
return map.getGraph().edgeSet();
}
@Override
public List<Path> getShortestPath(Waypoint start, Waypoint end) {
DijkstraShortestPath<Waypoint, Path> dijkstrashortestpath = new DijkstraShortestPath<Waypoint, Path>(
map.getGraph(), start, end);
public List<PathEdge> getShortestPath(Waypoint start, Waypoint end) {
DijkstraShortestPath<Waypoint, PathEdge> dijkstrashortestpath = new DijkstraShortestPath<Waypoint, PathEdge>(map.getGraph());
GraphPath gp = dijkstrashortestpath.getPath(start, end);
List<Path> paths = dijkstrashortestpath.getPathEdgeList();
return dijkstrashortestpath.getPathEdgeList();
return dijkstrashortestpath.getPath(start, end).getEdgeList();
}
@Override
......@@ -323,7 +323,7 @@ public abstract class AbstractWaypointModel implements WaypointModel {
}
@Override
public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph() {
public Graph<Waypoint, PathEdge> getGraph() {
if (map == null)
return null;
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.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.tud.kom.p2psim.impl.topology.waypoints.graph;
import java.util.Set;
import java.util.WeakHashMap;
import org.jgrapht.EdgeFactory;
import org.jgrapht.graph.DefaultDirectedWeightedGraph;
/**
* The simple weighted edge retrievable graph caches the edges
* for later batch retrieval.
*
* It uses the WeakHashMap to avoid unintentional references to
* dead objects.
*
* @author Fabio Zöllner
* @version 1.0, 27.03.2012
* @param <V> Vertices
* @param <E> Edges
*/
public class DefaultDirectedWeightedEdgeRetrievableGraph<V, E> extends DefaultDirectedWeightedGraph<V, E> {
private WeakHashMap<E, Object> edgeMap = new WeakHashMap<E, Object>();
@SuppressWarnings("unchecked")
public DefaultDirectedWeightedEdgeRetrievableGraph(EdgeFactory edgefactory) {
super(edgefactory);
}
@SuppressWarnings("unchecked")
public DefaultDirectedWeightedEdgeRetrievableGraph(Class class1) {
super(class1);
}
public E addEdge(V v1, V v2) {
E e = getEdgeFactory().createEdge(v1, v2);
addEdge(v1, v2, e);
return e;
}
public boolean addEdge(V v1, V v2, E e) {
edgeMap.put(e, null);
return super.addEdge(v1, v2, e);
}
public Set<E> getAllEdges() {
return edgeMap.keySet();
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.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.tud.kom.p2psim.impl.topology.waypoints.graph;
import java.util.Set;
import java.util.WeakHashMap;
import org.jgrapht.graph.SimpleWeightedGraph;
/**
* The simple weighted edge retrievable graph caches the edges
* for later batch retrieval.
*
* It uses the WeakHashMap to avoid unintentional references to
* dead objects.
*
* @author Fabio Zöllner
* @version 1.0, 27.03.2012
* @param <V> Vertices
* @param <E> Edges
*/
public class DefaultWeightedEdgeRetrievableGraph<V, E> extends SimpleWeightedGraph<V, E> {
private WeakHashMap<E, Object> edgeMap = new WeakHashMap<E, Object>();
@SuppressWarnings("unchecked")
public DefaultWeightedEdgeRetrievableGraph(Class<? extends E> edgeClass) {
super(edgeClass);
}
/**
* Add an edge to the graph by specifying the
* start and end vertex.
*/
public E addEdge(V v1, V v2) {
E e = getEdgeFactory().createEdge(v1, v2);
addEdge(v1, v2, e);
return e;
}
/**
* Add an edge to the graph by specifying the
* start and end vertex as well as the edge
* that is connecting the two.
*/
public boolean addEdge(V v1, V v2, E e) {
edgeMap.put(e, null);
return super.addEdge(v1, v2, e);
}
/**
* Returns the set of all edges in the graph.
*
* @return
*/
public Set<E> getAllEdges() {
return edgeMap.keySet();
}
}
......@@ -30,12 +30,12 @@ import org.jgrapht.graph.DefaultWeightedEdge;
* @author Fabio Zöllner
* @version 1.0, 27.03.2012
*/
public class Path extends DefaultWeightedEdge {
public class PathEdge extends DefaultWeightedEdge {
private Waypoint source;
private Waypoint target;
private double weight = 1;
public Path(Waypoint source, Waypoint target) {
public PathEdge(Waypoint source, Waypoint target) {
this.source = source;
this.target = target;
......@@ -73,7 +73,7 @@ public class Path extends DefaultWeightedEdge {
if (getClass() != obj.getClass())
return false;
Path other = (Path) obj;
PathEdge other = (PathEdge) obj;
if (getWeight() != other.getWeight() ||
!source.equals(other.getSource()) ||
!target.equals(other.getTarget()))
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.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.tud.kom.p2psim.impl.topology.waypoints.graph;
import org.jgrapht.EdgeFactory;
/**
* Creates a simple Path from two given way points.
*
* @author Fabio Zöllner
* @version 1.0, 09.04.2012
*/
public class PathEdgeFactory implements EdgeFactory<Waypoint, Path> {
@Override
public Path createEdge(Waypoint sourceVertex, Waypoint targetVertex) {
// Path uses the distance as weight by default
Path path = new Path(sourceVertex, targetVertex);
return path;
}
}
......@@ -38,8 +38,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javanet.staxutils.IndentingXMLStreamWriter;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
......@@ -54,6 +52,7 @@ import org.xml.sax.helpers.DefaultHandler;
import de.tud.kom.p2psim.impl.util.toolkits.SAXToolkit;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import javanet.staxutils.IndentingXMLStreamWriter;
/**
* <p>
......
......@@ -37,7 +37,6 @@ import org.jgrapht.Graph;
import org.jgrapht.GraphPath;
import org.jgrapht.alg.connectivity.ConnectivityInspector;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
import de.tud.kom.p2psim.api.scenario.ConfigurationException;
......@@ -46,9 +45,7 @@ import de.tud.kom.p2psim.api.util.geo.maps.Map;
import de.tud.kom.p2psim.api.util.geo.maps.Way;
import de.tud.kom.p2psim.impl.topology.obstacles.PolygonObstacle;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdgeFactory;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.Tuple;
import de.tud.kom.p2psim.impl.util.geo.maps.MapChangeListener.MapEvent;
......@@ -56,9 +53,9 @@ import de.tud.kom.p2psim.impl.util.geo.maps.MapChangeListener.MapEvent;
public abstract class AbstractMap implements Map {
private List<Obstacle> obstacles = Lists.newLinkedList();
private List<Path> paths = Lists.newLinkedList();
private List<PathEdge> paths = Lists.newLinkedList();
protected Graph<Waypoint, DefaultWeightedEdge> graph = new SimpleWeightedGraph<>(DefaultWeightedEdge.class);
protected Graph<Waypoint, PathEdge> graph = new SimpleWeightedGraph<>(PathEdge.class);
private Multimap<Class, Waypoint> typeWaypointMap = ArrayListMultimap.create();
......@@ -109,9 +106,9 @@ public abstract class AbstractMap implements Map {
}
protected void buildGraph() {
graph = new SimpleWeightedGraph<>(DefaultWeightedEdge.class);
graph = new SimpleWeightedGraph<>(PathEdge.class);
for (Path path : paths) {
for (PathEdge path : paths) {
graph.addVertex(path.getSource());
graph.addVertex(path.getTarget());
typeWaypointMap.put(path.getSource().getClass(), path.getSource());
......@@ -125,12 +122,12 @@ public abstract class AbstractMap implements Map {
raiseMapChanged(new MapChangeListener.ObstacleEvent(obstacle));
}
public void addPath(Path path) {
public void addPath(PathEdge path) {
paths.add(path);
raiseMapChanged(new MapChangeListener.PathEvent(path));
}
public List<Path> getPaths() {
public List<PathEdge> getPaths() {
return paths;
}
......@@ -194,12 +191,11 @@ public abstract class AbstractMap implements Map {
}
protected void createPath(Waypoint wp1, Waypoint wp2) {
Path path = new Path(wp1, wp2);
PathEdge path = new PathEdge(wp1, wp2);
addPath(path);
}
@SuppressWarnings("unchecked")
public DefaultWeightedEdgeRetrievableGraph getGraph() {
public Graph<Waypoint, PathEdge> getGraph() {
return graph;
}
......@@ -259,9 +255,9 @@ public abstract class AbstractMap implements Map {
return swapped[axis.ordinal()];
}
public List<Path> getShortestPath(Waypoint start, Waypoint end) {
DijkstraShortestPath<Waypoint, Path> dijkstrashortestpath = new DijkstraShortestPath<Waypoint, Path>(graph);
GraphPath<Waypoint, Path> path = dijkstrashortestpath.getPath(start, end);
public List<PathEdge> getShortestPath(Waypoint start, Waypoint end) {
DijkstraShortestPath<Waypoint, PathEdge> dijkstrashortestpath = new DijkstraShortestPath<Waypoint, PathEdge>(graph);
GraphPath<Waypoint, PathEdge> path = dijkstrashortestpath.getPath(start, end);
return path.getEdgeList();
}
......@@ -321,8 +317,8 @@ public abstract class AbstractMap implements Map {
while (waypoints != null) {
//removeWaypoints(waypoints, WeakWaypoint.class);
for (Waypoint w : waypoints) {
Set<Path> edges = Sets.newHashSet(graph.edgesOf(w));
for (Path p : edges) {
Set<PathEdge> edges = Sets.newHashSet(graph.edgesOf(w));
for (PathEdge p : edges) {
graph.removeEdge(p);
}
graph.removeVertex(w);
......@@ -360,8 +356,8 @@ public abstract class AbstractMap implements Map {
} catch (IllegalArgumentException e) {
//removeWaypoint(shortestDistancePair.getA());
Set<Path> edges = graph.outgoingEdgesOf(shortestDistancePair.getA());
for (Path p : edges) {
Set<PathEdge> edges = graph.outgoingEdgesOf(shortestDistancePair.getA());
for (PathEdge p : edges) {
graph.removeEdge(p);
}
graph.removeVertex(shortestDistancePair.getA());
......@@ -420,7 +416,7 @@ public abstract class AbstractMap implements Map {
}
private Queue<List<Waypoint>> getConnectedComponents() {
ConnectivityInspector ci = new ConnectivityInspector<Waypoint, Path>(getGraph());
ConnectivityInspector ci = new ConnectivityInspector<Waypoint, PathEdge>(getGraph());
@SuppressWarnings("unchecked")
List<Set<Waypoint>> connectedSets = ci.connectedSets();
......
......@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.impl.util.geo.maps;
import de.tud.kom.p2psim.api.topology.obstacles.Obstacle;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.geo.maps.AbstractMap.Axis;
......@@ -45,11 +45,11 @@ public interface MapChangeListener {
}
public static class PathEvent implements MapEvent {
private Path path;
public PathEvent(Path changedPath) {
private PathEdge path;
public PathEvent(PathEdge changedPath) {
this.path = changedPath;
}
public Path getPath() {
public PathEdge getPath() {
return path;
}
}
......
......@@ -50,7 +50,7 @@ import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.impl.topology.obstacles.PolygonObstacle;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.WeakWaypoint;
import de.tud.kom.p2psim.impl.util.geo.maps.AbstractMap;
......@@ -111,15 +111,15 @@ public class SVGMap extends AbstractMap {
private void resolveIntersections() {
List<PositionVector> intersections = Lists.newLinkedList();
List<Path> worklist = Lists.newLinkedList(getPaths());
Iterator<Path> iter = concurrentIterator(worklist);
List<PathEdge> worklist = Lists.newLinkedList(getPaths());
Iterator<PathEdge> iter = concurrentIterator(worklist);
while (iter.hasNext()) {
Path path = iter.next();
PathEdge path = iter.next();
Iterator<Path> compareIter = concurrentIterator(worklist);
Iterator<PathEdge> compareIter = concurrentIterator(worklist);
while (compareIter.hasNext()) {
Path comparePath = compareIter.next();
PathEdge comparePath = compareIter.next();
// Prevent intersection comparison for the same path and
// connected paths
......@@ -140,8 +140,8 @@ public class SVGMap extends AbstractMap {
PositionVector intersection = intersects(path, comparePath);
if (intersection != null) {
Path[] splitPath1 = splitPath(path, intersection);
Path[] splitPath2 = splitPath(comparePath, intersection);
PathEdge[] splitPath1 = splitPath(path, intersection);
PathEdge[] splitPath2 = splitPath(comparePath, intersection);
// Prevent the creation of loops
if (splitPath1[0].getSource().equals(
......@@ -222,20 +222,20 @@ public class SVGMap extends AbstractMap {
};
}
private Path[] splitPath(Path path, PositionVector intersectionPoint) {
Path[] paths = new Path[2];
private PathEdge[] splitPath(PathEdge path, PositionVector intersectionPoint) {
PathEdge[] paths = new PathEdge[2];
Waypoint wp1 = path.getSource();
Waypoint wp2 = path.getTarget();
Waypoint iwp = getWaypoint(intersectionPoint);
paths[0] = new Path(wp1, iwp);
paths[1] = new Path(wp2, iwp);
paths[0] = new PathEdge(wp1, iwp);
paths[1] = new PathEdge(wp2, iwp);
return paths;
}
private PositionVector intersects(Path path1, Path path2) {
private PositionVector intersects(PathEdge path1, PathEdge path2) {
LineIntersector inter = new RobustLineIntersector();
inter.computeIntersection(path1.getSource().getPosition()
......
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