diff options
author | Keith Packard <keithp@keithp.com> | 2014-06-24 18:24:02 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-06-24 18:25:18 -0700 |
commit | ade2cc9abb8ca403a9ae5d1f9c145ab72ce94919 (patch) | |
tree | a049e59c6b97021e8f6c3305b5dc7f87f9963d26 /altosuilib/AltosUIPreferences.java | |
parent | 97269bb90c1602a1f8c54fc7b6c34383a0370621 (diff) |
altosuilib: Make map cache size configurable
Systems with sufficient memory can get smoother map scrolling by
making the cache larger. Would be nice to do this automatically?
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosUIPreferences.java')
-rw-r--r-- | altosuilib/AltosUIPreferences.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 509faaff..ecab20d4 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -34,6 +34,9 @@ public class AltosUIPreferences extends AltosPreferences { /* Window position preference name */ final static String positionPreference = "POSITION"; + /* Maps cache size preference name */ + final static String mapCachePreference = "MAP-CACHE"; + /* UI Component to pop dialogs up */ static Component component; @@ -52,6 +55,10 @@ public class AltosUIPreferences extends AltosPreferences { public static int position = AltosUILib.position_top_left; + static LinkedList<AltosUIMapCacheListener> map_cache_listeners; + + public static int map_cache = 9; + public static void init() { AltosPreferences.init(new AltosUIPreferencesBackend()); @@ -68,6 +75,9 @@ public class AltosUIPreferences extends AltosPreferences { position = backend.getInt(positionPreference, AltosUILib.position_top_left); position_listeners = new LinkedList<AltosPositionListener>(); + + map_cache = backend.getInt(mapCachePreference, 9); + map_cache_listeners = new LinkedList<AltosUIMapCacheListener>(); } static { init(); } @@ -215,4 +225,32 @@ public class AltosUIPreferences extends AltosPreferences { return position; } } + + public static void register_map_cache_listener(AltosUIMapCacheListener l) { + synchronized(backend) { + map_cache_listeners.add(l); + } + } + + public static void unregister_map_cache_listener(AltosUIMapCacheListener 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 (AltosUIMapCacheListener l: map_cache_listeners) + l.map_cache_changed(map_cache); + } + } + + public static int map_cache() { + synchronized(backend) { + return map_cache; + } + } } |