use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class BaseConnectionStrategy method getFreightPassedInNode.
protected Map<Train, List<FreightConnectionPath>> getFreightPassedInNode(TimeInterval fromInterval, FreightConnectionFilter filter) {
if (!fromInterval.isNodeOwner()) {
throw new IllegalArgumentException("Only node intervals allowed.");
}
Map<Train, List<FreightConnectionPath>> result = new LinkedHashMap<>();
List<FNConnection> connections = freightNet.getTrainsFrom(fromInterval);
for (FNConnection conn : connections) {
List<FreightConnectionPath> nodes = this.getFreightToNodesImpl(conn.getTo(), conn.getFreightDstFilter(filter, true));
result.put(conn.getTo().getTrain(), nodes);
}
return result;
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class BaseConnectionStrategy method getFreightToNodesImpl.
private void getFreightToNodesImpl(Node start, TimeInterval fromInterval, List<TrainConnection> path, List<FreightConnectionPath> result, Set<FNConnection> used, FreightConnectionFilter filter, FilterContext context) {
FilterResult filterResult;
Iterator<TimeInterval> intervals = fromInterval.getTrain().iterator();
Iterators.find(intervals, interval -> interval == fromInterval);
intervals = Iterators.filter(intervals, interval -> interval.isNodeOwner() && (interval.isFreightTo() || interval.isFreightConnection()));
while (intervals.hasNext()) {
TimeInterval i = intervals.next();
if (i.isFreight()) {
FreightConnectionPath newDst = FreightFactory.createFreightNodeConnection(start, i.getOwnerAsNode(), i.isRegionCenterTransfer(), createNewPath(path, fromInterval, i));
filterResult = filter.accepted(context, newDst, 0);
if (filterResult == FilterResult.STOP_EXCLUDE) {
break;
}
if (filterResult != FilterResult.IGNORE) {
result.add(newDst);
}
if (filterResult == FilterResult.STOP_INCLUDE) {
break;
}
}
for (FNConnection conn : freightNet.getTrainsFrom(i)) {
if (!used.contains(conn)) {
used.add(conn);
List<TrainConnection> newPath = createNewPath(path, fromInterval, conn.getFrom());
this.getFreightToNodesImpl(start, conn.getTo(), newPath, result, used, conn.getFreightDstFilter(filter, false), context);
}
}
}
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class FreightNetPane2 method checkEnabledMoveConnection.
private boolean checkEnabledMoveConnection(FNConnection conn, int indexChange) {
if (conn == null) {
return false;
}
FreightNet net = model.get().getFreightNet();
List<FNConnection> conns = net.getTrainsFrom(conn.getFrom());
int currentIndex = conns.indexOf(conn);
int newIndex = currentIndex + indexChange;
return newIndex >= 0 && newIndex < conns.size();
}
Aggregations