Search in sources :

Example 1 with TrainsCycleType

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

the class TrainCycleTypeRemoveValidator method validate.

@Override
public boolean validate(Event event) {
    if (event.getSource() instanceof TrainDiagram && event.getType() == Type.REMOVED && event.getObject() instanceof TrainsCycleType) {
        // remove all cycles ...
        TrainsCycleType cycleType = (TrainsCycleType) event.getObject();
        List<TrainsCycle> copy = ImmutableList.copyOf(cycleType.getCycles());
        for (TrainsCycle cycle : copy) {
            cycleType.getCycles().remove(cycle);
        }
        return true;
    }
    return false;
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 2 with TrainsCycleType

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

the class LSTrainsCycleType method createTrainsCycleType.

public TrainsCycleType createTrainsCycleType(TrainDiagram diagram) throws LSException {
    TrainsCycleType type = new TrainsCycleType(id, diagram);
    type.setKey(key);
    if (name != null) {
        type.setKey(name);
        type.setName(LocalizedString.fromString(name));
    }
    type.getAttributes().add(attributes.createAttributes(diagram::getObjectById));
    return type;
}
Also used : TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 3 with TrainsCycleType

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

the class StationTimetablesExtractor method addOtherData.

private void addOtherData(TimeInterval interval, StationTimetableRow row) {
    // technological time handle differently
    row.setTechnologicalTime(interval.isTechnological());
    if (row.isTechnologicalTime()) {
        return;
    }
    row.setLength(this.getLength(interval));
    BiFunction<TrainsCycle, TrainsCycleItem, TrainsCycleItem> nextF = getNextFunction();
    BiFunction<TrainsCycle, TrainsCycleItem, TrainsCycleItem> previousF = getPreviousFunction();
    this.addEnginesAndTrainUnits(interval, diagram.getEngineCycleType(), row.getEngine(), nextF, previousF);
    this.addEnginesAndTrainUnits(interval, diagram.getTrainUnitCycleType(), row.getTrainUnit(), nextF, previousF);
    for (TrainsCycleType type : diagram.getCycleTypes()) {
        if (!type.isDefaultType()) {
            this.addCycles(interval, type, row.getCycle(), nextF, previousF);
        }
    }
    if (interval.isFreight()) {
        List<? extends FreightConnection> freightDests = strategy.getFreightToNodes(interval);
        if (!freightDests.isEmpty()) {
            ArrayList<FreightDestinationInfo> fl = new ArrayList<>(freightDests.size());
            for (FreightConnection dst : freightDests) {
                fl.add(FreightDestinationInfo.convert(locale, dst));
            }
            row.setFreightTo(fl);
        }
    }
    if (interval.isFreightConnection()) {
        Map<Train, List<FreightConnectionPath>> passedCargoDst = strategy.getFreightPassedInNode(interval);
        if (!passedCargoDst.isEmpty()) {
            List<FreightToTrain> fttl = new ArrayList<>();
            for (Map.Entry<Train, List<FreightConnectionPath>> entry : passedCargoDst.entrySet()) {
                FreightToTrain ftt = new FreightToTrain();
                ftt.setTrain(entry.getKey().getName());
                List<? extends FreightConnection> mList = entry.getValue();
                List<FreightDestinationInfo> fl = new ArrayList<>(mList.size());
                for (FreightConnection dst : mList) {
                    fl.add(FreightDestinationInfo.convert(locale, dst));
                }
                ftt.setFreightTo(fl);
                fttl.add(ftt);
            }
            row.setFreightToTrain(fttl);
        }
    }
    List<FNConnection> trainsFrom = diagram.getFreightNet().getTrainsTo(interval);
    if (!trainsFrom.isEmpty()) {
        ArrayList<TranslatedString> nt = new ArrayList<>(trainsFrom.size());
        for (FNConnection conn : trainsFrom) {
            nt.add(conn.getFrom().getTrain().getName());
        }
        row.setFreightFromTrain(nt);
    }
    row.setComment(interval.getComment());
    row.setOccupied(interval.getAttributes().getBool(TimeInterval.ATTR_OCCUPIED));
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) TranslatedString(net.parostroj.timetable.model.TranslatedString) ArrayList(java.util.ArrayList) TrainsCycleItem(net.parostroj.timetable.model.TrainsCycleItem) FreightConnection(net.parostroj.timetable.model.freight.FreightConnection) ArrayList(java.util.ArrayList) TimeIntervalList(net.parostroj.timetable.model.TimeIntervalList) LinkedList(java.util.LinkedList) List(java.util.List) Train(net.parostroj.timetable.model.Train) Map(java.util.Map) FNConnection(net.parostroj.timetable.model.FNConnection) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 4 with TrainsCycleType

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

the class PositionsExtractor method getPositionsCustom.

private List<Cycles> getPositionsCustom(BiFunction<Collection<TrainsCycle>, Integer, List<Position>> function, Integer startingTime) {
    List<Cycles> cyclesList = new ArrayList<>();
    for (TrainsCycleType type : diagram.getCycleTypes()) {
        if (!type.isDefaultType()) {
            Cycles cycles = new Cycles();
            cycles.setName(type.getName());
            cycles.setPositions(function.apply(type.getCycles(), startingTime));
            cyclesList.add(cycles);
        }
    }
    return cyclesList;
}
Also used : ArrayList(java.util.ArrayList) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 5 with TrainsCycleType

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

the class CirculationSequenceDialog method fillFree.

private void fillFree() {
    elementSelectionPanel.clear();
    TrainsCycleType type = circulation.getType();
    // left - not selected part
    for (TrainsCycle cc : type.getCycles()) {
        if (cc != circulation && !cc.isPartOfSequence()) {
            elementSelectionPanel.getNotSelected().addWrapper(Wrapper.getWrapper(cc));
        }
    }
    // right - selected
    List<Wrapper<TrainsCycle>> selCirc = new ArrayList<Wrapper<TrainsCycle>>();
    circulation.applyToSequence(tc -> selCirc.add(Wrapper.getWrapper(tc)));
    elementSelectionPanel.getSelected().setListOfWrappers(selCirc);
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) ArrayList(java.util.ArrayList) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Aggregations

TrainsCycleType (net.parostroj.timetable.model.TrainsCycleType)7 ArrayList (java.util.ArrayList)3 TrainsCycle (net.parostroj.timetable.model.TrainsCycle)3 OutputParam (net.parostroj.timetable.output2.OutputParam)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Wrapper (net.parostroj.timetable.gui.wrappers.Wrapper)1 FNConnection (net.parostroj.timetable.model.FNConnection)1 TimeIntervalList (net.parostroj.timetable.model.TimeIntervalList)1 Train (net.parostroj.timetable.model.Train)1 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)1 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)1 TranslatedString (net.parostroj.timetable.model.TranslatedString)1 FreightConnection (net.parostroj.timetable.model.freight.FreightConnection)1 OutputException (net.parostroj.timetable.output2.OutputException)1