Record Class LayoutUtil.Point2D

java.lang.Object
java.lang.Record
cloud.opencode.base.graph.layout.LayoutUtil.Point2D
Record Components:
x - x-coordinate | x坐标
y - y-coordinate | y坐标
Enclosing class:
LayoutUtil

public static record LayoutUtil.Point2D(double x, double y) extends Record
Immutable 2D point for graph layout. 用于图布局的不可变二维点。
Since:
JDK 25, opencode-base-graph V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Point2D

      public Point2D(double x, double y)
      Creates an instance of a Point2D record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
  • Method Details

    • distanceTo

      public double distanceTo(LayoutUtil.Point2D other)
      Calculate distance to another point. 计算到另一点的距离。
      Parameters:
      other - the other point | 另一点
      Returns:
      distance | 距离
    • add

      Add another point (vector addition). 添加另一点(向量加法)。
      Parameters:
      other - the other point | 另一点
      Returns:
      new point | 新点
    • subtract

      public LayoutUtil.Point2D subtract(LayoutUtil.Point2D other)
      Subtract another point (vector subtraction). 减去另一点(向量减法)。
      Parameters:
      other - the other point | 另一点
      Returns:
      new point | 新点
    • multiply

      public LayoutUtil.Point2D multiply(double scalar)
      Multiply by scalar. 标量乘法。
      Parameters:
      scalar - the scalar | 标量
      Returns:
      new point | 新点
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component