use of net.parostroj.timetable.model.freight.NodeConnectionEdges in project grafikon by jub77.
the class FreightCheckPanel method checkFreight.
private void checkFreight(TextBuffer buffer) {
FreightConnectionStrategy strategy = FreightConnectionStrategy.createCached(diagram.getFreightNet().getConnectionStrategy());
// check
FreightChecker checker = new FreightChecker(strategy);
// check all centers
buffer.appendText(ResourceLoader.getString("freight.check.centers") + ":\n", boldUnderlineStyle);
diagram.getNet().getNodes().stream().filter(n -> n.isCenterOfRegions()).forEach(n -> {
Set<Node> noConnToNodes = checker.getNoConnectionsToNodes(n, notFreightTypes);
Set<Node> noConnToCenter = checker.getNoConnectionToCenter(n, notFreightTypes);
buffer.appendText("-", noConnToCenter.isEmpty() && noConnToNodes.isEmpty() ? okStyle : errorStyle);
buffer.appendText(String.format(" %s\n", nodeWithRegionToString(n)), null);
for (Node ncNode : noConnToNodes) {
buffer.appendText(String.format(" %s → %s\n", n.getName(), ncNode.getName()), null);
}
for (Node ncNode : noConnToCenter) {
buffer.appendText(String.format(" %s → %s\n", ncNode.getName(), n.getName()), null);
}
});
buffer.appendText(ResourceLoader.getString("freight.check.center.connections") + ":\n", boldUnderlineStyle);
Map<Node, List<ConnectionState<NodeConnectionEdges>>> centerConnMap = checker.analyseCenterConnections(diagram.getNet()).stream().collect(Collectors.groupingBy(c -> c.getFrom()));
centerConnMap.entrySet().stream().sorted(Comparator.comparing(e -> e.getKey().getName(), comparator)).forEach(c -> {
boolean exists = c.getValue().stream().allMatch(ConnectionState::exists);
buffer.appendText("-", exists ? okStyle : errorStyle);
buffer.appendText(String.format(" %s\n", nodeWithRegionToString(c.getKey())), null);
c.getValue().stream().filter(cx -> !cx.exists()).forEach(cx -> {
buffer.appendText(String.format(" %s → %s\n", cx.getFrom().getName(), nodeWithRegionToString(cx.getTo())), null);
});
});
buffer.appendText(ResourceLoader.getString("freight.check.node.connections") + ":\n", boldUnderlineStyle);
checker.analyseNodeConnections(diagram.getNet(), notFreightTypes).stream().filter(c -> !c.exists()).sorted(compareConnections()).forEach(c -> {
buffer.appendText("-", errorStyle);
buffer.appendText(String.format(" %s → %s\n", c.getFrom().getName(), c.getTo().getName()), null);
});
}
Aggregations