source: ether_statistics/service/implementation/gov/noaa/pmel/util/Point2D.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 3.5 KB
Line 
1/*
2 * $Id: Point2D.java,v 1.4 2003/08/22 23:02:40 dwd Exp $
3 *
4 * This software is provided by NOAA for full, free and open release.  It is
5 * understood by the recipient/user that NOAA assumes no liability for any
6 * errors contained in the code.  Although this software is released without
7 * conditions or restrictions in its use, it is expected that appropriate
8 * credit be given to its author and to the National Oceanic and Atmospheric
9 * Administration should the software be included by the recipient as an
10 * element in other product development.
11 */
12
13package  gov.noaa.pmel.util;
14
15import java.io.Serializable;
16
17/**
18 * Point2D will be part of java.java2d.
19 *
20 * @author Donald Denbo
21 * @version $Revision: 1.4 $, $Date: 2003/08/22 23:02:40 $
22 * @since sgt 1.0
23 */
24public abstract class Point2D implements Serializable, Cloneable {
25  /**
26   * Inner class for <code>Point2D</code> for type
27   * <code>double</code>.
28   * @since sgt 1.0
29   */
30  public static class Double extends Point2D {
31    /** x coordinate */
32    public double x;
33    /** y coordinate */
34    public double y;
35    /**
36     * Default constructor
37     */
38    public Double() {
39    }
40    public Double(double x,double y) {
41      this.x = x;
42      this.y = y;
43    }
44    /**
45     * Test for equality.  Both x and y coordinates must be equal for
46     * equality.
47     */
48    public boolean equals(Point2D.Double pt) {
49      return (x == pt.x && y == pt.y) ;
50    }
51    /**
52     * @since sgt 3.0
53     */
54    public boolean equals(Object pt) {
55      if(pt instanceof Point2D.Double) {
56        Point2D.Double pt2 = (Point2D.Double)pt;
57        return (x == pt2.x) && (y == pt2.y);
58      } else {
59        return false;
60      }
61    }
62    public String toString() {
63      return new String("(" + x + ", " + y + ")");
64    }
65    /**
66     * Make a copy of the <code>Rectangle2D</code>.
67     * @since sgt 3.0
68     */
69    public Point2D copy() {
70      try {
71        return (Point2D)clone();
72      } catch (CloneNotSupportedException e) {
73        return null;
74      }
75    }
76  }
77  /**
78   * Inner class for <code>Point2D</code> for type
79   * <code>float</code>.
80   * @since sgt 2.0
81   */
82  public static class Float extends Point2D {
83    /** x coordinate */
84    public float x;
85    /** y coordinate */
86    public float y;
87    /**
88     * Default constructor
89     */
90    public Float() {
91    }
92    public Float(float x,float y) {
93      this.x = x;
94      this.y = y;
95    }
96    /**
97     * Test for equality.  Both x and y coordinates must be equal for
98     * equality.
99     */
100    public boolean equals(Point2D.Float pt) {
101      return (x == pt.x && y == pt.y) ;
102    }
103    /**
104     * @since sgt 3.0
105     */
106    public boolean equals(Object pt) {
107      if(pt instanceof Point2D.Float) {
108        Point2D.Float pt2 = (Point2D.Float)pt;
109        return (x == pt2.x) && (y == pt2.y);
110      } else {
111        return false;
112      }
113    }
114    public String toString() {
115      return new String("(" + x + ", " + y + ")");
116    }
117    /**
118     * Make a copy of the <code>Rectangle2D</code>.
119     * @since sgt 3.0
120     */
121    public Point2D copy() {
122      try {
123        return (Point2D)clone();
124      } catch (CloneNotSupportedException e) {
125        return null;
126      }
127    }
128  }
129  /**
130   * This is an abstract class that cannot be instantiated directly.
131   * Type-specific implementation subclasses are available for
132   * instantiation and provide a number of formats for storing
133   * the information necessary to satisfy the various accessor
134   * methods below.
135   *
136   */
137  protected Point2D() {
138  }
139}
Note: See TracBrowser for help on using the repository browser.