View Javadoc

1   /* File LineObject2D.java 
2    *
3    * Project : Java Geometry Library
4    *
5    * ===========================================
6    * 
7    * This library is free software; you can redistribute it and/or modify it 
8    * under the terms of the GNU Lesser General Public License as published by
9    * the Free Software Foundation, either version 2.1 of the License, or (at
10   * your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful, but 
13   * WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14   * or FITNESS FOR A PARTICULAR PURPOSE.
15   *
16   * See the GNU Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public License
19   * along with this library. if not, write to :
20   * The Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21   * Boston, MA 02111-1307, USA.
22   */
23  
24  // package
25  
26  package math.geom2d.line;
27  
28  import math.geom2d.Point2D;
29  
30  // Imports
31  
32  /**
33   * Line object defined from 2 points. This object keep points reference in
34   * memory, and recomputes properties directly from points. LineObject2D is
35   * mutable.
36   * <p>
37   * Example :
38   * <p>
39   * <code>
40   * // Create an Edge2D<br>
41   * LineObject2D line = new LineObject2D(new Point2D(0, 0), new Point2D(1, 2));<br>
42   * // Change direction of line, by changing second point :<br>
43   * line.setPoint2(new Point2D(4, 5));<br>
44   * // Change position and direction of the line, by changing first point. <br>
45   * // 'line' is now the edge (2,3)-(4,5)<br>
46   * line.setPoint1(new Point2D(2, 3));<br>
47   * </code>
48   * <p>
49   * <p>
50   * This class is maybe slower than Edge2D or StraightLine2D, because parameters
51   * are updated each time a computation is made, causing lot of additional
52   * processing.
53   * @deprecated use Line2D instead
54   */
55  @Deprecated
56  public class LineObject2D extends Line2D implements Cloneable {
57  
58  
59      // ===================================================================
60      // constructors
61  
62      /** Define a new LineObject2D with two extremities. */
63      public LineObject2D(Point2D point1, Point2D point2) {
64          super(point1, point2);
65      }
66  
67      /** Define a new LineObject2D with two extremities. */
68      public LineObject2D(double x1, double y1, double x2, double y2) {
69          super(x1, y1, x2, y2);
70      }
71  
72      // ===================================================================
73      // Methods specific to LineObject2D
74  
75  
76      @Override
77      public Line2D clone() {
78          return new Line2D(p1.clone(), p2.clone());
79      }
80  }