protected Point2D checkUpperLimits(){
  Point2D p1=new Point2D.Double();
  Point2D p2=null;
  double moveX=0;
  double moveY=0;
  inverse(width,0,p1);
  if (p1.getX() > rightLimit) {
    p2=forward(centerY,rightLimit,p2);
    moveX=width - p2.getX();
  }
  if (p1.getY() > topLimit) {
    p2=forward(topLimit,centerX,p2);
    moveY=p2.getY();
  }
  if (p2 != null) {
    inverse(hWidth - moveX,hHeight + moveY,p2);
  }
  return p2;
}

protected Point2D checkUpperLimits ( ) { Point2D p1 = new Point2D . Double ( ) ; Point2D p2 = null ; double moveX = 0 ; double moveY = 0 ; inverse ( width , 0 , p1 ) ; if ( p1 . getX ( ) > rightLimit ) { p2 = forward ( centerY , rightLimit , p2 ) ; moveX = width - p2 . getX ( ) ; } if ( p1 . getY ( ) > topLimit ) { p2 = forward ( topLimit , centerX , p2 ) ; moveY = p2 . getY ( ) ; } if ( p2 != null ) { inverse ( hWidth - moveX , hHeight + moveY , p2 ) ; } return p2 ; }
checks the upper limits and returns new center coordinates to keep the limits at the edge if necessary .
