Package slash.navigation.common

Examples of slash.navigation.common.UnitSystem


*/

public class UnitSystemListCellRenderer extends DefaultListCellRenderer {
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        UnitSystem unitSystem = UnitSystem.class.cast(value);
        String text = RouteConverter.getBundle().getString("unitsystem-" + unitSystem.name().toLowerCase());
        label.setText(text);
        return label;
    }
View Full Code Here


    private static String currentTimeZone = "";

    public static String formatDistance(Double distance) {
        if (distance == null || distance <= 0.0)
            return "";
        UnitSystem unitSystem = RouteConverter.getInstance().getUnitSystemModel().getUnitSystem();
        double distanceInMeters = unitSystem.valueToUnit(distance);
        if (abs(distanceInMeters) < maximumDistanceDisplayedInMeters)
            return format("%d %s", round(distanceInMeters), unitSystem.getElevationName());
        double distanceInKiloMeters = unitSystem.distanceToUnit(distance / 1000.0);
        if (abs(distanceInMeters) < maximumDistanceDisplayedInHundredMeters)
            return format("%s %s", roundFraction(distanceInKiloMeters, 1), unitSystem.getDistanceName());
        return format("%d %s", round(distanceInKiloMeters), unitSystem.getDistanceName());
    }
View Full Code Here

    }

    public static String formatElevation(Double elevation) {
        if (elevation == null)
            return "";
        UnitSystem unitSystem = RouteConverter.getInstance().getUnitSystemModel().getUnitSystem();
        double distanceInUnit = unitSystem.valueToUnit(elevation);
        return format("%d %s", round(distanceInUnit), unitSystem.getElevationName());
    }
View Full Code Here

    }

    private static String formatSpeed(Double speed) {
        if (speed == null)
            return "";
        UnitSystem unitSystem = RouteConverter.getInstance().getUnitSystemModel().getUnitSystem();
        Double speedInUnit = unitSystem.distanceToUnit(speed);
        if (abs(speedInUnit) < 10.0)
             return format("%s %s", roundFraction(speedInUnit, 1), unitSystem.getSpeedName());
        else
            return format("%d %s", round(speedInUnit), unitSystem.getSpeedName());
    }
View Full Code Here

        comboBoxUnitSystem.setRenderer(new UnitSystemListCellRenderer());
        comboBoxUnitSystem.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                UnitSystem unitSystem = UnitSystem.class.cast(e.getItem());
                r.getUnitSystemModel().setUnitSystem(unitSystem);
            }
        });

        ComboBoxModel<DegreeFormat> degreeFormatModel = new DefaultComboBoxModel<>(new DegreeFormat[]{
View Full Code Here

            stringValue = stringValue.replaceAll(replaceAll, "");
        return parseDouble(stringValue);
    }

    private Double parseElevation(Object objectValue, String stringValue) {
        UnitSystem unitSystem = RouteConverter.getInstance().getUnitSystemModel().getUnitSystem();
        Double value = parseDegrees(objectValue, stringValue, unitSystem.getElevationName());
        return unitSystem.valueToDefault(value);
    }
View Full Code Here

        Double value = parseDegrees(objectValue, stringValue, unitSystem.getElevationName());
        return unitSystem.valueToDefault(value);
    }

    private Double parseSpeed(Object objectValue, String stringValue) {
        UnitSystem unitSystem = RouteConverter.getInstance().getUnitSystemModel().getUnitSystem();
        Double value = parseDegrees(objectValue, stringValue, unitSystem.getSpeedName());
        return unitSystem.distanceToDefault(value);
    }
View Full Code Here

        profileModel.setProfileMode(profileMode);
        updateAxis();
    }

    private void updateAxis() {
        UnitSystem unitSystem = profileModel.getUnitSystem();
        ProfileMode profileMode = profileModel.getProfileMode();

        plot.getDomainAxis().setLabel(format(getBundle().getString("distance-axis"), unitSystem.getDistanceName()));
        String yAxisUnit = profileMode.equals(Elevation) ? unitSystem.getElevationName() : unitSystem.getSpeedName();
        String yAxisKey = profileMode.equals(Elevation) ? "elevation-axis" : "speed-axis";
        plot.getRangeAxis().setLabel(format(getBundle().getString(yAxisKey), yAxisUnit));

        chartPanel.setToolTipGenerator(new StandardXYToolTipGenerator(
                "{2} " + yAxisUnit + " @ {1} " + unitSystem.getDistanceName(),
                getIntegerInstance(), getIntegerInstance()));
    }
View Full Code Here

TOP

Related Classes of slash.navigation.common.UnitSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.