This consumes more memory, but avoids cache conflicts between windows
Signed-off-by: Keith Packard <keithp@keithp.com>
static final int bad_request = 3;
static final int forbidden = 4;
static final int bad_request = 3;
static final int forbidden = 4;
- static private Object fetch_lock = new Object();
+ static final int min_cache_size = 9;
+ static final int max_cache_size = 24;
- static final int min_cache_size = 9;
- static final int max_cache_size = 24;
+ private Object fetch_lock = new Object();
+ private Object cache_lock = new Object();
- static int cache_size = min_cache_size;
+ int cache_size = min_cache_size;
- static AltosUIMapImage[] images = new AltosUIMapImage[cache_size];
+ AltosUIMapImage[] images = new AltosUIMapImage[cache_size];
- static Object cache_lock = new Object();
- public static void set_cache_size(int new_size) {
+ public void set_cache_size(int new_size) {
if (new_size < min_cache_size)
new_size = min_cache_size;
if (new_size > max_cache_size)
if (new_size < min_cache_size)
new_size = min_cache_size;
if (new_size > max_cache_size)
- static long used;
-
- public static Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) {
+ public Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) {
int oldest = -1;
long age = used;
int oldest = -1;
long age = used;
+
+ public AltosUIMapCache() {
+ }
public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, ItemListener, AltosUIMapTileListener {
AltosUIFrame owner;
AltosUIMap map;
public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, ItemListener, AltosUIMapTileListener {
AltosUIFrame owner;
AltosUIMap map;
+ AltosUIMapCache cache = new AltosUIMapCache();
AltosUIMapPos lat;
AltosUIMapPos lon;
AltosUIMapPos lat;
AltosUIMapPos lon;
+ public AltosUIMapCache cache() { return cache; }
+
public void set_sites() {
int i = 1;
for (AltosUISite site : sites.sites) {
public void set_sites() {
int i = 1;
for (AltosUISite site : sites.sites) {
int zoom;
int maptype;
AltosUIMapStore store;
int zoom;
int maptype;
AltosUIMapStore store;
int status;
private File map_file() {
int status;
private File map_file() {
++painting_serial;
if (image == null && t.has_location())
++painting_serial;
if (image == null && t.has_location())
- image = AltosUIMapCache.get(this, store, px_size, px_size);
+ image = cache.get(this, store, px_size, px_size);
paint_graphics(g2d, t, painting_serial);
}
paint_graphics(g2d, t, painting_serial);
}
public AltosUIMapTile(AltosUIMapTileListener listener, AltosUILatLon upper_left, AltosUILatLon center, int zoom, int maptype, int px_size, Font font) {
this.listener = listener;
this.upper_left = upper_left;
public AltosUIMapTile(AltosUIMapTileListener listener, AltosUILatLon upper_left, AltosUILatLon center, int zoom, int maptype, int px_size, Font font) {
this.listener = listener;
this.upper_left = upper_left;
+ cache = listener.cache();
while (center.lon < -180.0)
center.lon += 360.0;
while (center.lon < -180.0)
center.lon += 360.0;
public interface AltosUIMapTileListener {
abstract public void notify_tile(AltosUIMapTile tile, int status);
public interface AltosUIMapTileListener {
abstract public void notify_tile(AltosUIMapTile tile, int status);
+
+ abstract public AltosUIMapCache cache();
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>();
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);
+ 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) {