use of net.parostroj.timetable.model.FreightNet 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.FreightNet 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.FreightNet 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