]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/gui/map/MapPosition.java
Start with editable map, thanks to fperrin
[GpsPrune.git] / src / tim / prune / gui / map / MapPosition.java
index 25f05fc1a2a238370d8888ea4b807b7d3f5f8adb..a70bbf63ba79b86c02114d785c3737d96b6625c5 100644 (file)
@@ -17,6 +17,8 @@ public class MapPosition
        private int _zoom = 12;
        /** Factor to zoom by, 2 to the power of zoom */
        private int _zoomFactor = 1 << _zoom;
+       /** Flag to mark if this position has ever been set */
+       private boolean _empty = true;
        /** Maximum zoom level */
        private static final int MAX_ZOOM = 21;
 
@@ -51,6 +53,7 @@ public class MapPosition
                setZoom(requiredZoom);
                _xPosition = transformToPixels((inMinX + inMaxX) / 2.0);
                _yPosition = transformToPixels((inMinY + inMaxY) / 2.0);
+               _empty = false;
        }
 
        /**
@@ -61,6 +64,7 @@ public class MapPosition
        {
                _zoom = inZoom;
                _zoomFactor = 1 << _zoom;
+               _empty = false;
        }
 
        /**
@@ -93,6 +97,7 @@ public class MapPosition
                // Set position
                _xPosition = (_xPosition - inWidth/2 + (inMinX + inMaxX) / 2) * multFactor;
                _yPosition = (_yPosition - inHeight/2 + (inMinY + inMaxY) / 2) * multFactor;
+               _empty = false;
        }
 
        /**
@@ -277,4 +282,12 @@ public class MapPosition
                _xPosition += inDeltaX;
                _yPosition += inDeltaY;
        }
+
+       /**
+        * @return true if this position has never been set
+        */
+       public boolean isEmpty()
+       {
+               return _empty;
+       }
 }