Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
f9b5d672
Commit
f9b5d672
authored
Aug 24, 2020
by
Julian Zobel
Browse files
POM Update & Updated lib usage
parent
282df4c4
Changes
16
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
f9b5d672
...
...
@@ -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>
src/de/tud/kom/p2psim/api/topology/waypoints/WaypointModel.java
View file @
f9b5d672
...
...
@@ -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
,
Path
Edge
>>
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
,
Path
Edge
>>
getConnectedWaypoints
(
Waypoint
waypoint
,
Class
type
);
/**
* Returns all paths that are part of the waypoint model.
*
* @return
*/
public
abstract
Set
<
Path
>
getPaths
();
public
abstract
Set
<
Path
Edge
>
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
<
Path
Edge
>
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
DefaultWeightedEdgeRetrievable
Graph
<
Waypoint
,
Path
>
getGraph
();
public
Graph
<
Waypoint
,
Path
Edge
>
getGraph
();
/**
* Indicates if this model is scaled to the required world coordinates.
...
...
src/de/tud/kom/p2psim/api/topology/waypoints/WaypointModelListener.java
View file @
f9b5d672
...
...
@@ -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.Path
Edge
;
import
de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint
;
public
interface
WaypointModelListener
{
public
void
addedPath
(
Path
path
);
public
void
addedPath
(
Path
Edge
path
);
public
void
addedWaypoint
(
Waypoint
waypoint
);
public
void
modifiedWaypoints
();
}
src/de/tud/kom/p2psim/api/util/geo/maps/Map.java
View file @
f9b5d672
...
...
@@ -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
);
...
...
src/de/tud/kom/p2psim/impl/topology/movement/local/ShortestPathWaypointMovement.java
View file @
f9b5d672
...
...
@@ -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.Path
Edge
;
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
<
Path
Edge
>
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
<
Path
Edge
>
shortestPath
)
{
List
<
Waypoint
>
waypointList
=
new
ArrayList
<
Waypoint
>();
Waypoint
lastWaypoint
=
start
;
waypointList
.
add
(
start
);
for
(
Path
p
:
shortestPath
)
{
for
(
Path
Edge
p
:
shortestPath
)
{
lastWaypoint
=
p
.
getOtherEnd
(
lastWaypoint
);
waypointList
.
add
(
lastWaypoint
);
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/StrongWaypointComponentVis.java
View file @
f9b5d672
...
...
@@ -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.Path
Edge
;
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
(
Path
Edge
path
)
{
needsRedraw
=
true
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/WeakWaypointComponentVis.java
View file @
f9b5d672
...
...
@@ -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
<
Path
Edge
>
usedWaypoints
=
new
ArrayList
<
Path
Edge
>();
ArrayList
<
Waypoint
>
starts
=
new
ArrayList
<
Waypoint
>();
Collection
<
Waypoint
>
waypoints
=
model
.
getWaypoints
();
DefaultWeightedEdgeRetrievable
Graph
<
Waypoint
,
Path
>
graph
=
model
.
getGraph
();
Graph
<
Waypoint
,
Path
Edge
>
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
<
Path
Edge
>
workList
=
new
ArrayList
<
Path
Edge
>();
workList
.
addAll
(
graph
.
edgesOf
(
wp
));
Color
pathColor
=
getRandomColor
();
while
(!
workList
.
isEmpty
())
{
Path
p
=
workList
.
remove
(
0
);
Path
Edge
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
<
Path
Edge
>
workList
,
Path
Edge
p1
)
{
for
(
Path
Edge
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
<
Path
Edge
>
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
(
Path
Edge
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
(
Path
Edge
path
)
{
needsRedraw
=
true
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/waypoints/AbstractWaypointModel.java
View file @
f9b5d672
...
...
@@ -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
,
Path
Edge
>>
getConnectedWaypoints
(
Waypoint
waypoint
)
{
return
getConnectedWaypoints
(
waypoint
,
Waypoint
.
class
);
}
@Override
public
List
<
Tuple
<
Waypoint
,
Path
>>
getConnectedWaypoints
(
Waypoint
waypoint
,
public
List
<
Tuple
<
Waypoint
,
Path
Edge
>>
getConnectedWaypoints
(
Waypoint
waypoint
,
Class
type
)
{
Set
<
Path
>
paths
=
map
.
getGraph
().
edgesOf
(
waypoint
);
ArrayList
<
Tuple
<
Waypoint
,
Path
>>
waypointsAndPaths
=
new
ArrayList
<
Tuple
<
Waypoint
,
Path
>>();
Set
<
Path
Edge
>
paths
=
map
.
getGraph
().
edgesOf
(
waypoint
);
ArrayList
<
Tuple
<
Waypoint
,
Path
Edge
>>
waypointsAndPaths
=
new
ArrayList
<
Tuple
<
Waypoint
,
Path
Edge
>>();
for
(
Path
p
:
paths
)
{
for
(
Path
Edge
p
:
paths
)
{
Waypoint
destinationWaypoint
=
null
;
if
(
p
.
getSource
().
equals
(
waypoint
))
destinationWaypoint
=
p
.
getTarget
();
else
if
(
p
.
getTarget
().
equals
(
waypoint
))
destinationWaypoint
=
p
.
getSource
();
if
(
ma
p
.
get
Graph
().
getEdge
Source
(
p
).
equals
(
waypoint
))
destinationWaypoint
=
ma
p
.
get
Graph
().
getEdge
Target
(
p
);
else
if
(
ma
p
.
get
Graph
().
getEdge
Target
(
p
).
equals
(
waypoint
))
destinationWaypoint
=
ma
p
.
get
Graph
().
getEdge
Source
(
p
);
if
(
destinationWaypoint
.
getClass
().
equals
(
type
))
waypointsAndPaths
.
add
(
new
Tuple
<
Waypoint
,
Path
>(
waypointsAndPaths
.
add
(
new
Tuple
<
Waypoint
,
Path
Edge
>(
destinationWaypoint
,
p
));
}
...
...
@@ -278,7 +279,7 @@ public abstract class AbstractWaypointModel implements WaypointModel {
}
}
private
void
notifyAddedPath
(
Path
path
)
{
private
void
notifyAddedPath
(
Path
Edge
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
<
Path
Edge
>
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
DefaultWeightedEdgeRetrievable
Graph
<
Waypoint
,
Path
>
getGraph
()
{
public
Graph
<
Waypoint
,
Path
Edge
>
getGraph
()
{
if
(
map
==
null
)
return
null
;
...
...
src/de/tud/kom/p2psim/impl/topology/waypoints/graph/DefaultDirectedWeightedEdgeRetrievableGraph.java
deleted
100644 → 0
View file @
282df4c4
/*
* 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
();
}
}
src/de/tud/kom/p2psim/impl/topology/waypoints/graph/DefaultWeightedEdgeRetrievableGraph.java
deleted
100644 → 0
View file @
282df4c4
/*
* 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
();
}
}
src/de/tud/kom/p2psim/impl/topology/waypoints/graph/Path.java
→
src/de/tud/kom/p2psim/impl/topology/waypoints/graph/Path
Edge
.java
View file @
f9b5d672
...
...
@@ -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
Path
Edge
extends
DefaultWeightedEdge
{
private
Waypoint
source
;
private
Waypoint
target
;
private
double
weight
=
1
;
public
Path
(
Waypoint
source
,
Waypoint
target
)
{
public
Path
Edge
(
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
;
Path
Edge
other
=
(
Path
Edge
)
obj
;
if
(
getWeight
()
!=
other
.
getWeight
()
||
!
source
.
equals
(
other
.
getSource
())
||
!
target
.
equals
(
other
.
getTarget
()))
...
...
src/de/tud/kom/p2psim/impl/topology/waypoints/graph/PathEdgeFactory.java
deleted
100644 → 0
View file @
282df4c4
/*
* 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
;
}
}
src/de/tud/kom/p2psim/impl/util/db/relational/RelationalDB.java
View file @
f9b5d672
...
...
@@ -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>
...
...
src/de/tud/kom/p2psim/impl/util/geo/maps/AbstractMap.java
View file @
f9b5d672
...
...
@@ -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
<
Path
Edge
>
paths
=
Lists
.
newLinkedList
();
protected
Graph
<
Waypoint
,
DefaultWeighted
Edge
>
graph
=
new
SimpleWeightedGraph
<>(
DefaultWeighted
Edge
.
class
);
protected
Graph
<
Waypoint
,
Path
Edge
>
graph
=
new
SimpleWeightedGraph
<>(
Path
Edge
.
class
);
private
Multimap
<
Class
,
Waypoint
>
typeWaypointMap
=
ArrayListMultimap
.
create
();
...
...
@@ -109,9 +106,9 @@ public abstract class AbstractMap implements Map {
}
protected
void
buildGraph
()
{
graph
=
new
SimpleWeightedGraph
<>(
DefaultWeighted
Edge
.
class
);
graph
=
new
SimpleWeightedGraph
<>(
Path
Edge
.
class
);
for
(
Path
path
:
paths
)
{
for
(
Path
Edge
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
(
Path
Edge
path
)
{
paths
.
add
(
path
);
raiseMapChanged
(
new
MapChangeListener
.
PathEvent
(
path
));
}
public
List
<
Path
>
getPaths
()
{
public
List
<
Path
Edge
>
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
);
Path
Edge
path
=
new
Path
Edge
(
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
<
Path
Edge
>
getShortestPath
(
Waypoint
start
,
Waypoint
end
)
{
DijkstraShortestPath
<
Waypoint
,
Path
Edge
>
dijkstrashortestpath
=
new
DijkstraShortestPath
<
Waypoint
,
Path
Edge
>(
graph
);
GraphPath
<
Waypoint
,
Path
Edge
>
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
<
Path
Edge
>
edges
=
Sets
.
newHashSet
(
graph
.
edgesOf
(
w
));
for
(
Path
Edge
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
<
Path
Edge
>
edges
=
graph
.
outgoingEdgesOf
(
shortestDistancePair
.
getA
());
for
(
Path
Edge
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
,
Path
Edge
>(
getGraph
());
@SuppressWarnings
(
"unchecked"
)
List
<
Set
<
Waypoint
>>
connectedSets
=
ci
.
connectedSets
();
...
...
src/de/tud/kom/p2psim/impl/util/geo/maps/MapChangeListener.java
View file @
f9b5d672
...
...
@@ -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.Path
Edge
;
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
Path
Edge
path
;
public
PathEvent
(
Path
Edge
changedPath
)
{
this
.
path
=
changedPath
;
}
public
Path
getPath
()
{
public
Path
Edge
getPath
()
{
return
path
;
}
}
...
...
src/de/tud/kom/p2psim/impl/util/geo/maps/svg/SVGMap.java
View file @
f9b5d672
...
...
@@ -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.Path
Edge
;
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
<
Path
Edge
>
worklist
=
Lists
.
newLinkedList
(
getPaths
());
Iterator
<
Path
Edge
>
iter
=
concurrentIterator
(
worklist
);
while
(
iter
.
hasNext
())
{
Path
path
=
iter
.
next
();
Path
Edge
path
=
iter
.
next
();
Iterator
<
Path
>
compareIter
=
concurrentIterator
(
worklist
);
Iterator
<
Path
Edge
>
compareIter
=
concurrentIterator
(
worklist
);
while
(
compareIter
.
hasNext
())
{
Path
comparePath
=
compareIter
.
next
();
Path
Edge
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
);
Path
Edge
[]
splitPath1
=
splitPath
(
path
,
intersection
);
Path
Edge
[]
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
Path
Edge
[]
splitPath
(
Path
Edge
path
,
PositionVector
intersectionPoint
)
{
Path
Edge
[]
paths
=
new
Path
Edge
[
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
Path
Edge
(
wp1
,
iwp
);
paths
[
1
]
=
new
Path
Edge
(
wp2
,
iwp
);
return
paths
;
}
private
PositionVector
intersects
(
Path
path1
,
Path
path2
)
{
private
PositionVector
intersects
(
Path
Edge
path1
,
Path
Edge
path2
)
{
LineIntersector
inter
=
new
RobustLineIntersector
();
inter
.
computeIntersection
(
path1
.
getSource
().
getPosition
()
...
...
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