X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIMapView.java;h=a14fde6583e42cb64b938a49168dce22c751897f;hp=c558118ba78742bab83909ed4b7a78989bfc2b8a;hb=5392ee3c5328f8384ed30a2d147e4be96075e064;hpb=db2443fdbf65b65703217174303027c439124a83 diff --git a/altosuilib/AltosUIMapView.java b/altosuilib/AltosUIMapView.java index c558118b..a14fde65 100644 --- a/altosuilib/AltosUIMapView.java +++ b/altosuilib/AltosUIMapView.java @@ -28,12 +28,14 @@ import java.util.*; import java.util.concurrent.*; import org.altusmetrum.altoslib_4.*; -public class AltosUIMapView extends Canvas implements MouseMotionListener, MouseListener, MouseWheelListener, ComponentListener, AltosUIMapTileListener, AltosUIMapStoreListener { +public class AltosUIMapView extends Component implements MouseMotionListener, MouseListener, MouseWheelListener, ComponentListener, AltosUIMapTileListener, AltosUIMapStoreListener { AltosUIMapPath path = new AltosUIMapPath(); AltosUIMapLine line = new AltosUIMapLine(); + AltosUIMapCache cache = new AltosUIMapCache(); + LinkedList marks = new LinkedList(); LinkedList zoom_listeners = new LinkedList(); @@ -68,6 +70,11 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse line.set_font(AltosUILib.value_font); for (AltosUIMapTile tile : tiles.values()) tile.set_font(AltosUILib.value_font); + repaint(); + } + + public void set_units() { + repaint(); } private boolean is_drag_event(MouseEvent e) { @@ -129,8 +136,10 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse notice_user_input(); if (is_drag_event(e)) drag_start(e); - else + else { line.pressed(e, transform); + repaint(); + } } public void mouseReleased(MouseEvent e) { @@ -361,7 +370,7 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse 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); @@ -378,7 +387,7 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse } /* AltosUIMapTileListener methods */ - public void notify_tile(AltosUIMapTile tile, int status) { + public synchronized void notify_tile(AltosUIMapTile tile, int status) { for (Point point : tiles.keySet()) { if (tile == tiles.get(point)) { Point screen = transform.screen(point); @@ -387,8 +396,10 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse } } + public AltosUIMapCache cache() { return cache; } + /* AltosUIMapStoreListener methods */ - public void notify_store(AltosUIMapStore store, int status) { + public synchronized void notify_store(AltosUIMapStore store, int status) { if (load_listener != null) { for (AltosUIMapTile tile : tiles.values()) if (store.equals(tile.store)) @@ -415,7 +426,6 @@ public class AltosUIMapView extends Canvas implements MouseMotionListener, Mouse } public void paint(Graphics g) { - VolatileImage back_buffer = create_back_buffer(); do { GraphicsConfiguration gc = getGraphicsConfiguration();