package netposa.map;
import android.graphics.Rect;
public class MyBounds {
private Rect mRect;
public MyBounds()
{
mRect=new Rect();
}
public void insert(int lat, int lon)
{
if(mRect.left==0&&mRect.top==0)
{
mRect.left=lat;
mRect.top=lon;
}else if(mRect.right==0&&mRect.bottom==0)
{
mRect.right=lat;
mRect.bottom=lon;
}else
{
mRect.union(lat, lon);
}
}
public int centerX()
{
if(mRect.isEmpty())
{
return 0;
}else if (mRect.right==0&&mRect.bottom==0) {
return mRect.left;
}else{
return mRect.centerX();
}
}
public int centerY() {
if(mRect.isEmpty())
{
return 0;
}else if (mRect.right==0&&mRect.bottom==0) {
return mRect.top;
}else{
return mRect.centerY();
}
}
public int getLatSpanE6() {
if (mRect.right==0&&mRect.bottom==0)
{
return 0;
}else {
return mRect.right-mRect.left;
}
}
public int getLonSpanE6() {
if (mRect.right==0&&mRect.bottom==0)
{
return 0;
}else{
return mRect.bottom-mRect.top;
}
}
public int getLeft() {
return mRect.left;
}
public int getTop() {
return mRect.top;
}
public int getRight() {
return mRect.right;
}
public int getBottom() {
return mRect.bottom;
}
}
|