本文整理了Java中com.github.rinde.rinsim.geom.Graph.getConnection()
方法的一些代码示例,展示了Graph.getConnection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getConnection()
方法的具体详情如下:
包路径:com.github.rinde.rinsim.geom.Graph
类名称:Graph
方法名:getConnection
[英]Returns a Connection between from
and to
.
[中]返回from
和to
之间的连接。
代码示例来源:origin: com.github.rinde/rinsim-geom
@Override
public Connection<E> getConnection(Point from, Point to) {
return delegate.getConnection(from, to);
}
代码示例来源:origin: rinde/RinSim
assertTrue(graph.hasConnection(n3, n2));
assertEquals(1.4, graph.getConnection(n0, n1).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(.8, graph.getConnection(n0, n19663).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.0, graph.getConnection(n0, n16767).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.4, graph.getConnection(n1, n0).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.6, graph.getConnection(n1, n2).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.6, graph.getConnection(n2, n1).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.1, graph.getConnection(n2, n3).data().get().getLength()
.get().doubleValue(), 0);
assertEquals(1.1, graph.getConnection(n3, n2).data().get().getLength()
.get().doubleValue(), 0);
代码示例来源:origin: rinde/RinSim
@Override
public Connection<E> getConnection(Point from, Point to) {
return delegate.getConnection(from, to);
}
代码示例来源:origin: com.github.rinde/rinsim-geom
@Nullable
MultiAttributeData getData(Graph<?> graph, Point from, Point to) {
if (graph.hasConnection(from, to)) {
final Connection<?> conn = graph.getConnection(from, to);
safeToCast = lastGraph == graph && safeToCast;
lastGraph = graph;
if (conn.data().isPresent()
&& (safeToCast || conn.data().get() instanceof MultiAttributeData)) {
safeToCast = true;
return (MultiAttributeData) conn.data().get();
}
}
return null;
}
代码示例来源:origin: rinde/RinSim
@Nullable
MultiAttributeData getData(Graph<?> graph, Point from, Point to) {
if (graph.hasConnection(from, to)) {
final Connection<?> conn = graph.getConnection(from, to);
safeToCast = lastGraph == graph && safeToCast;
lastGraph = graph;
if (conn.data().isPresent()
&& (safeToCast || conn.data().get() instanceof MultiAttributeData)) {
safeToCast = true;
return (MultiAttributeData) conn.data().get();
}
}
return null;
}
代码示例来源:origin: rinde/RinSim
@Override
public void removeConnection(Point from, Point to) {
final Connection<?> conn = delegate.getConnection(from, to);
delegate.removeConnection(from, to);
eventDispatcher
.dispatchEvent(new GraphEvent(
EventTypes.REMOVE_CONNECTION, this, conn));
}
代码示例来源:origin: com.github.rinde/rinsim-geom
@Override
public void removeNode(Point node) {
// collect data of removed connections but only if there is a listener
final List<Connection<?>> removedConnections = newArrayList();
if (eventDispatcher.hasListenerFor(EventTypes.REMOVE_CONNECTION)) {
for (final Point p : delegate.getIncomingConnections(node)) {
removedConnections.add(delegate.getConnection(p, node));
}
for (final Point p : delegate.getOutgoingConnections(node)) {
removedConnections.add(delegate.getConnection(node, p));
}
}
delegate.removeNode(node);
// notify listeners
for (final Connection<?> c : removedConnections) {
eventDispatcher.dispatchEvent(new GraphEvent(
EventTypes.REMOVE_CONNECTION, this, c));
}
}
代码示例来源:origin: rinde/RinSim
@Override
public void removeNode(Point node) {
// collect data of removed connections but only if there is a listener
final List<Connection<?>> removedConnections = newArrayList();
if (eventDispatcher.hasListenerFor(EventTypes.REMOVE_CONNECTION)) {
for (final Point p : delegate.getIncomingConnections(node)) {
removedConnections.add(delegate.getConnection(p, node));
}
for (final Point p : delegate.getOutgoingConnections(node)) {
removedConnections.add(delegate.getConnection(node, p));
}
}
delegate.removeNode(node);
// notify listeners
for (final Connection<?> c : removedConnections) {
eventDispatcher.dispatchEvent(new GraphEvent(
EventTypes.REMOVE_CONNECTION, this, c));
}
}
代码示例来源:origin: com.github.rinde/rinsim-geom
@Override
public void removeConnection(Point from, Point to) {
final Connection<?> conn = delegate.getConnection(from, to);
delegate.removeConnection(from, to);
eventDispatcher
.dispatchEvent(new GraphEvent(
EventTypes.REMOVE_CONNECTION, this, conn));
}
代码示例来源:origin: rinde/RinSim
/**
* Returns all {@link RoadUser}s that are on the connection between
* <code>from</code> and <code>to</code> (inclusive).
* @param from The start point of a connection.
* @param to The end point of a connection.
* @return The {@link RoadUser}s that are on the connection, or an empty set
* in case {@link #hasRoadUserOn(Point, Point)} returns
* <code>false</code>.
* @throws IllegalArgumentException if no connection exists between
* <code>from</code> and <code>to</code>.
*/
@Override
public ImmutableSet<RoadUser> getRoadUsersOn(Point from, Point to) {
checkConnectionsExists(from, to);
final Connection<?> conn = graph.getConnection(from, to);
return ImmutableSet.<RoadUser>builder()
.addAll(registry().getObjectsOn(conn))
.addAll(registry().getObjectsOn(from))
.addAll(registry().getObjectsOn(to))
.build();
}
代码示例来源:origin: rinde/RinSim
+ "connection in the graph.",
from, to);
conn = graph.getConnection(from, to);
代码示例来源:origin: rinde/RinSim
@SuppressWarnings("unchecked")
final Connection<T> conn =
(Connection<T>) roadModel.getGraph().getConnection(prev, cur);
代码示例来源:origin: rinde/RinSim
@Override
public double calculateTravelTime(Graph<?> graph, Point from, Point to,
Unit<Length> distanceUnit,
Measure<Double, Velocity> speed, Unit<Duration> outputTimeUnit) {
final Measure<Double, Length> distance = Measure
.valueOf(graph.getConnection(from, to).getLength(), distanceUnit);
return Measure.valueOf(distance.doubleValue(SI.METER)
// divided by m/s
/ speed.doubleValue(SI.METERS_PER_SECOND),
// gives seconds
SI.SECOND)
// convert to desired unit
.doubleValue(outputTimeUnit);
}
}
代码示例来源:origin: rinde/RinSim
graph.get().getConnection(nextFrom, conn.from());
shockwave.offer(new ShockwaveSimulation(shockwave, conn, nextConn,
nextRelExTimestamp, nextRelReTimestamp, nextActualExTimestamp,
代码示例来源:origin: com.github.rinde/rinsim-geom
@Override
public double calculateTravelTime(Graph<?> graph, Point from, Point to,
Unit<Length> distanceUnit,
Measure<Double, Velocity> speed, Unit<Duration> outputTimeUnit) {
final Measure<Double, Length> distance = Measure
.valueOf(graph.getConnection(from, to).getLength(), distanceUnit);
return Measure.valueOf(distance.doubleValue(SI.METER)
// divided by m/s
/ speed.doubleValue(SI.METERS_PER_SECOND),
// gives seconds
SI.SECOND)
// convert to desired unit
.doubleValue(outputTimeUnit);
}
}
代码示例来源:origin: rinde/RinSim
@Test(expected = IllegalArgumentException.class)
public void nonExistingConnection() {
graph.getConnection(new Point(1, 2), new Point(2, 3));
}
代码示例来源:origin: rinde/RinSim
/**
* Checks whether there is a {@link RoadUser} on the connection between
* <code>from</code> and <code>to</code> (inclusive).
* @param from The start point of a connection.
* @param to The end point of a connection.
* @return <code>true</code> if a {@link RoadUser} occupies either
* <code>from</code>, <code>to</code> or the connection between
* <code>from</code> and <code>to</code>, <code>false</code>
* otherwise.
* @throws IllegalArgumentException if no connection exists between
* <code>from</code> and <code>to</code>.
*/
@Override
public boolean hasRoadUserOn(Point from, Point to) {
checkConnectionsExists(from, to);
return registry().hasObjectOn(graph.getConnection(from, to))
|| registry().hasObjectOn(from)
|| registry().hasObjectOn(to);
}
代码示例来源:origin: rinde/RinSim
@Test
public void unmodifiable2() {
final Point N = new Point(0, 5);
final Point E = new Point(5, 0);
final Point S = new Point(0, -5);
final Point W = new Point(-5, 0);
Graphs.addBiPath(graph, N, E, S, W, N);
final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
graph.addConnection(N, S);
assertEquals(graph.getConnection(N, S), unmod.getConnection(N, S));
}
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
GraphEvent ge = (GraphEvent) e;
if (e.getEventType() == ADD_CONNECTION) {
assertTrue(ge.getGraph().hasConnection(ge.getConnection()));
assertEquals(
ge.getConnection(),
ge.getGraph().getConnection(ge.getConnection().from(),
ge.getConnection().to()));
} else if (e.getEventType() == REMOVE_CONNECTION) {
assertFalse(ge.getGraph().hasConnection(ge.getConnection().from(),
ge.getConnection().to()));
} else if (e.getEventType() == CHANGE_CONNECTION_DATA) {
assertTrue(ge.getGraph().hasConnection(ge.getConnection().from(),
ge.getConnection().to()));
assertEquals(
ge.getConnection().data(),
ge.getGraph()
.getConnection(ge.getConnection().from(),
ge.getConnection().to())
.data());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!