Ignore:
Timestamp:
2017-09-23T23:20:03+02:00 (3 years ago)
Author:
bastiK
Message:

see #15229 - move non-essential helper methods from Preferences to PreferencesUtils

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r12846 r12891  
    3333import javax.swing.ImageIcon;
    3434
    35 import org.openstreetmap.josm.Main;
    3635import org.openstreetmap.josm.data.Bounds;
     36import org.openstreetmap.josm.data.PreferencesUtils;
    3737import org.openstreetmap.josm.data.SystemOfMeasurement;
    3838import org.openstreetmap.josm.data.SystemOfMeasurement.SoMChangeListener;
     
    279279    public ColorMode getColorMode(String layerName) {
    280280        try {
    281             int i = Main.pref.getInteger("draw.rawgps.colors", specName(layerName), 0);
     281            int i = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.colors", specName(layerName), 0);
    282282            return ColorMode.fromIndex(i);
    283283        } catch (IndexOutOfBoundsException e) {
     
    300300    public void readPreferences(String layerName) {
    301301        String spec = specName(layerName);
    302         forceLines = Main.pref.getBoolean("draw.rawgps.lines.force", spec, false);
    303         direction = Main.pref.getBoolean("draw.rawgps.direction", spec, false);
    304         lineWidth = Main.pref.getInteger("draw.rawgps.linewidth", spec, 0);
    305         alphaLines = Main.pref.getBoolean("draw.rawgps.lines.alpha-blend", spec, false);
     302        forceLines = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines.force", spec, false);
     303        direction = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.direction", spec, false);
     304        lineWidth = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.linewidth", spec, 0);
     305        alphaLines = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines.alpha-blend", spec, false);
    306306
    307307        if (!data.fromServer) {
    308             maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", spec, -1);
    309             lines = Main.pref.getBoolean("draw.rawgps.lines.local", spec, true);
     308            maxLineLength = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.max-line-length.local", spec, -1);
     309            lines = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines.local", spec, true);
    310310        } else {
    311             maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", spec, 200);
    312             lines = Main.pref.getBoolean("draw.rawgps.lines", spec, true);
    313         }
    314         large = Main.pref.getBoolean("draw.rawgps.large", spec, false);
    315         largesize = Main.pref.getInteger("draw.rawgps.large.size", spec, 3);
    316         hdopCircle = Main.pref.getBoolean("draw.rawgps.hdopcircle", spec, false);
     311            maxLineLength = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.max-line-length", spec, 200);
     312            lines = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines", spec, true);
     313        }
     314        large = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.large", spec, false);
     315        largesize = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.large.size", spec, 3);
     316        hdopCircle = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.hdopcircle", spec, false);
    317317        colored = getColorMode(layerName);
    318         alternateDirection = Main.pref.getBoolean("draw.rawgps.alternatedirection", spec, false);
    319         delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", spec, 40);
    320         colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", spec, 45);
    321         colorModeDynamic = Main.pref.getBoolean("draw.rawgps.colors.dynamic", spec, false);
     318        alternateDirection = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.alternatedirection", spec, false);
     319        delta = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.min-arrow-distance", spec, 40);
     320        colorTracksTune = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.colorTracksTune", spec, 45);
     321        colorModeDynamic = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.colors.dynamic", spec, false);
    322322        /* good HDOP's are between 1 and 3, very bad HDOP's go into 3 digit values */
    323323        hdoprange = Config.getPref().getInt("hdop.range", 7);
     
    326326
    327327        // get heatmap parameters
    328         heatMapEnabled = Main.pref.getBoolean("draw.rawgps.heatmap.enabled", spec, false);
    329         heatMapDrawExtraLine = Main.pref.getBoolean("draw.rawgps.heatmap.line-extra", spec, false);
    330         heatMapDrawColorTableIdx = Main.pref.getInteger("draw.rawgps.heatmap.colormap", spec, 0);
    331         heatMapDrawPointMode = Main.pref.getBoolean("draw.rawgps.heatmap.use-points", spec, false);
    332         heatMapDrawGain = Main.pref.getInteger("draw.rawgps.heatmap.gain", spec, 0);
    333         heatMapDrawLowerLimit = Main.pref.getInteger("draw.rawgps.heatmap.lower-limit", spec, 0);
     328        heatMapEnabled = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.heatmap.enabled", spec, false);
     329        heatMapDrawExtraLine = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.heatmap.line-extra", spec, false);
     330        heatMapDrawColorTableIdx = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.heatmap.colormap", spec, 0);
     331        heatMapDrawPointMode = PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.heatmap.use-points", spec, false);
     332        heatMapDrawGain = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.heatmap.gain", spec, 0);
     333        heatMapDrawLowerLimit = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.heatmap.lower-limit", spec, 0);
    334334
    335335        // shrink to range
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r12846 r12891  
    2525import org.openstreetmap.josm.Main;
    2626import org.openstreetmap.josm.actions.ExpertToggleAction;
     27import org.openstreetmap.josm.data.PreferencesUtils;
    2728import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper;
    2829import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
     
    392393            drawRawGpsLinesGlobal.setSelected(true);
    393394        } else {
    394             Boolean lf = Main.pref.getBoolean("draw.rawgps.lines.local", layerName, true);
    395             if (Main.pref.getBoolean("draw.rawgps.lines", layerName, true)) {
     395            Boolean lf =  PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines.local", layerName, true);
     396            if (PreferencesUtils.getBoolean(Config.getPref(), "draw.rawgps.lines", layerName, true)) {
    396397                drawRawGpsLinesAll.setSelected(true);
    397398            } else if (lf) {
     
    402403        }
    403404
    404         drawRawGpsMaxLineLengthLocal.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length.local", layerName, -1)));
    405         drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length", layerName, 200)));
    406         drawLineWidth.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.linewidth", layerName, 0)));
    407         drawLineWithAlpha.setSelected(Main.pref.getBoolean("draw.rawgps.lines.alpha-blend", layerName, false));
    408         forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force", layerName, false));
    409         drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction", layerName, false));
    410         drawGpsArrowsFast.setSelected(Main.pref.getBoolean("draw.rawgps.alternatedirection", layerName, false));
    411         drawGpsArrowsMinDist.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.min-arrow-distance", layerName, 40)));
    412         hdopCircleGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.hdopcircle", layerName, false));
    413         largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large", layerName, false));
     405        drawRawGpsMaxLineLengthLocal.setText(Integer.toString(PreferencesUtils.getInteger(Config.getPref(),
     406                "draw.rawgps.max-line-length.local", layerName, -1)));
     407        drawRawGpsMaxLineLength.setText(Integer.toString(PreferencesUtils.getInteger(Config.getPref(),
     408                "draw.rawgps.max-line-length", layerName, 200)));
     409        drawLineWidth.setText(Integer.toString(PreferencesUtils.getInteger(Config.getPref(),
     410                "draw.rawgps.linewidth", layerName, 0)));
     411        drawLineWithAlpha.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     412                "draw.rawgps.lines.alpha-blend", layerName, false));
     413        forceRawGpsLines.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     414                "draw.rawgps.lines.force", layerName, false));
     415        drawGpsArrows.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     416                "draw.rawgps.direction", layerName, false));
     417        drawGpsArrowsFast.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     418                "draw.rawgps.alternatedirection", layerName, false));
     419        drawGpsArrowsMinDist.setText(Integer.toString(PreferencesUtils.getInteger(Config.getPref(),
     420                "draw.rawgps.min-arrow-distance", layerName, 40)));
     421        hdopCircleGpsPoints.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     422                "draw.rawgps.hdopcircle", layerName, false));
     423        largeGpsPoints.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     424                "draw.rawgps.large", layerName, false));
    414425        useGpsAntialiasing.setSelected(Config.getPref().getBoolean("mappaint.gpx.use-antialiasing", false));
    415426
     
    424435            colorTypeHeatMapLowerLimit.setValue(0);
    425436        } else {
    426             int colorType = Main.pref.getInteger("draw.rawgps.colors", layerName, 0);
     437            int colorType = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.colors", layerName, 0);
    427438            switch (colorType) {
    428439            case 0: colorTypeNone.setSelected(true); break;
     
    434445            default: Logging.warn("Unknown color type: " + colorType);
    435446            }
    436             int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune", layerName, 45);
     447            int ccts = PreferencesUtils.getInteger(Config.getPref(), "draw.rawgps.colorTracksTune", layerName, 45);
    437448            colorTypeVelocityTune.setSelectedIndex(ccts == 10 ? 2 : (ccts == 20 ? 1 : 0));
    438             colorTypeHeatMapTune.setSelectedIndex(Main.pref.getInteger("draw.rawgps.heatmap.colormap", layerName, 0));
    439             colorDynamic.setSelected(Main.pref.getBoolean("draw.rawgps.colors.dynamic", layerName, false));
    440             colorTypeHeatMapPoints.setSelected(Main.pref.getBoolean("draw.rawgps.heatmap.use-points", layerName, false));
    441             colorTypeHeatMapGain.setValue(Main.pref.getInteger("draw.rawgps.heatmap.gain", layerName, 0));
    442             colorTypeHeatMapLowerLimit.setValue(Main.pref.getInteger("draw.rawgps.heatmap.lower-limit", layerName, 0));
     449            colorTypeHeatMapTune.setSelectedIndex(PreferencesUtils.getInteger(Config.getPref(),
     450                    "draw.rawgps.heatmap.colormap", layerName, 0));
     451            colorDynamic.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     452                    "draw.rawgps.colors.dynamic", layerName, false));
     453            colorTypeHeatMapPoints.setSelected(PreferencesUtils.getBoolean(Config.getPref(),
     454                    "draw.rawgps.heatmap.use-points", layerName, false));
     455            colorTypeHeatMapGain.setValue(PreferencesUtils.getInteger(Config.getPref(),
     456                    "draw.rawgps.heatmap.gain", layerName, 0));
     457            colorTypeHeatMapLowerLimit.setValue(PreferencesUtils.getInteger(Config.getPref(),
     458                    "draw.rawgps.heatmap.lower-limit", layerName, 0));
    443459        }
    444460    }
Note: See TracChangeset for help on using the changeset viewer.