net.von_gagern.martin.confoo.mesh.flat
Class Vertex2D
java.lang.Object
java.awt.geom.Point2D
java.awt.geom.Point2D.Double
net.von_gagern.martin.confoo.mesh.flat.Vertex2D
- All Implemented Interfaces:
- Serializable, Cloneable
public class Vertex2D
- extends Point2D.Double
A 2D point with equality comparison.
To easily construct meshes, it is useful to identify common
vertices. This implementation considers points equal if they
exactly agree in their coordinates. This contrasts with the
implementation in the super class, which inherits the equality
comparison from Object.
- Since:
- 1.0
- Author:
- Martin von Gagern
- See Also:
- Serialized Form
|
Constructor Summary |
Vertex2D(double x,
double y)
Construct vertex from given coordinates. |
Vertex2D(Point2D p)
Construct vertex from given point. |
|
Method Summary |
boolean |
equals(Object o)
Compare vertex to other point. |
int |
hashCode()
Calculate hash code from coordinates. |
Vertex2D
public Vertex2D(Point2D p)
- Construct vertex from given point.
- Parameters:
p - the point used to initialize the coordinates
Vertex2D
public Vertex2D(double x,
double y)
- Construct vertex from given coordinates.
- Parameters:
x - the initial x coordinatey - the initial y coordinate
hashCode
public int hashCode()
- Calculate hash code from coordinates.
- Overrides:
hashCode in class Point2D
- Returns:
- a hash code derived from the coordinates
equals
public boolean equals(Object o)
- Compare vertex to other point.
The comparison is based on coordinates, not object
identity. The classes aren't compared either. Any
Point2D with the same coordinates will compare
equal. This is a violation of symmetry! While it may be
handy to compare vertices with other points where you know what
you are doing, mixing them in any container that compares its
elements is a bad idea, as it can lead to inconsistent
behaviour.
- Overrides:
equals in class Point2D
- Parameters:
o - another object
- Returns:
- whether o is a
Point2D with the same
coordinates as this vertex - See Also:
Point2D
Copyright © 2008 Martin von Gagern. All Rights Reserved.