Ignore:
Timestamp:
2011-04-04T19:47:00+02:00 (13 years ago)
Author:
glebius
Message:

The default refreshtime of 5 seconds doesn't look like sane one, if
we are trying to emulate a navigator in JOSM. That will draw cursor
cornering right after the vehicle already passed a turn.

Decrease default refreshtime to 500 milliseconds. Deprecate the old
config key livegps.refreshinterval, and introduce a new key measured
in milliseconds.

Keep compatibility with old key.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/livegps/src/livegps/LiveGpsSuppressor.java

    r23191 r25788  
    1919
    2020    /**
    21      * Default sleep time is 5 seconds.
     21     * Default sleep time is 0.5 seconds.
    2222     */
    23     private static final int DEFAULT_SLEEP_TIME = 5;
    24 
    25     /**
    26      * The currently used sleepTime.
    27      */
    28     private int sleepTime = DEFAULT_SLEEP_TIME;
     23    private static final int DEFAULT_SLEEP_TIME = 500;
     24    private static final String oldConfigKey = "livegps.refreshinterval";     /* in seconds */
     25    private static final String ConfigKey = "livegps.refresh_interval_msec";  /* in msec */
     26    private int sleepTime;
    2927
    3028    /**
     
    6260
    6361    /**
    64      * Retrieve the sleepTime from the configuration.
    65      * If no such configuration key exists, it will be initialized here.
     62     * Retrieve the sleepTime from the configuration. Be compatible with old
     63     * version that stored value in seconds. If no such configuration key exists,
     64     * it will be initialized here.
    6665     */
    6766    private void initSleepTime() {
    68         // fetch it from the user setting, or use the default value.
    69         int sleepSeconds = 0;
    70         sleepSeconds = Main.pref.getInteger("livegps.refreshinterval",
    71                 DEFAULT_SLEEP_TIME);
     67        if ((this.sleepTime = Main.pref.getInteger(ConfigKey, 0)) == 0) {
     68                if ((this.sleepTime = Main.pref.getInteger(oldConfigKey, 0)) != 0) {
     69                        this.sleepTime *= 1000;
     70                        Main.pref.put(oldConfigKey, null);
     71                } else
     72                        this.sleepTime = DEFAULT_SLEEP_TIME;
     73        }
     74
    7275        // creates the setting, if none present.
    73         Main.pref.putInteger("livegps.refreshinterval", sleepSeconds);
    74 
    75         // convert seconds into milliseconds internally.
    76         this.sleepTime = sleepSeconds * 1000;
     76        Main.pref.putInteger(ConfigKey, this.sleepTime);
    7777    }
    7878
Note: See TracChangeset for help on using the changeset viewer.