use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class TrainDiagramBuilder method setFreightNet.
public void setFreightNet(LSFreightNet lsFreightNet) throws LSException {
FreightNet net = lsFreightNet.createFreightNet(diagram);
this.diagram.setFreightNet(net);
for (LSFreightConnection lsConnection : lsFreightNet.getConnections()) {
Train from = diagram.getTrains().getById(lsConnection.getTrainFrom());
Train to = diagram.getTrains().getById(lsConnection.getTrainTo());
TimeInterval iFrom = from.getIntervalById(lsConnection.getIntervalFrom());
TimeInterval iTo = to.getIntervalById(lsConnection.getIntervalTo());
FNConnection connection = diagram.getFreightNet().addConnection(iFrom, iTo);
connection.merge(lsConnection.getAttributes().createAttributes(diagram::getObjectById));
}
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class FreightNetPane2 method updateInfo.
private void updateInfo() {
StringBuilder builder = new StringBuilder();
FNConnection conn = selector.getSelectedConnection();
TimeInterval from = conn != null ? conn.getFrom() : connection.first;
TimeInterval to = conn != null ? conn.getTo() : connection.second;
if (from != null) {
builder.append(from.getOwnerAsNode().getAbbr()).append(": ");
builder.append(getIntervalInfo(from, true));
}
if (to != null) {
builder.append(" -> ").append(getIntervalInfo(to, false));
}
infoTextField.setText(builder.toString());
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class FreightNetPane2 method moveConnection.
private void moveConnection(int change) {
FNConnection conn = selector.getSelectedConnection();
FreightNet net = model.getDiagram().getFreightNet();
int currentIndex = net.getTrainsFrom(conn.getFrom()).indexOf(conn);
net.moveConnection(conn, currentIndex + change);
graphicalTimetableView.repaint();
upButton.setEnabled(checkEnabledMoveConnection(conn, 1));
downButton.setEnabled(checkEnabledMoveConnection(conn, -1));
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class StationTimetablesExtractor method addOtherData.
private void addOtherData(TimeInterval interval, StationTimetableRow row) {
// technological time handle differently
row.setTechnologicalTime(interval.isTechnological());
if (row.isTechnologicalTime()) {
return;
}
row.setLength(this.getLength(interval));
BiFunction<TrainsCycle, TrainsCycleItem, TrainsCycleItem> nextF = getNextFunction();
BiFunction<TrainsCycle, TrainsCycleItem, TrainsCycleItem> previousF = getPreviousFunction();
this.addEnginesAndTrainUnits(interval, diagram.getEngineCycleType(), row.getEngine(), nextF, previousF);
this.addEnginesAndTrainUnits(interval, diagram.getTrainUnitCycleType(), row.getTrainUnit(), nextF, previousF);
for (TrainsCycleType type : diagram.getCycleTypes()) {
if (!type.isDefaultType()) {
this.addCycles(interval, type, row.getCycle(), nextF, previousF);
}
}
if (interval.isFreight()) {
List<? extends FreightConnection> freightDests = strategy.getFreightToNodes(interval);
if (!freightDests.isEmpty()) {
ArrayList<FreightDestinationInfo> fl = new ArrayList<>(freightDests.size());
for (FreightConnection dst : freightDests) {
fl.add(FreightDestinationInfo.convert(locale, dst));
}
row.setFreightTo(fl);
}
}
if (interval.isFreightConnection()) {
Map<Train, List<FreightConnectionPath>> passedCargoDst = strategy.getFreightPassedInNode(interval);
if (!passedCargoDst.isEmpty()) {
List<FreightToTrain> fttl = new ArrayList<>();
for (Map.Entry<Train, List<FreightConnectionPath>> entry : passedCargoDst.entrySet()) {
FreightToTrain ftt = new FreightToTrain();
ftt.setTrain(entry.getKey().getName());
List<? extends FreightConnection> mList = entry.getValue();
List<FreightDestinationInfo> fl = new ArrayList<>(mList.size());
for (FreightConnection dst : mList) {
fl.add(FreightDestinationInfo.convert(locale, dst));
}
ftt.setFreightTo(fl);
fttl.add(ftt);
}
row.setFreightToTrain(fttl);
}
}
List<FNConnection> trainsFrom = diagram.getFreightNet().getTrainsTo(interval);
if (!trainsFrom.isEmpty()) {
ArrayList<TranslatedString> nt = new ArrayList<>(trainsFrom.size());
for (FNConnection conn : trainsFrom) {
nt.add(conn.getFrom().getTrain().getName());
}
row.setFreightFromTrain(nt);
}
row.setComment(interval.getComment());
row.setOccupied(interval.getAttributes().getBool(TimeInterval.ATTR_OCCUPIED));
}
use of net.parostroj.timetable.model.FNConnection in project grafikon by jub77.
the class BaseConnectionStrategy method getFreightToNodesImpl.
private List<FreightConnectionPath> getFreightToNodesImpl(TimeInterval fromInterval, FreightConnectionFilter filter) {
List<FreightConnectionPath> result = new LinkedList<>();
this.getFreightToNodesImpl(fromInterval.getOwnerAsNode(), fromInterval, Collections.<TrainConnection>emptyList(), result, new HashSet<FNConnection>(), filter, new FilterContext(fromInterval));
return result;
}
Aggregations