Search in sources :

Example 1 with FNConnection

use of net.parostroj.timetable.model.FNConnection 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 FNConnection

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

the class FreightNetPane2 method updateInfo.

private void updateInfo() {
    StringBuilder builder = new StringBuilder();
    FNConnection conn = selector.getSelectedConnection();
    TimeInterval from = conn != null ? conn.getFrom() : connection.first;
    TimeInterval to = conn != null ? conn.getTo() : connection.second;
    if (from != null) {
        builder.append(from.getOwnerAsNode().getAbbr()).append(": ");
        builder.append(getIntervalInfo(from, true));
    }
    if (to != null) {
        builder.append(" -> ").append(getIntervalInfo(to, false));
    }
    infoTextField.setText(builder.toString());
}
Also used : TimeInterval(net.parostroj.timetable.model.TimeInterval) FNConnection(net.parostroj.timetable.model.FNConnection)

Example 3 with FNConnection

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

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

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

the class BaseConnectionStrategy method getFreightToNodesImpl.

private List<FreightConnectionPath> getFreightToNodesImpl(TimeInterval fromInterval, FreightConnectionFilter filter) {
    List<FreightConnectionPath> result = new LinkedList<>();
    this.getFreightToNodesImpl(fromInterval.getOwnerAsNode(), fromInterval, Collections.<TrainConnection>emptyList(), result, new HashSet<FNConnection>(), filter, new FilterContext(fromInterval));
    return result;
}
Also used : LinkedList(java.util.LinkedList) FNConnection(net.parostroj.timetable.model.FNConnection) FilterContext(net.parostroj.timetable.model.FreightConnectionFilter.FilterContext)

Aggregations

FNConnection (net.parostroj.timetable.model.FNConnection)8 LinkedList (java.util.LinkedList)4 FreightNet (net.parostroj.timetable.model.FreightNet)4 Train (net.parostroj.timetable.model.Train)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TimeInterval (net.parostroj.timetable.model.TimeInterval)3 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 FilterContext (net.parostroj.timetable.model.FreightConnectionFilter.FilterContext)2 Iterators (com.google.common.collect.Iterators)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 FreightConnectionFilter (net.parostroj.timetable.model.FreightConnectionFilter)1 FilterResult (net.parostroj.timetable.model.FreightConnectionFilter.FilterResult)1 Node (net.parostroj.timetable.model.Node)1 TimeIntervalList (net.parostroj.timetable.model.TimeIntervalList)1