Search in sources :

Example 36 with Node

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

the class LSTrain method createTrain.

public DelayedAttributes<Train> createTrain(TrainDiagram diagram) throws LSException {
    Train train = diagram.getPartFactory().createTrain(id);
    train.setNumber(number);
    train.setDescription(desc);
    train.setTopSpeed(topSpeed);
    train.setType(diagram.getTrainTypes().getById(type));
    // build time interval list
    TrainIntervalsBuilder builder = new TrainIntervalsBuilder(train, start);
    if (this.route != null) {
        for (Object routePart : this.route) {
            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(diagram::getObjectById));
            } 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(), linePart.getAddedTime() != null ? linePart.getAddedTime() : 0, linePart.getAttributes().createAttributes(diagram::getObjectById));
            }
        }
    }
    builder.finish();
    // set technological time
    train.setTimeBefore(this.timeBefore);
    train.setTimeAfter(this.timeAfter);
    return new DelayedAttributes<>(train, attributes, diagram::getObjectById);
}
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 37 with Node

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

the class StationTimetablesExtractor method getLength.

private LengthInfo getLength(TimeInterval interval) {
    LengthInfo lengthInfo = null;
    Train train = interval.getTrain();
    TrainType trainType = train.getType();
    if (!interval.isLast() && interval.isStop() && trainType != null && trainType.getAttributes().getBool(TrainType.ATTR_SHOW_WEIGHT_INFO)) {
        Pair<Node, Integer> length = getNextLength(interval.getOwnerAsNode(), train, NextType.LAST_STATION);
        // if length was calculated
        if (length != null && length.second != null) {
            // update length with station lengths
            lengthInfo = new LengthInfo();
            lengthInfo.setLength(length.second);
            LengthUnit lengthUnitObj = diagram.getAttribute(TrainDiagram.ATTR_LENGTH_UNIT, LengthUnit.class);
            lengthInfo.setLengthInAxles(LengthUnit.AXLE == lengthUnitObj);
            lengthInfo.setLengthUnit(lengthUnitObj);
            lengthInfo.setStationAbbr(length.first.getAbbr());
        }
    }
    return lengthInfo;
}
Also used : Node(net.parostroj.timetable.model.Node) TrainType(net.parostroj.timetable.model.TrainType) Train(net.parostroj.timetable.model.Train) LengthUnit(net.parostroj.timetable.model.units.LengthUnit)

Example 38 with Node

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

the class StationTimetablesExtractor method getStationTimetables.

public List<StationTimetable> getStationTimetables() {
    List<StationTimetable> result = new LinkedList<>();
    for (Node node : nodes) {
        StationTimetable timetable = new StationTimetable(node.getName());
        timetable.setType(node.getType());
        // regions + company
        Set<Region> regions = node.getRegions();
        if (!regions.isEmpty()) {
            timetable.setRegions(regions.stream().map(RegionInfo::convert).collect(Collectors.toList()));
        }
        Company company = node.getAttribute(Node.ATTR_COMPANY, Company.class);
        if (company != null) {
            timetable.setCompany(CompanyInfo.convert(company));
        }
        // process rows ...
        for (TimeInterval interval : this.collectIntervals(node)) {
            if (techTime || !interval.isTechnological()) {
                timetable.getRows().add(this.createRow(interval));
            }
        }
        result.add(timetable);
    }
    return result;
}
Also used : Company(net.parostroj.timetable.model.Company) TimeInterval(net.parostroj.timetable.model.TimeInterval) Node(net.parostroj.timetable.model.Node) Region(net.parostroj.timetable.model.Region) LinkedList(java.util.LinkedList)

Example 39 with Node

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

the class FreightDestinationInfo method convert.

public static FreightDestinationInfo convert(Locale locale, FreightConnection dst) {
    FreightDestinationInfo info = new FreightDestinationInfo();
    if (dst.getTo().isNode()) {
        Node to = dst.getTo().getNode();
        info.setName(to.getName());
        info.setAbbr(to.getAbbr());
        List<FreightColor> sortedColors = OutputFreightUtil.sortFreightColors(dst.getTo().getFreightColors());
        info.setColors(sortedColors == null || sortedColors.isEmpty() ? null : sortedColors);
        if (!dst.getTo().isVisible()) {
            info.setHidden(true);
        }
    }
    if (dst.getTo().isRegions()) {
        Set<Region> regions = dst.getTo().getRegions();
        info.setRegions(new OutputFreightUtil().regionsToString(regions, locale));
    }
    return info;
}
Also used : Node(net.parostroj.timetable.model.Node) Region(net.parostroj.timetable.model.Region) OutputFreightUtil(net.parostroj.timetable.output2.util.OutputFreightUtil) FreightColor(net.parostroj.timetable.model.FreightColor)

Aggregations

Node (net.parostroj.timetable.model.Node)39 List (java.util.List)10 ArrayList (java.util.ArrayList)9 TimeInterval (net.parostroj.timetable.model.TimeInterval)9 BorderLayout (java.awt.BorderLayout)8 Collection (java.util.Collection)8 Region (net.parostroj.timetable.model.Region)8 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)8 FlowLayout (java.awt.FlowLayout)7 Comparator (java.util.Comparator)7 Set (java.util.Set)7 BorderFactory (javax.swing.BorderFactory)7 JButton (javax.swing.JButton)7 JPanel (javax.swing.JPanel)7 JScrollPane (javax.swing.JScrollPane)7 RxActionHandler (net.parostroj.timetable.gui.actions.execution.RxActionHandler)7 GuiComponentUtils (net.parostroj.timetable.gui.utils.GuiComponentUtils)7 GuiIcon (net.parostroj.timetable.gui.utils.GuiIcon)7 ResourceLoader (net.parostroj.timetable.gui.utils.ResourceLoader)7 ItemEvent (java.awt.event.ItemEvent)6