Search in sources :

Example 1 with FreightNet

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));
    }
}
Also used : TimeInterval(net.parostroj.timetable.model.TimeInterval) Train(net.parostroj.timetable.model.Train) FNConnection(net.parostroj.timetable.model.FNConnection) FreightNet(net.parostroj.timetable.model.FreightNet)

Example 2 with FreightNet

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));
}
Also used : FNConnection(net.parostroj.timetable.model.FNConnection) FreightNet(net.parostroj.timetable.model.FreightNet)

Example 3 with FreightNet

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();
}
Also used : FNConnection(net.parostroj.timetable.model.FNConnection) FreightNet(net.parostroj.timetable.model.FreightNet)

Aggregations

FNConnection (net.parostroj.timetable.model.FNConnection)3 FreightNet (net.parostroj.timetable.model.FreightNet)3 TimeInterval (net.parostroj.timetable.model.TimeInterval)1 Train (net.parostroj.timetable.model.Train)1