diff options
| author | Keith Packard <keithp@keithp.com> | 2014-05-28 10:16:38 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-05-28 10:16:38 -0700 |
| commit | 52ce41952c5a3c31532fa4f0d1b3155a162b76f4 (patch) | |
| tree | 91d72fd602969a74b7d1ec0cc6c67fd298313c25 /altosuilib/AltosSiteMapTile.java | |
| parent | 5c3991768d3cb17fc99ad32b2d6d8d11f0e37dfa (diff) | |
altosuilib: Update map preloading UI to include zoom and maptypes
This lets you specify precisely which maps to load.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosSiteMapTile.java')
| -rw-r--r-- | altosuilib/AltosSiteMapTile.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/altosuilib/AltosSiteMapTile.java b/altosuilib/AltosSiteMapTile.java index 136fbd7a..f8b924a8 100644 --- a/altosuilib/AltosSiteMapTile.java +++ b/altosuilib/AltosSiteMapTile.java @@ -155,9 +155,16 @@ public class AltosSiteMapTile extends JComponent { return String.format(format, distance); } - boolean painting; + int painting_serial; + int painted_serial; + + public void paint_graphics(Graphics2D g2d, Image image, int serial) { + + if (serial < painted_serial) + return; + + painted_serial = serial; - public void paint_graphics(Graphics2D g2d, Image image) { if (image != null) { AltosSiteMap.debug_component(this, "paint_graphics"); g2d.drawImage(image, 0, 0, null); @@ -239,7 +246,6 @@ public class AltosSiteMapTile extends JComponent { } g2d.drawString(message, x, y); } - painting = false; } public void paint(Graphics g) { @@ -247,26 +253,23 @@ public class AltosSiteMapTile extends JComponent { Image image = null; boolean queued = false; - if (painting) { - AltosSiteMap.debug_component(this, "already painting"); - return; - } AltosSiteMap.debug_component(this, "paint"); + ++painting_serial; + if (file != null) { AltosSiteMapImage aimage; aimage = AltosSiteMapCache.get_image(this, file, px_size, px_size); if (aimage != null) { - if (aimage.validate()) + if (aimage.validate(painting_serial)) image = aimage.image; else queued = true; } } if (!queued) - paint_graphics(g2d, image); - painting = queued; + paint_graphics(g2d, image, painting_serial); } public void show(int state, Point2D.Double last_pt, Point2D.Double pt) |
