This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch master
in repository josm-plugins.

commit 514e7c5f40475ef3cc5f1500c024cd2eb890bf49
Author: David Paleino <da...@debian.org>
Date:   Fri Apr 15 11:41:53 2011 +0200

    Imported Upstream version 0.0.svn25845
---
 livegps/src/livegps/ILiveGpsSuppressor.java        |  20 ---
 livegps/src/livegps/LiveGpsAcquirer.java           |  74 +++++-----
 livegps/src/livegps/LiveGpsLayer.java              | 115 ++++++++++-----
 livegps/src/livegps/LiveGpsPlugin.java             | 162 +++++++++------------
 livegps/src/livegps/LiveGpsSuppressor.java         | 136 -----------------
 .../josm/plugin/routing/gui/RoutingDialog.java     |  18 +--
 .../josm/plugin/routing/gui/RoutingMenu.java       |   2 +-
 svn-info.xml                                       |   6 +-
 8 files changed, 190 insertions(+), 343 deletions(-)

diff --git a/livegps/src/livegps/ILiveGpsSuppressor.java 
b/livegps/src/livegps/ILiveGpsSuppressor.java
deleted file mode 100644
index 04aeb96..0000000
--- a/livegps/src/livegps/ILiveGpsSuppressor.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package livegps;
-
-/**
- * Interface for class LiveGpsSuppressor, only has a query if currently an 
update is allowed.
- *
- * @author casualwalker
- *
- */
-public interface ILiveGpsSuppressor {
-
-    /**
-     * Query, if an update is currently allowed.
-     * When it is allowed, it will disable the allowUpdate flag as a side 
effect.
-     * (this means, one thread got to issue an update event)
-     *
-     * @return true, if an update is currently allowed; false, if the update 
shall be suppressed.
-     */
-    boolean isAllowUpdate();
-
-}
diff --git a/livegps/src/livegps/LiveGpsAcquirer.java 
b/livegps/src/livegps/LiveGpsAcquirer.java
index 10684c7..2c13349 100644
--- a/livegps/src/livegps/LiveGpsAcquirer.java
+++ b/livegps/src/livegps/LiveGpsAcquirer.java
@@ -21,6 +21,10 @@ import org.json.JSONObject;
 import org.json.JSONException;
 
 public class LiveGpsAcquirer implements Runnable {
+    private static final String DEFAULT_HOST = "localhost";
+    private static final int DEFAULT_PORT = 2947;
+    private static final String C_HOST = "livegps.gpsd.host";
+    private static final String C_PORT = "livegps.gpsd.port";
     private String gpsdHost;
     private int gpsdPort;
 
@@ -40,11 +44,11 @@ public class LiveGpsAcquirer implements Runnable {
     public LiveGpsAcquirer() {
         super();
 
-        gpsdHost = Main.pref.get("livegps.gpsd.host", "localhost");
-        gpsdPort = Main.pref.getInteger("livegps.gpsd.port", 2947);
+        gpsdHost = Main.pref.get(C_HOST, DEFAULT_HOST);
+        gpsdPort = Main.pref.getInteger(C_PORT, DEFAULT_PORT);
         // put the settings back in to the preferences, makes keys appear.
-        Main.pref.put("livegps.gpsd.host", gpsdHost);
-        Main.pref.putInteger("livegps.gpsd.port", gpsdPort);
+        Main.pref.put(C_HOST, gpsdHost);
+        Main.pref.putInteger(C_PORT, gpsdPort);
     }
 
     /**
@@ -120,11 +124,20 @@ public class LiveGpsAcquirer implements Runnable {
         shutdownFlag = false;
         while (!shutdownFlag) {
 
-            try {
-                if (!connected)
+           while (!connected) {
+               try {
                     connect();
+               } catch (IOException iox) {
+                   fireGpsStatusChangeEvent( 
LiveGpsStatus.GpsStatus.CONNECTION_FAILED, tr("Connection Failed"));
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException ignore) {}
+               };
+           }
+
+           assert (connected);
 
-                if (connected) {
+           try {
                     String line;
 
                     // <FIXXME date="23.06.2007" author="cdaller">
@@ -133,7 +146,7 @@ public class LiveGpsAcquirer implements Runnable {
                     line = gpsdReader.readLine();
                     // </FIXXME>
                     if (line == null)
-                        break;
+                        throw new IOException();
 
                     if (JSONProtocol == true)
                         gpsData = ParseJSON(line);
@@ -145,21 +158,12 @@ public class LiveGpsAcquirer implements Runnable {
 
                     fireGpsDataChangeEvent(oldGpsData, gpsData);
                     oldGpsData = gpsData;
-                } else {
-                    
fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not 
connected"));
-                    try {
-                        Thread.sleep(1000);
-                    } catch (InterruptedException ignore) {}
-                }
             } catch (IOException iox) {
-                connected = false;
-                if (gpsData != null) {
-                    gpsData.setFix(false);
-                    fireGpsDataChangeEvent(oldGpsData, gpsData);
-                }
+                System.out.println("LiveGps: lost connection to gpsd");
                 fireGpsStatusChangeEvent(
                         LiveGpsStatus.GpsStatus.CONNECTION_FAILED,
                         tr("Connection Failed"));
+               disconnect();
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException ignore) {} ;
@@ -167,17 +171,10 @@ public class LiveGpsAcquirer implements Runnable {
             }
         }
 
+       System.out.println("LiveGps: Disconnected from gpsd");
         fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED,
                 tr("Not connected"));
-        if (gpsdSocket != null) {
-            try {
-                gpsdSocket.close();
-                gpsdSocket = null;
-                System.out.println("LiveGps: Disconnected from gpsd");
-            } catch (Exception e) {
-                System.out.println("LiveGps: Unable to close socket; 
reconnection may not be possible");
-            }
-        }
+       disconnect();
     }
 
     public void shutdown() {
@@ -196,16 +193,14 @@ public class LiveGpsAcquirer implements Runnable {
             try {
                 gpsdSocket = new Socket(addrs[i], gpsdPort);
                 break;
-            } catch (Exception e) {
+            } catch (IOException e) {
                 System.out.println("LiveGps: Could not open connection to 
gpsd: " + e);
                 gpsdSocket = null;
             }
         }
 
-        if (gpsdSocket == null)
-            return;
-
-        fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTING, 
tr("Connecting"));
+        if (gpsdSocket == null || gpsdSocket.isConnected() == false)
+            throw new IOException();
 
         /*
          * First emit the "w" symbol. The older version will activate, the 
newer one will ignore it.
@@ -249,6 +244,19 @@ public class LiveGpsAcquirer implements Runnable {
         }
     }
 
+    private void disconnect() {
+       assert(gpsdSocket != null);
+
+       connected = false;
+
+        try {
+               gpsdSocket.close();
+               gpsdSocket = null;
+       } catch (Exception e) {
+               System.out.println("LiveGps: Unable to close socket; 
reconnection may not be possible");
+       }
+    }
+
     private LiveGpsData ParseJSON(String line) {
         JSONObject report;
         String type;
diff --git a/livegps/src/livegps/LiveGpsLayer.java 
b/livegps/src/livegps/LiveGpsLayer.java
index 92f7fbd..5c4b4c3 100644
--- a/livegps/src/livegps/LiveGpsLayer.java
+++ b/livegps/src/livegps/LiveGpsLayer.java
@@ -5,6 +5,8 @@ import static org.openstreetmap.josm.tools.I18n.tr;
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.Point;
+import java.awt.geom.Point2D;
+import java.awt.Rectangle;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.text.SimpleDateFormat;
@@ -24,6 +26,20 @@ import org.openstreetmap.josm.gui.layer.GpxLayer;
 public class LiveGpsLayer extends GpxLayer implements PropertyChangeListener {
     public static final String LAYER_NAME = tr("LiveGPS layer");
     public static final String KEY_LIVEGPS_COLOR = "color.livegps.position";
+
+    private static final int DEFAULT_REFRESH_INTERVAL = 250;
+    private static final int DEFAULT_CENTER_INTERVAL = 5000;
+    private static final int DEFAULT_CENTER_FACTOR = 80;
+    private static final String oldC_REFRESH_INTERVAL = 
"livegps.refreshinterval";     /* in seconds */
+    private static final String C_REFRESH_INTERVAL = 
"livegps.refresh_interval_msec";  /* in msec */
+    private static final String C_CENTER_INTERVAL = 
"livegps.center_interval_msec";  /* in msec */
+    private static final String C_CENTER_FACTOR = "livegps.center_factor" /* 
in percent */;
+    private int refreshInterval;
+    private int centerInterval;
+    private double centerFactor;
+    private long lastRedraw = 0;
+    private long lastCenter = 0;
+
     LatLon lastPos;
     WayPoint lastPoint;
     private final AppendableGpxTrackSegment trackSegment;
@@ -31,13 +47,7 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
     float course;
     // JLabel lbl;
     boolean autocenter;
-    private SimpleDateFormat dateFormat = new SimpleDateFormat(
-    "yyyy-MM-dd'T'HH:mm:ss.SSS");
-
-    /**
-     * The suppressor is queried, if the GUI shall be re-drawn.
-     */
-    private ILiveGpsSuppressor suppressor;
+    private SimpleDateFormat dateFormat = new 
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
 
     public LiveGpsLayer(GpxData data) {
         super(data, LAYER_NAME);
@@ -48,26 +58,24 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
 
         GpxTrack trackBeingWritten = new SingleSegmentGpxTrack(trackSegment, 
attr);
         data.tracks.add(trackBeingWritten);
+
+       initIntervals();
     }
 
     void setCurrentPosition(double lat, double lon) {
-        // System.out.println("adding pos " + lat + "," + lon);
         LatLon thisPos = new LatLon(lat, lon);
-        if ((lastPos != null) && (thisPos.equalsEpsilon(lastPos))) {
+        if ((lastPos != null) && (thisPos.equalsEpsilon(lastPos)))
             // no change in position
             // maybe show a "paused" cursor or some such
             return;
-        }
 
         lastPos = thisPos;
         lastPoint = new WayPoint(thisPos);
         lastPoint.attr.put("time", dateFormat.format(new Date()));
         trackSegment.addWaypoint(lastPoint);
-        if (autocenter && allowRedraw()) {
-            center();
-        }
 
-        // Main.map.repaint();
+       if (autocenter)
+               conditionalCenter(thisPos);
     }
 
     public void center() {
@@ -75,6 +83,20 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
             Main.map.mapView.zoomTo(lastPoint.getCoor());
     }
 
+    public void conditionalCenter(LatLon Pos) {
+       Point2D P = Main.map.mapView.getPoint2D(Pos);
+       Rectangle rv = Main.map.mapView.getBounds(null);
+       Date date = new Date();
+       long current = date.getTime();
+
+       rv.grow(-(int)(rv.getHeight() * centerFactor), -(int)(rv.getWidth() * 
centerFactor));
+
+       if (!rv.contains(P) || (centerInterval > 0 && current - lastCenter >= 
centerInterval)) {
+               Main.map.mapView.zoomTo(Pos);
+               lastCenter = current;
+       }
+    }
+
     // void setStatus(String status)
     // {
     // this.status = status;
@@ -84,12 +106,10 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
 
     void setSpeed(float metresPerSecond) {
         speed = metresPerSecond;
-        // Main.map.repaint();
     }
 
     void setCourse(float degrees) {
         course = degrees;
-        // Main.map.repaint();
     }
 
     public void setAutoCenter(boolean ac) {
@@ -98,9 +118,8 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
 
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds bounds) {
-        // System.out.println("in paint");
-        // System.out.println("in synced paint");
         super.paint(g, mv, bounds);
+
         // int statusHeight = 50;
         // Rectangle mvs = mv.getBounds();
         // mvs.y = mvs.y + mvs.height - statusHeight;
@@ -146,38 +165,56 @@ public class LiveGpsLayer extends GpxLayer implements 
PropertyChangeListener {
                 if (!Float.isNaN(data.getCourse())) {
                     setCourse(data.getCourse());
                 }
-                if (!autocenter && allowRedraw()) {
+                if (allowRedraw())
                     Main.map.repaint();
-                }
             }
         }
     }
 
     /**
-     * @param suppressor the suppressor to set
-     */
-    public void setSuppressor(ILiveGpsSuppressor suppressor) {
-        this.suppressor = suppressor;
-    }
-
-    /**
-     * @return the suppressor
-     */
-    public ILiveGpsSuppressor getSuppressor() {
-        return suppressor;
-    }
-
-    /**
      * Check, if a redraw is currently allowed.
      *
      * @return true, if a redraw is permitted, false, if a re-draw
      * should be suppressed.
      */
     private boolean allowRedraw() {
-        if (this.suppressor != null) {
-            return this.suppressor.isAllowUpdate();
-        } else {
-            return true;
-        }
+       Date date = new Date();
+       long current = date.getTime();
+
+       if (current - lastRedraw >= refreshInterval) {
+               lastRedraw = current;
+               return true;
+       } else
+               return false;
+    }
+
+    /**
+     * Retrieve the refreshInterval and centerInterval from the configuration. 
Be compatible
+     * with old version that stored refreshInterval in seconds. If no such 
configuration key
+     * exists, it will be initialized here.
+     */
+    private void initIntervals() {
+       if ((refreshInterval = Main.pref.getInteger(oldC_REFRESH_INTERVAL, 0)) 
!= 0) {
+               refreshInterval *= 1000;
+               Main.pref.put(oldC_REFRESH_INTERVAL, null);
+       } else
+               refreshInterval = Main.pref.getInteger(C_REFRESH_INTERVAL, 
DEFAULT_REFRESH_INTERVAL);
+
+       centerInterval = Main.pref.getInteger(C_CENTER_INTERVAL, 
DEFAULT_CENTER_INTERVAL);
+       centerFactor = Main.pref.getInteger(C_CENTER_FACTOR, 
DEFAULT_CENTER_FACTOR);
+       if (centerFactor <= 1 || centerFactor >= 99)
+               centerFactor = DEFAULT_CENTER_FACTOR;
+
+        Main.pref.putInteger(C_REFRESH_INTERVAL, refreshInterval);
+        Main.pref.putInteger(C_CENTER_INTERVAL, centerInterval);
+       Main.pref.putInteger(C_CENTER_FACTOR, (int )centerFactor);
+
+       /*
+        * Do one time conversion of factor: user value means "how big is inner 
rectangle
+        * comparing to screen in percent", machine value means "what is the 
shrink ratio
+        * for each dimension on _both_ sides".
+        */
+
+       centerFactor = (100 - centerFactor) / 2 / 100;
     }
 }
