Search in sources :

Example 1 with Train

use of net.parostroj.timetable.model.Train in project grafikon by jub77.

the class PreviousNextTrainValidator method checkAndUpdateTimeAfter.

private void checkAndUpdateTimeAfter(Train currentTrain) {
    Train nextTrain = currentTrain.getNextJoinedTrain();
    if (nextTrain != null) {
        int startTime = currentTrain.getEndTime();
        int endTime = nextTrain.getStartTime();
        int length = TimeUtil.difference(startTime, endTime);
        if (length != currentTrain.getTimeAfter()) {
            currentTrain.setTimeAfter(length);
        }
        if (nextTrain.getTimeBefore() != 0) {
            nextTrain.setTimeBefore(0);
        }
    }
}
Also used : Train(net.parostroj.timetable.model.Train)

Example 2 with Train

use of net.parostroj.timetable.model.Train 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 3 with Train

use of net.parostroj.timetable.model.Train in project grafikon by jub77.

the class TrainDiagramBuilder method setTrain.

public void setTrain(LSTrain lsTrain) throws LSException {
    DelayedAttributes<Train> delayedAttributes = lsTrain.createTrain(diagram);
    delayedAttributesList.add(delayedAttributes);
    Train train = delayedAttributes.getObject();
    Train foundTrain = null;
    if ((foundTrain = diagram.getTrains().getById(train.getId())) != null) {
        diagram.getTrains().remove(foundTrain);
    }
    diagram.getTrains().add(train);
}
Also used : Train(net.parostroj.timetable.model.Train)

Example 4 with Train

use of net.parostroj.timetable.model.Train in project grafikon by jub77.

the class LSTrain method createTrain.

public Train createTrain(TrainDiagram diagram) {
    Train train = diagram.getPartFactory().createTrain(id);
    train.setNumber(number);
    train.getAttributes().add(attributes.createAttributes());
    train.setDescription(desc);
    train.setTopSpeed(topSpeed);
    train.setType(diagram.getTrainTypes().getById(type));
    // build time interval list
    TrainIntervalsBuilder builder = new TrainIntervalsBuilder(train, start);
    for (Object routePart : getRoute()) {
        if (routePart instanceof LSTrainRoutePartNode) {
            LSTrainRoutePartNode nodePart = (LSTrainRoutePartNode) routePart;
            Node node = diagram.getNet().getNodeById(nodePart.getNodeId());
            NodeTrack nodeTrack = node.getTrackById(nodePart.getTrackId());
            builder.addNode(nodePart.getIntervalId(), node, nodeTrack, nodePart.getStop(), nodePart.getAttributes().createAttributes());
        } else {
            LSTrainRoutePartLine linePart = (LSTrainRoutePartLine) routePart;
            Line line = diagram.getNet().getLineById(linePart.getLineId());
            LineTrack lineTrack = line.getTrackById(linePart.getTrackId());
            builder.addLine(linePart.getIntervalId(), line, lineTrack, linePart.getSpeed(), 0, linePart.getAttributes().createAttributes());
        }
    }
    builder.finish();
    // set technological time
    train.setTimeBefore(this.timeBefore);
    train.setTimeAfter(this.timeAfter);
    return train;
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack) Line(net.parostroj.timetable.model.Line) TrainIntervalsBuilder(net.parostroj.timetable.actions.TrainIntervalsBuilder) Node(net.parostroj.timetable.model.Node) Train(net.parostroj.timetable.model.Train) LineTrack(net.parostroj.timetable.model.LineTrack)

Example 5 with Train

use of net.parostroj.timetable.model.Train in project grafikon by jub77.

the class LSTrainsCycleItem method createTrainsCycleItem.

public TrainsCycleItem createTrainsCycleItem(TrainsCycle cycle, TrainDiagram diagram) {
    Train modelTrain = diagram.getTrains().getById(train);
    TrainsCycleItem item = new TrainsCycleItem(cycle, modelTrain, LocalizedString.fromString(comment), modelTrain.getIntervalById(from), modelTrain.getIntervalById(to));
    return item;
}
Also used : TrainsCycleItem(net.parostroj.timetable.model.TrainsCycleItem) Train(net.parostroj.timetable.model.Train)

Aggregations

Train (net.parostroj.timetable.model.Train)31 TimeInterval (net.parostroj.timetable.model.TimeInterval)8 LinkedList (java.util.LinkedList)5 Node (net.parostroj.timetable.model.Node)5 TrainsCycle (net.parostroj.timetable.model.TrainsCycle)5 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)5 List (java.util.List)4 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 FNConnection (net.parostroj.timetable.model.FNConnection)3 TranslatedString (net.parostroj.timetable.model.TranslatedString)3 Component (java.awt.Component)2 Rectangle (java.awt.Rectangle)2 Shape (java.awt.Shape)2 JOptionPane (javax.swing.JOptionPane)2 TrainIntervalsBuilder (net.parostroj.timetable.actions.TrainIntervalsBuilder)2 GuiComponentUtils (net.parostroj.timetable.gui.utils.GuiComponentUtils)2 Group (net.parostroj.timetable.model.Group)2 Route (net.parostroj.timetable.model.Route)2