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