public void rectangle(double x,double y,double halfWidth,double halfHeight){
  if (halfWidth < 0)   throw new IllegalArgumentException("half width can't be negative");
  if (halfHeight < 0)   throw new IllegalArgumentException("half height can't be negative");
  double xs=scaleX(x);
  double ys=scaleY(y);
  double ws=factorX(2 * halfWidth);
  double hs=factorY(2 * halfHeight);
  if (ws <= 1 && hs <= 1)   pixel(x,y);
 else   offscreen.draw(new Rectangle2D.Double(xs - ws / 2,ys - hs / 2,ws,hs));
  draw();
}

public void rectangle ( double x , double y , double halfWidth , double halfHeight ) { if ( halfWidth < 0 ) throw new IllegalArgumentException ( "half width can't be negative" ) ; if ( halfHeight < 0 ) throw new IllegalArgumentException ( "half height can't be negative" ) ; double xs = scaleX ( x ) ; double ys = scaleY ( y ) ; double ws = factorX ( 2 * halfWidth ) ; double hs = factorY ( 2 * halfHeight ) ; if ( ws <= 1 && hs <= 1 ) pixel ( x , y ) ; else offscreen . draw ( new Rectangle2D . Double ( xs - ws / 2 , ys - hs / 2 , ws , hs ) ) ; draw ( ) ; }
draws a rectangle of given half width and half height , centered on ( x , y ) .
