Search in sources :

Example 1 with SpeedUnit

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();
}
Also used : SpeedUnit(net.parostroj.timetable.model.units.SpeedUnit) BigDecimal(java.math.BigDecimal)

Example 2 with SpeedUnit

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;
}
Also used : SpeedUnit(net.parostroj.timetable.model.units.SpeedUnit) IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection) File(java.io.File) LengthUnit(net.parostroj.timetable.model.units.LengthUnit)

Aggregations

SpeedUnit (net.parostroj.timetable.model.units.SpeedUnit)2 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 IniConfigSection (net.parostroj.timetable.gui.ini.IniConfigSection)1 LengthUnit (net.parostroj.timetable.model.units.LengthUnit)1