MyBounds.java :  » UnTagged » wolfwei » netposa » map » Android Open Source

Android Open Source » UnTagged » wolfwei 
wolfwei » netposa » map » MyBounds.java
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;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.