private Point2D.Double moveDragPoint(Point2D.Double p,Rectangle2D.Double maxMoveBounds,double mouseX,double mouseY,double xOffset,double yOffset){
  Point2D.Double nextPoint=new Point2D.Double(p.x,p.y);
  nextPoint.x=Math.max(maxMoveBounds.x,Math.min(maxMoveBounds.getMaxX(),mouseX - xOffset));
  nextPoint.y=Math.max(maxMoveBounds.y,Math.min(maxMoveBounds.getMaxY(),mouseY - yOffset));
  return nextPoint;
}

private Point2D . Double moveDragPoint ( Point2D . Double p , Rectangle2D . Double maxMoveBounds , double mouseX , double mouseY , double xOffset , double yOffset ) { Point2D . Double nextPoint = new Point2D . Double ( p . x , p . y ) ; nextPoint . x = Math . max ( maxMoveBounds . x , Math . min ( maxMoveBounds . getMaxX ( ) , mouseX - xOffset ) ) ; nextPoint . y = Math . max ( maxMoveBounds . y , Math . min ( maxMoveBounds . getMaxY ( ) , mouseY - yOffset ) ) ; return nextPoint ; }
takes the point specified by p and moves it to the point specified by mousex and mousey using the x and y offset and taking the maximum move bounds in to account - by allowing the maxmovebounds to constrain the movement in any particular direction .
