public boolean isOnMap(Projection proj){
  Point2D p1=proj.forward(lat,lon);
  Point2D p2=proj.forward(lat2,lon2);
  int h=(int)Math.abs(p2.getY() - p1.getY());
  int w=(int)Math.abs(p2.getX() - p1.getX());
  Rectangle imageRect=new Rectangle((int)p1.getX(),(int)p1.getY(),w,h);
  proj.forward(proj.getUpperLeft(),p1);
  proj.forward(proj.getLowerRight(),p2);
  h=(int)Math.abs(p2.getY() - p1.getY());
  w=(int)Math.abs(p2.getX() - p1.getX());
  Rectangle mapRect=new Rectangle((int)p1.getX(),(int)p1.getY(),w,h);
  return mapRect.intersects(imageRect);
}

public boolean isOnMap ( Projection proj ) { Point2D p1 = proj . forward ( lat , lon ) ; Point2D p2 = proj . forward ( lat2 , lon2 ) ; int h = ( int ) Math . abs ( p2 . getY ( ) - p1 . getY ( ) ) ; int w = ( int ) Math . abs ( p2 . getX ( ) - p1 . getX ( ) ) ; Rectangle imageRect = new Rectangle ( ( int ) p1 . getX ( ) , ( int ) p1 . getY ( ) , w , h ) ; proj . forward ( proj . getUpperLeft ( ) , p1 ) ; proj . forward ( proj . getLowerRight ( ) , p2 ) ; h = ( int ) Math . abs ( p2 . getY ( ) - p1 . getY ( ) ) ; w = ( int ) Math . abs ( p2 . getX ( ) - p1 . getX ( ) ) ; Rectangle mapRect = new Rectangle ( ( int ) p1 . getX ( ) , ( int ) p1 . getY ( ) , w , h ) ; return mapRect . intersects ( imageRect ) ; }
test to see if projected image is on map .
