use of net.parostroj.timetable.model.units.SpeedUnit in project grafikon by jub77.
the class NetItemConversionUtil method getLineSpeedString.
public String getLineSpeedString(Line line, SpeedUnit defaultSpeedUnit) {
SpeedUnit speedUnit = line.getDiagram().getAttributes().get(TrainDiagram.ATTR_EDIT_SPEED_UNIT, SpeedUnit.class, defaultSpeedUnit);
BigDecimal sValue = speedUnit.convertFrom(new BigDecimal(line.getTopSpeed()), SpeedUnit.KMPH);
return UnitUtil.convertToString("#0", sValue) + speedUnit.getUnitsOfString();
}
use of net.parostroj.timetable.model.units.SpeedUnit in project grafikon by jub77.
the class ApplicationModel method loadFromPreferences.
@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
guiContext.loadFromPreferences(prefs);
IniConfigSection section = prefs.getSection("model");
deserializeOutputTemplates(section.get("output.templates", ""));
programSettings.setUserName(section.get("user.name"));
LengthUnit lengthUnit = LengthUnit.getByKey(section.get("unit", "mm"));
SpeedUnit speedUnit = SpeedUnit.getByKey(section.get("unit.speed", "kmph"));
programSettings.setLengthUnit(lengthUnit != null ? lengthUnit : LengthUnit.MM);
programSettings.setSpeedUnit(speedUnit != null ? speedUnit : SpeedUnit.KMPH);
List<String> filenames = section.getAll("last.opened");
if (filenames != null) {
Collections.reverse(filenames);
for (String filename : filenames) {
if (filename != null) {
this.addLastOpenedFile(new File(filename));
}
}
}
return section;
}
Aggregations