diff options
author | Keith Packard <keithp@keithp.com> | 2015-05-21 13:49:28 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-05-21 13:49:28 -0700 |
commit | 29edc37a8de56cb6eb028e3bf3f56aa70f109eba (patch) | |
tree | ab2a1ac5a7edf706134cde3f54ed133f0efb7761 /altoslib/AltosPreferences.java | |
parent | 59a28811cb19d315b483df296145a2769c445f80 (diff) |
altoslib: Create display-independent map support code
This takes the swing-specific map code and creates a generic version.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosPreferences.java')
-rw-r--r-- | altoslib/AltosPreferences.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 5aa45d3f..9c4cadff 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -118,6 +118,13 @@ public class AltosPreferences { public final static String unitsPreference = "IMPERIAL-UNITS"; + /* Maps cache size preference name */ + final static String mapCachePreference = "MAP-CACHE"; + + static LinkedList<AltosMapCacheListener> map_cache_listeners; + + public static int map_cache = 9; + public static AltosFrequency[] load_common_frequencies() { AltosFrequency[] frequencies = null; boolean existing = false; @@ -208,6 +215,9 @@ public class AltosPreferences { common_frequencies = load_common_frequencies(); AltosConvert.imperial_units = backend.getBoolean(unitsPreference, false); + + map_cache = backend.getInt(mapCachePreference, 9); + map_cache_listeners = new LinkedList<AltosMapCacheListener>(); } public static void flush_preferences() { @@ -548,4 +558,33 @@ public class AltosPreferences { units_listeners.remove(l); } } + + + public static void register_map_cache_listener(AltosMapCacheListener l) { + synchronized(backend) { + map_cache_listeners.add(l); + } + } + + public static void unregister_map_cache_listener(AltosMapCacheListener l) { + synchronized (backend) { + map_cache_listeners.remove(l); + } + } + + public static void set_map_cache(int new_map_cache) { + synchronized(backend) { + map_cache = new_map_cache; + backend.putInt(mapCachePreference, map_cache); + flush_preferences(); + for (AltosMapCacheListener l: map_cache_listeners) + l.map_cache_changed(map_cache); + } + } + + public static int map_cache() { + synchronized(backend) { + return map_cache; + } + } } |