1    /*
2    Copyright 2000 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
6    import java.awt.geom.*;
7    
8    public class LazyQuad extends QuadCurve2D {
9    
10     Point2D CtrlPt;
11     Point2D P1;
12     Point2D P2;
13   
14     public LazyQuad(Point2D p1,Point2D ctrlp1,Point2D p2){
15       P1 = p1;
16       P2 = p2;
17       CtrlPt = ctrlp1;
18     }
19   
20     public Point2D  getCtrlPt() {
21       return(CtrlPt);
22     }
23   
24     public double  getCtrlX() {
25       return(CtrlPt.getX());
26     }
27   
28     public double  getCtrlY() {
29       return(CtrlPt.getY());
30     }
31   
32     public Point2D  getP1() {
33       return(P1);
34     }
35   
36     public double  getX1() {
37       return(P1.getX());
38     }
39   
40     public double  getY1() {
41       return(P1.getY());
42     }
43   
44     public Point2D  getP2() {
45       return(P2);
46     }
47   
48     public double  getX2() {
49       return(P2.getX());
50     }
51   
52     public double  getY2() {
53       return(P2.getY());
54     }
55   
56     public void setCurve(double x1, double y1, double ctrlx1, double ctrly1,
57           	double x2, double y2) {
58       P1 = new Point2D.Double(x1,y1);
59       P2 = new Point2D.Double(x2,y2);
60       CtrlPt = new Point2D.Double(ctrlx1,ctrly1);
61     }
62   
63     public Rectangle2D getBounds2D() {
64       double minx = P1.getX();
65       double maxx = minx;
66       if (P2.getX()<minx) minx = P2.getX();
67       if (P2.getX()>maxx) maxx = P2.getX();
68       if (CtrlPt.getX()<minx) minx = CtrlPt.getX();
69       if (CtrlPt.getX()>maxx) maxx = CtrlPt.getX();
70   
71       double miny = P1.getY();
72       double maxy = miny;
73       if (P2.getY()<miny) miny = P2.getY();
74       if (P2.getY()>maxy) maxy = P2.getY();
75       if (CtrlPt.getY()<miny) miny = CtrlPt.getY();
76       if (CtrlPt.getY()>maxy) maxy = CtrlPt.getY();
77   
78       return new Rectangle2D.Double(minx,miny,maxx,maxy);
79     }
80   
81   }
82   
83