Package com.digitizer.core
Record Class Point
java.lang.Object
java.lang.Record
com.digitizer.core.Point
Represents a single data point with x and y coordinates.
Points are modeled as an immutable record to simplify threading and
ensure value semantics for equality and hashing. Use distanceTo(Point)
when comparing proximity between points.
-
Constructor Summary
ConstructorsConstructorDescriptionPoint(double x, double y) Creates a new Point with the specified coordinates. -
Method Summary
Modifier and TypeMethodDescriptiondoubledistanceTo(Point other) Calculates the Euclidean distance to another point.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.toString()Returns a string representation of the point.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.
-
Constructor Details
-
Point
public Point(double x, double y) Creates a new Point with the specified coordinates.- Parameters:
x- the x-coordinatey- the y-coordinate
-
-
Method Details
-
toString
Returns a string representation of the point. -
distanceTo
Calculates the Euclidean distance to another point.- Parameters:
other- the other point- Returns:
- the distance between this point and the other point
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public double x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public double y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-