diff --git a/livegps/src/livegps/LiveGpsPlugin.java 
b/livegps/src/livegps/LiveGpsPlugin.java
index 19c24e2..b64bc00 100644
--- a/livegps/src/livegps/LiveGpsPlugin.java
+++ b/livegps/src/livegps/LiveGpsPlugin.java
@@ -27,27 +27,19 @@ import org.openstreetmap.josm.plugins.PluginInformation;
 import org.openstreetmap.josm.tools.Shortcut;
 
 public class LiveGpsPlugin extends Plugin implements LayerChangeListener {
+    private boolean enabled = false;
     private LiveGpsAcquirer acquirer = null;
     private Thread acquirerThread = null;
-    private JMenu lgpsmenu;
+    private JMenu lgpsmenu = null;
     private JCheckBoxMenuItem lgpscapture;
     private JCheckBoxMenuItem lgpsautocenter;
     private LiveGpsDialog lgpsdialog;
-    List<PropertyChangeListener> listenerQueue;
+    /* List of foreign (e.g. other plugins) subscribers */
+    List<PropertyChangeListener> listenerQueue = new 
ArrayList<PropertyChangeListener>();
 
     private GpxData data = new GpxData();
     private LiveGpsLayer lgpslayer = null;
 
-    /**
-     * The LiveGpsSuppressor is queried, if an event shall be suppressed.
-     */
-    private LiveGpsSuppressor suppressor;
-
-    /**
-     * separate thread, where the LiveGpsSuppressor executes.
-     */
-    private Thread suppressorThread;
-
     public class CaptureAction extends JosmAction {
         public CaptureAction() {
             super(
@@ -105,13 +97,12 @@ public class LiveGpsPlugin extends Plugin implements 
LayerChangeListener {
     }
 
     public void layerRemoved(Layer oldLayer) {
-        if (oldLayer == lgpslayer) {
-            enableTracking(false);
-            lgpscapture.setSelected(false);
-            removePropertyChangeListener(lgpslayer);
-            MapView.removeLayerChangeListener(this);
-            lgpslayer = null;
-        }
+        assert (oldLayer == lgpslayer);
+
+        enableTracking(false);
+        lgpscapture.setSelected(false);
+        MapView.removeLayerChangeListener(this);
+        lgpslayer = null;
     }
 
     public LiveGpsPlugin(PluginInformation info) {
@@ -133,8 +124,7 @@ public class LiveGpsPlugin extends Plugin implements 
LayerChangeListener {
         JosmAction autoCenterAction = new AutoCenterAction();
         lgpsautocenter = new JCheckBoxMenuItem(autoCenterAction);
         lgpsmenu.add(lgpsautocenter);
-        lgpsautocenter.setAccelerator(autoCenterAction.getShortcut()
-                .getKeyStroke());
+        
lgpsautocenter.setAccelerator(autoCenterAction.getShortcut().getKeyStroke());
     }
 
     /**
@@ -164,82 +154,65 @@ public class LiveGpsPlugin extends Plugin implements 
LayerChangeListener {
      * @param enable if <code>true</code> tracking is started.
      */
     public void enableTracking(boolean enable) {
-        if ((acquirer != null) && (!enable)) {
-            acquirer.shutdown();
-            acquirerThread = null;
-
-            // also stop the suppressor
-            if (suppressor != null) {
-                suppressor.shutdown();
-                suppressorThread = null;
-                if (lgpslayer != null) {
-                    lgpslayer.setSuppressor(null);
-                }
-            }
-        } else if (enable) {
-            // also start the suppressor
-            if (suppressor == null) {
-                suppressor = new LiveGpsSuppressor();
-            }
-            if (suppressorThread == null) {
-                suppressorThread = new Thread(suppressor);
-                suppressorThread.start();
-            }
+       
+        if (enable && !enabled) {
+            assert (acquirer == null);
+            assert (acquirerThread == null);
 
-            if (acquirer == null) {
-                acquirer = new LiveGpsAcquirer();
-                if (lgpslayer == null) {
-                    lgpslayer = new LiveGpsLayer(data);
-                    Main.main.addLayer(lgpslayer);
-                    MapView.addLayerChangeListener(this);
-                    lgpslayer.setAutoCenter(isAutoCenter());
-                }
-                // connect layer with acquirer:
-                addPropertyChangeListener(lgpslayer);
-
-                // connect layer with suppressor:
-                lgpslayer.setSuppressor(suppressor);
-                // add all listeners that were added before the acquirer
-                // existed:
-                if (listenerQueue != null) {
-                    for (PropertyChangeListener listener : listenerQueue) {
-                        addPropertyChangeListener(listener);
-                    }
-                    listenerQueue.clear();
-                }
-            }
-            if (acquirerThread == null) {
-                acquirerThread = new Thread(acquirer);
-                acquirerThread.start();
-            }
+            acquirer = new LiveGpsAcquirer();
+            acquirerThread = new Thread(acquirer);
 
-        }
-    }
+           if (lgpslayer == null) {
+               lgpslayer = new LiveGpsLayer(data);
+               Main.main.addLayer(lgpslayer);
+               MapView.addLayerChangeListener(this);
+               lgpslayer.setAutoCenter(isAutoCenter());
+           }
 
-    /**
-     * Add a listener for gps events.
-     * @param listener the listener.
-     */
-    public void addPropertyChangeListener(PropertyChangeListener listener) {
-        if (acquirer != null) {
-            acquirer.addPropertyChangeListener(listener);
-        } else {
-            if (listenerQueue == null) {
-                listenerQueue = new ArrayList<PropertyChangeListener>();
-            }
-            listenerQueue.add(listener);
-        }
+            acquirer.addPropertyChangeListener(lgpslayer);
+            acquirer.addPropertyChangeListener(lgpsdialog);
+            for (PropertyChangeListener listener : listenerQueue)
+               acquirer.addPropertyChangeListener(listener);
+
+            acquirerThread.start();
+
+           enabled = true;
+
+        } else if (!enable && enabled) {
+           assert (lgpslayer != null);
+            assert (acquirer != null);
+            assert (acquirerThread != null);
+
+           acquirer.shutdown();
+           acquirer = null;
+           acquirerThread = null;
+
+           enabled = false;
+       }
     }
 
-    /**
-     * Remove a listener for gps events.
-     * @param listener the listener.
-     */
-    public void removePropertyChangeListener(PropertyChangeListener listener) {
+    /** 
+     * Add a listener for gps events. 
+     * @param listener the listener. 
+     */ 
+    public void addPropertyChangeListener(PropertyChangeListener listener) { 
+        assert(!listenerQueue.contains(listener));
+
+        listenerQueue.add(listener); 
         if (acquirer != null)
-            acquirer.removePropertyChangeListener(listener);
-        else if (listenerQueue != null && listenerQueue.contains(listener))
-            listenerQueue.remove(listener);
+            acquirer.addPropertyChangeListener(listener); 
+    } 
+
+    /** 
+     * Remove a listener for gps events. 
+     * @param listener the listener. 
+     */ 
+    public void removePropertyChangeListener(PropertyChangeListener listener) 
{ 
+        assert(listenerQueue.contains(listener));
+
+        listenerQueue.remove(listener); 
+        if (acquirer != null) 
+            acquirer.removePropertyChangeListener(listener); 
     }
 
     /* (non-Javadoc)
@@ -247,12 +220,8 @@ public class LiveGpsPlugin extends Plugin implements 
LayerChangeListener {
      */
     @Override
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-        if (newFrame != null) {
-            // add dialog
+        if (newFrame != null)
             newFrame.addToggleDialog(lgpsdialog = new LiveGpsDialog(newFrame));
-            // connect listeners with acquirer:
-            addPropertyChangeListener(lgpsdialog);
-        }
     }
 
     /**
@@ -261,5 +230,4 @@ public class LiveGpsPlugin extends Plugin implements 
LayerChangeListener {
     public JMenu getLgpsMenu() {
         return this.lgpsmenu;
     }
-
 }
diff --git a/livegps/src/livegps/LiveGpsSuppressor.java 
b/livegps/src/livegps/LiveGpsSuppressor.java
deleted file mode 100644
index 78bcf17..0000000
--- a/livegps/src/livegps/LiveGpsSuppressor.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package livegps;
-
-import org.openstreetmap.josm.Main;
-
-/**
- * The LiveGpsSuppressor permits update events only once within a given 
timespan.
- * This is useful, when too frequent updates consume large parts of the CPU 
resources (esp.
- * on low-end devices, such as netbooks).
- *
- * Its own thread wakes up after the sleepTime and enables the allowUpdate 
flag.
- * When another thread (the LiveGpsAcquirere) "asks for permission",
- * the first call is permitted, but it also disables the updates for the 
following calls,
- * until the sleepTime has elapsed.
- *
- * @author casualwalker
- *
- */
-public class LiveGpsSuppressor implements Runnable, ILiveGpsSuppressor {
-
-    /**
-     * Default sleep time is 5 seconds.
-     */
-    private static final int DEFAULT_SLEEP_TIME = 5;
-
-    /**
-     * The currently used sleepTime.
-     */
-    private int sleepTime = DEFAULT_SLEEP_TIME;
-
-    /**
-     * The flag allowUpdate is enabled once during the sleepTime.
-     */
-    private boolean allowUpdate = false;
-
-    /**
-     * Controls if this thread is still in used.
-     */
-    private boolean shutdownFlag = false;
-
-    /**
-     * Run thread enables the allowUpdate flag once during its cycle.
-     * @see java.lang.Runnable#run()
-     */
-    public void run() {
-        initSleepTime();
-
-        shutdownFlag = false;
-        // stop the thread, when explicitely shut down or when disabled by
-        // config setting
-        while (!shutdownFlag && isEnabled()) {
-            setAllowUpdate(true);
-
-            try {
-                Thread.sleep(getSleepTime());
-            } catch (InterruptedException e) {
-                // TODO I never knew, how to handle this??? Probably just carry
-                // on
-            }
-        }
-
-    }
-
-    /**
-     * Retrieve the sleepTime from the configuration.
-     * If no such configuration key exists, it will be initialized here.
-     */
-    private void initSleepTime() {
-        // fetch it from the user setting, or use the default value.
-        int sleepSeconds = 0;
-        sleepSeconds = Main.pref.getInteger("livegps.refreshinterval",
-                DEFAULT_SLEEP_TIME);
-        // creates the setting, if none present.
-        Main.pref.putInteger("livegps.refreshinterval", sleepSeconds);
-
-        // convert seconds into milliseconds internally.
-        this.sleepTime = sleepSeconds * 1000;
-    }
-
-    /**
-     * Set the allowUpdate flag. May only privately accessible!
-     * @param allowUpdate the allowUpdate to set
-     */
-    private synchronized void setAllowUpdate(boolean allowUpdate) {
-        this.allowUpdate = allowUpdate;
-    }
-
-    /**
-     * Query, if an update is currently allowed.
-     * When it is allowed, it will disable the allowUpdate flag as a side 
effect.
-     * (this means, one thread got to issue an update event)
-     *
-     * @return true, if an update is currently allowed; false, if the update 
shall be suppressed.
-     * @see livegps.ILiveGpsSuppressor#isAllowUpdate()
-     */
-    public synchronized boolean isAllowUpdate() {
-
-        // if disabled, always permit a re-draw.
-        if (!isEnabled()) {
-            return true;
-        } else {
-
-            if (allowUpdate) {
-                allowUpdate = false;
-                return true;
-            } else {
-                return false;
-            }
-        }
-    }
-
-    /**
-     * A value below 1 disables this feature.
-     * This ensures that a small value does not run this thread
-     * in a tight loop.
-     *
-     * @return true, if suppressing is enabled
-     */
-    private boolean isEnabled() {
-        return this.sleepTime > 0;
-    }
-
-    /**
-     * Shut this thread down.
-     */
-    public void shutdown() {
-        shutdownFlag = true;
-    }
-
-    /**
-     * @return the defaultSleepTime
-     */
-    private int getSleepTime() {
-        return this.sleepTime;
-    }
-
-}
diff --git 
a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java 
b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
index ed86883..9644632 100644
--- a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
+++ b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
@@ -29,14 +29,15 @@ package com.innovant.josm.plugin.routing.gui;
 
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.BorderLayout;
 import java.awt.ComponentOrientation;
 import java.awt.Font;
 import java.awt.event.KeyEvent;
 
 import javax.swing.BorderFactory;
-import javax.swing.BoxLayout;
 import javax.swing.DefaultListModel;
 import javax.swing.JList;
+import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.border.EtchedBorder;
 
@@ -67,15 +68,8 @@ public class RoutingDialog extends ToggleDialog {
     public RoutingDialog() {
         super(tr("Routing"), "routing", tr("Open a list of routing nodes"),
                 Shortcut.registerShortcut("subwindow:relations", tr("Toggle: 
{0}", tr("Routing")), KeyEvent.VK_R, Shortcut.GROUP_LAYER), 150);
-        model= new DefaultListModel();
-        this.setSize(456, 292);
-        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-        this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
-        this.setName("PrincipalDialog");
-        this.setFont(new Font("Dialog", Font.PLAIN, 12));
-        this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-        this.add(getJScrollPane(), null);
-
+        model = new DefaultListModel();
+        add(getJScrollPane(), BorderLayout.CENTER);
     }
 
     /**
@@ -86,12 +80,8 @@ public class RoutingDialog extends ToggleDialog {
     private JScrollPane getJScrollPane() {
         if (jScrollPane == null) {
             jScrollPane = new JScrollPane();
-            
jScrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
-            
jScrollPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
             
jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
             
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
-            jScrollPane.setName("nList");
-            
jScrollPane.setViewportBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
             jScrollPane.setViewportView(getJList());
         }
         return jScrollPane;
diff --git a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java 
b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
index 29dff73..2b360b7 100644
--- a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
+++ b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
@@ -119,7 +119,7 @@ public class RoutingMenu extends JMenu {
         criteriaM.add(rfaster);
 
         criteriaM.addSeparator();
-        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Ignore oneways");
+        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways"));
         cbmi.addItemListener(new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) 
{
diff --git a/svn-info.xml b/svn-info.xml
index 212a54c..2574d66 100644
--- a/svn-info.xml
+++ b/svn-info.xml
@@ -3,16 +3,16 @@
 <entry
    kind="dir"
    path="plugins"
-   revision="25537">
+   revision="25850">
 <url>http://svn.openstreetmap.org/applications/editors/josm/plugins</url>
 <repository>
 <root>http://svn.openstreetmap.org</root>
 <uuid>b9d5c4c9-76e1-0310-9c85-f3177eceb1e4</uuid>
 </repository>
 <commit
-   revision="25527">
+   revision="25845">
 <author>stoecker</author>
-<date>2011-03-06T14:57:08.379261Z</date>
+<date>2011-04-14T14:32:17.341054Z</date>
 </commit>
 </entry>
 </info>

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/josm-plugins.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to