use of net.parostroj.timetable.model.TrainType in project grafikon by jub77.
the class LSTrainType method createTrainType.
public TrainType createTrainType(PartFactory partFactory, Function<String, ObjectWithId> mapping, Function<String, TrainTypeCategory> categoryMapping) throws LSException {
TrainType type = partFactory.createTrainType(id);
if (abbr != null) {
type.setAbbr(LocalizedString.fromString(abbr));
}
type.setColor(Conversions.convertTextToColor(color));
if (desc != null) {
type.setDesc(LocalizedString.fromString(desc));
}
type.setPlatform(platform);
type.setTrainCompleteNameTemplate(trainCompleteNameTemplate != null ? trainCompleteNameTemplate.createTextTemplate() : null);
type.setTrainNameTemplate(trainNameTemplate != null ? trainNameTemplate.createTextTemplate() : null);
type.setCategory(categoryMapping.apply(categoryId));
if (attributes != null) {
type.getAttributes().add(attributes.createAttributes(mapping));
}
return type;
}
use of net.parostroj.timetable.model.TrainType in project grafikon by jub77.
the class LoadFilter4d21 method checkDiagram.
@Override
public void checkDiagram(TrainDiagram diagram, ModelVersion version) {
if (version.compareTo(new ModelVersion(4, 21, 0)) <= 0) {
// convert route unit...
Attributes attributes = diagram.getAttributes();
if (attributes.containsKey(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT)) {
// try to convert to length unit
String lUnitStr = attributes.get(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT, String.class);
LengthUnit lUnit = LengthUnit.getByKey(lUnitStr);
attributes.setRemove(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT, lUnit);
}
}
if (version.compareTo(new ModelVersion(4, 21, 1)) <= 0) {
// convert train name templates (common)
diagram.getTrainsData().setTrainNameTemplate(convertForAbbreviation(diagram.getTrainsData().getTrainNameTemplate()));
diagram.getTrainsData().setTrainCompleteNameTemplate(convertForAbbreviation(diagram.getTrainsData().getTrainCompleteNameTemplate()));
// in train types
for (TrainType type : diagram.getTrainTypes()) {
type.setTrainNameTemplate(convertForAbbreviation(type.getTrainNameTemplate()));
type.setTrainCompleteNameTemplate(convertForAbbreviation(type.getTrainCompleteNameTemplate()));
}
}
}
use of net.parostroj.timetable.model.TrainType 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;
}
Aggregations