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 LazyLine extends Line2D {
9    
10     Point2D P1;
11     Point2D P2;
12   
13     public LazyLine(Point2D p1,Point2D p2){
14       P1 = p1;
15       P2 = p2;
16     }
17   
18     public Point2D  getP1() {
19       return(P1);
20     }
21   
22     public double  getX1() {
23       return(P1.getX());
24     }
25   
26     public double  getY1() {
27       return(P1.getY());
28     }
29   
30     public Point2D  getP2() {
31       return(P2);
32     }
33   
34     public double getX2() {
35       return(P2.getX());
36     }
37   
38     public double  getY2() {
39       return(P2.getY());
40     }
41   
42     public void setLine(double x1, double y1, double x2, double y2) {
43       P1 = new Point2D.Double(x1,y1);
44       P2 = new Point2D.Double(x2,y2);
45     }
46   
47     public Rectangle2D getBounds2D() {
48       double minx = P1.getX();
49       double maxx = minx;
50       if (P2.getX()<minx) minx = P2.getX();
51       if (P2.getX()>maxx) maxx = P2.getX();
52   
53       double miny = P1.getY();
54       double maxy = miny;
55       if (P2.getY()<miny) miny = P2.getY();
56       if (P2.getY()>maxy) maxy = P2.getY();
57   
58       return new Rectangle2D.Double(minx,miny,maxx,maxy);
59     }
60   
61   }
62