Search in sources :

Example 1 with NodeTrack

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

the class NodeTimetableByTracksWriter method writeNodeTimetable.

/**
 * writes node timetable.
 *
 * @param node node
 * @param str appendable
 */
public void writeNodeTimetable(Node node, Appendable str) throws IOException {
    TimeConverter c = node.getDiagram().getTimeConverter();
    str.append("Node: ");
    str.append(node.getName()).append('\n');
    List<NodeTrack> tracks = node.getTracks();
    for (NodeTrack track : tracks) {
        str.append("Track: " + track.getNumber()).append('\n');
        for (TimeInterval interval : track.getTimeIntervalList()) {
            try (Formatter f = new Formatter(str)) {
                f.format("%1$-20s", interval.getTrain().getDefaultCompleteName());
                str.append(c.convertIntToText(interval.getStart(), true));
                str.append(" ").append(c.convertIntToText(interval.getEnd(), true)).append("\n");
                f.flush();
            }
        }
    }
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack) TimeInterval(net.parostroj.timetable.model.TimeInterval) Formatter(java.util.Formatter) TimeConverter(net.parostroj.timetable.model.TimeConverter)

Example 2 with NodeTrack

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

the class LSNodeTrack method createNodeTrack.

public NodeTrack createNodeTrack(Function<String, ObjectWithId> mapping) throws LSException {
    NodeTrack nodeTrack = new NodeTrack(this.getId());
    this.addValuesTrack(mapping, nodeTrack);
    nodeTrack.setPlatform(platform);
    return nodeTrack;
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack)

Example 3 with NodeTrack

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

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

the class LibraryBuilder method importNode.

public LibraryItem importNode(Node node) {
    Node nodeCopy = copyFactory.copy(node, node.getId());
    addHandler.stripObjectIdAttributes(nodeCopy);
    for (NodeTrack track : nodeCopy.getTracks()) {
        addHandler.stripObjectIdAttributes(track);
    }
    // create item and add it to library
    return addImpl(nodeCopy, LibraryItemType.NODE);
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack) Node(net.parostroj.timetable.model.Node)

Example 5 with NodeTrack

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

the class LSNodeTrack method createNodeTrack.

public NodeTrack createNodeTrack() {
    NodeTrack nodeTrack = new NodeTrack(this.getId());
    this.addValuesTrack(nodeTrack);
    nodeTrack.setPlatform(platform);
    return nodeTrack;
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack)

Aggregations

NodeTrack (net.parostroj.timetable.model.NodeTrack)9 Node (net.parostroj.timetable.model.Node)5 LineTrack (net.parostroj.timetable.model.LineTrack)4 Line (net.parostroj.timetable.model.Line)3 TrainIntervalsBuilder (net.parostroj.timetable.actions.TrainIntervalsBuilder)2 TimeInterval (net.parostroj.timetable.model.TimeInterval)2 Train (net.parostroj.timetable.model.Train)2 ParseException (java.text.ParseException)1 Formatter (java.util.Formatter)1 LocalizedString (net.parostroj.timetable.model.LocalizedString)1 Net (net.parostroj.timetable.model.Net)1 TimeConverter (net.parostroj.timetable.model.TimeConverter)1 Track (net.parostroj.timetable.model.Track)1