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;
* @param inWidth width of display
* @param inHeight height of display
*/
- public void zoomToXY(double inMinX, double inMaxX, double inMinY, double inMaxY, int inWidth, int inHeight)
+ public void zoomToXY(double inMinX, double inMaxX, double inMinY, double inMaxY, int inWidth, int inHeight, int maxZoom)
{
// System.out.println("Zooming to " + inMinX + ", " + inMaxX + ", " + inMinY + ", " + inMaxY + "; width=" + inWidth + ", height=" + inHeight);
double diffX = Math.abs(inMaxX - inMinX);
double diffY = Math.abs(inMaxY - inMinY);
// Find out what zoom level to go to
int requiredZoom = -1;
- for (int currZoom = MAX_ZOOM; currZoom >= 2; currZoom--)
+ for (int currZoom = maxZoom; currZoom >= 2; currZoom--)
{
if (transformToPixels(diffX, currZoom) < inWidth
&& transformToPixels(diffY, currZoom) < inHeight)
}
}
if (requiredZoom < 2) requiredZoom = 2;
+ else if (requiredZoom > 18) requiredZoom = 18;
// Set position
setZoom(requiredZoom);
_xPosition = transformToPixels((inMinX + inMaxX) / 2.0);
_yPosition = transformToPixels((inMinY + inMaxY) / 2.0);
+ _empty = false;
}
/**
{
_zoom = inZoom;
_zoomFactor = 1 << _zoom;
+ _empty = false;
}
/**
// Set position
_xPosition = (_xPosition - inWidth/2 + (inMinX + inMaxX) / 2) * multFactor;
_yPosition = (_yPosition - inHeight/2 + (inMinY + inMaxY) / 2) * multFactor;
+ _empty = false;
}
/**
_xPosition += inDeltaX;
_yPosition += inDeltaY;
}
+
+ /**
+ * @return true if this position has never been set
+ */
+ public boolean isEmpty()
+ {
+ return _empty;
+ }
}