use of net.parostroj.timetable.model.ls.ModelVersion in project grafikon by jub77.
the class LoadFilter4d19 method checkDiagram.
@Override
public void checkDiagram(TrainDiagram diagram, ModelVersion version) {
if (version.compareTo(new ModelVersion(4, 19, 0)) <= 0) {
// not passing cargo in center (move to time interval from train)
for (Train train : diagram.getTrains()) {
if (train.getAttributeAsBool("no.transitive.region.start")) {
for (TimeInterval interval : train.getNodeIntervals()) {
if (interval.isFirst())
continue;
if (interval.getOwnerAsNode().isCenterOfRegions()) {
interval.setAttributeAsBool(TimeInterval.ATTR_NO_REGION_CENTER_TRANSFER, true);
}
}
}
}
}
if (version.compareTo(new ModelVersion(4, 19, 2)) <= 0) {
// convert some texts to localized strings
this.convertToLocalizedStrings(diagram);
// filter out output templates with default.template
removeDefaultTemplatesExceptDrawAndXml(diagram);
}
}
use of net.parostroj.timetable.model.ls.ModelVersion 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.ls.ModelVersion in project grafikon by jub77.
the class LoadFilter4d2 method checkDiagram.
@Override
public void checkDiagram(TrainDiagram diagram, ModelVersion version) {
if (version.compareTo(new ModelVersion(4, 2)) <= 0) {
// fix weight info
for (Train train : diagram.getTrains()) {
Integer weight = TrainsHelper.getWeightFromInfoAttribute(train);
if (weight != null) {
train.setAttribute(Train.ATTR_WEIGHT, weight);
}
// remove weight.info attribute
train.removeAttribute("weight.info");
}
// fix route info
for (Train train : diagram.getTrains()) {
String routeInfo = ObjectsUtil.checkAndTrim(train.getAttribute("route.info", String.class));
if (routeInfo != null) {
try {
train.setAttribute(Train.ATTR_ROUTE, this.convert(routeInfo));
} catch (GrafikonException e) {
log.warn("Couldn't convert route info to template: {}", e.getMessage());
}
train.removeAttribute("route.info");
}
}
}
}
Aggregations