class Rectangle extends PS { Point pp1,pp2,pp3,pp4,cp; double scale=1.0; double lw=1.0; int itype=1; public Rectangle(Point p1, Point p3) { double ccx,ccy; Point p2=new Point(p3.px, p1.py); Point p4=new Point(p1.px, p3.py); pp1=p1;pp2=p2;pp3=p3;pp4=p4; ccx=(pp1.px+pp3.px)/2.0; ccy=(pp1.py+pp3.py)/2.0; pp1.center(ccx,ccy);pp2.center(ccx,ccy);pp3.center(ccx,ccy);pp4.center(ccx,ccy); } public Rectangle(Point p1, Point p2, Point p3, Point p4) { double ccx,ccy; pp1=p1;pp2=p2;pp3=p3;pp4=p4; ccx=(pp1.px+pp2.px+pp3.px+pp4.px)/4.0; ccy=(pp1.py+pp2.py+pp3.py+pp4.py)/4.0; pp1.center(ccx,ccy);pp2.center(ccx,ccy);pp3.center(ccx,ccy);pp4.center(ccx,ccy); } void move(double x, double y) { pp1.move(x, y);pp2.move(x,y);pp3.move(x,y);pp4.move(x,y); } void center(double x, double y) { pp1.center(x, y);pp2.center(x,y);pp3.center(x,y);pp4.center(x,y); } void rotate(double theta) { pp1.rotate(theta);pp2.rotate(theta);pp3.rotate(theta);pp4.rotate(theta); } void expand(double times) { pp1.expand(times);pp2.expand(times);pp3.expand(times);pp4.expand(times); } void draw() { double x1, y1, x2, y2, x3, y3; this.plot(pp1.px, pp1.py, 3);this.plot(pp2.px, pp2.py, 2); this.plot(pp3.px, pp3.py, 2);this.plot(pp4.px, pp4.py, 2); this.closepath();this.stroke(); } }