use of net.parostroj.timetable.model.freight.NodeFreight in project grafikon by jub77.
the class FreightDestinationPanel method addFreightToNodes.
private void addFreightToNodes(DataModel model, NodeFreight nodeFreight) {
Locale locale = Locale.getDefault();
Collator collator = Collator.getInstance();
List<Tuple<String>> lines = nodeFreight.getNodeConnections().stream().filter(e -> e.getTo().isVisible()).map(e -> {
String node = util.freightNodeToString(e.getTo(), locale, false);
String trains = util.intervalsToString(diagram, e.getTransport().getTrains(), locale).stream().collect(Collectors.joining(", "));
return new Tuple<>(node, trains);
}).sorted(comparator(collator)).collect(Collectors.toList());
model.addLinesWithEmpty(lines);
}
use of net.parostroj.timetable.model.freight.NodeFreight in project grafikon by jub77.
the class FreightDestinationPanel method addFreightToColors.
private void addFreightToColors(DataModel model, NodeFreight nodeFreight) {
Locale locale = Locale.getDefault();
List<Tuple<String>> lines = nodeFreight.getFreightColorConnections().stream().map(e -> {
String color = util.freightColorsToString(e.getTo(), locale).stream().collect(Collectors.joining(", "));
String transport = util.transportToString(diagram, e.getTransport(), locale).stream().collect(Collectors.joining(", "));
return new Tuple<>(color, transport);
}).collect(Collectors.toList());
model.addLinesWithEmpty(lines);
}
use of net.parostroj.timetable.model.freight.NodeFreight in project grafikon by jub77.
the class FreightDestinationPanel method updateView.
public void updateView(Node node) {
// update selection
if (nodesModel.getSelectedObject() != node) {
nodesModel.setSelectedObject(node);
}
tableModel.clear();
if (node != null) {
DataModel model = new DataModel();
RxActionHandler.createInstance().newExecution("freight_dest", GuiComponentUtils.getTopLevelComponent(this), diagram).addConsumer((c, diagram) -> {
c.setWaitMessage(ResourceLoader.getString("wait.message.processing"));
c.setWaitDialogVisible(true);
}).onBackground().addConsumer((c, diagram) -> {
FreightAnalyser analyser = new FreightAnalyser(diagram.getFreightNet().getConnectionStrategy());
NodeFreight freight = analyser.getNodeFreightFrom(node);
addFreightToNodes(model, freight);
addFreightToRegions(model, freight);
addFreightToColors(model, freight);
addFreightTrainsFromNode(model, node, analyser);
addFreightTrainUnitsFromNode(model, node, analyser);
}).addConsumer((c, diagram) -> {
tableModel.addLines(model);
adjustColumnWidth.run();
}).execute();
}
}
Aggregations