Worldwind public release 0.2
[worldwind-tracker.git] / gov / nasa / worldwind / geom / Intersection.java
blobfc8987e0bc687d2fe559e956c39e37f9f58cea83
1 /*
2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
5 All Rights Reserved.
6 */
7 package gov.nasa.worldwind.geom;
9 import gov.nasa.worldwind.*;
11 /**
12 * @author Tom Gaskins
13 * @version $Id: Intersection.java 510 2007-01-17 04:57:40Z ericdalgliesh $
15 public final class Intersection // Instances are immutable
18 private final Point intersectionPoint;
19 private final boolean isTangent;
21 /**
22 * @param intersectionPoint
23 * @param isTangent
24 * @throws IllegalArgumentException if <code>intersectionpoint</code> is null
26 public Intersection(Point intersectionPoint, boolean isTangent)
28 if (intersectionPoint == null)
30 String message = WorldWind.retrieveErrMsg("nullValue.IntersectionPointIsNull");
31 WorldWind.logger().log(java.util.logging.Level.FINE, message);
32 throw new IllegalArgumentException(message);
34 this.intersectionPoint = intersectionPoint;
35 this.isTangent = isTangent;
38 public final Point getIntersectionPoint()
40 return intersectionPoint;
43 public final boolean isTangent()
45 return isTangent;
48 @Override
49 public boolean equals(Object o)
51 if (this == o)
52 return true;
53 if (o == null || getClass() != o.getClass())
54 return false;
56 final gov.nasa.worldwind.geom.Intersection that = (gov.nasa.worldwind.geom.Intersection) o;
58 if (isTangent != that.isTangent)
59 return false;
60 if (!intersectionPoint.equals(that.intersectionPoint))
61 return false;
63 return true;
66 @Override
67 public int hashCode()
69 int result;
70 result = intersectionPoint.hashCode();
71 result = 29 * result + (isTangent ? 1 : 0);
72 return result;
75 @Override
76 public String toString()
78 String pt = "Intersection Point: " + this.intersectionPoint;
79 String tang = this.isTangent ? " is a tangent." : " not a tangent";
80 return pt + tang;