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;
}
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;
}
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));
}
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;
}
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);
}
Aggregations