altosuilib: Make map-cache per-window instead of global
[fw/altos] / altosuilib / AltosUIMapView.java
index efae376786f5652951fd600623fbdd3510bfe94a..4df178e2e57e6ba676d0f619a30aedc0d6e2b0ce 100644 (file)
@@ -34,6 +34,8 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo
 
        AltosUIMapLine  line = new AltosUIMapLine();
 
 
        AltosUIMapLine  line = new AltosUIMapLine();
 
+       AltosUIMapCache cache = new AltosUIMapCache();
+
        LinkedList<AltosUIMapMark> marks = new LinkedList<AltosUIMapMark>();
 
        LinkedList<AltosUIMapZoomListener> zoom_listeners = new LinkedList<AltosUIMapZoomListener>();
        LinkedList<AltosUIMapMark> marks = new LinkedList<AltosUIMapMark>();
 
        LinkedList<AltosUIMapZoomListener> zoom_listeners = new LinkedList<AltosUIMapZoomListener>();
@@ -368,7 +370,7 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo
                for (Point point : to_remove)
                        tiles.remove(point);
 
                for (Point point : to_remove)
                        tiles.remove(point);
 
-               AltosUIMapCache.set_cache_size(((lower_right.y - upper_left.y) / px_size + 1) * ((lower_right.x - upper_left.x) / px_size + 1));
+               cache.set_cache_size(((lower_right.y - upper_left.y) / px_size + 1) * ((lower_right.x - upper_left.x) / px_size + 1));
                for (int y = upper_left.y; y <= lower_right.y; y += px_size) {
                        for (int x = upper_left.x; x <= lower_right.x; x += px_size) {
                                Point point = new Point(x, y);
                for (int y = upper_left.y; y <= lower_right.y; y += px_size) {
                        for (int x = upper_left.x; x <= lower_right.x; x += px_size) {
                                Point point = new Point(x, y);
@@ -394,6 +396,8 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo
                }
        }
 
                }
        }
 
+       public AltosUIMapCache cache() { return cache; }
+
        /* AltosUIMapStoreListener methods */
        public void notify_store(AltosUIMapStore store, int status) {
                if (load_listener != null) {
        /* AltosUIMapStoreListener methods */
        public void notify_store(AltosUIMapStore store, int status) {
                if (load_listener != null) {