Class Distance

java.lang.Object
ffx.numerics.clustering.Distance
All Implemented Interfaces:
Cloneable, Comparable<Distance>

public class Distance extends Object implements Comparable<Distance>, Cloneable
Simple value object storing a distance and an optional weight used during linkage computations; comparable by distance and cloneable.
Since:
1.0
Author:
Lars Behnke, 2013, Michael J. Schnieders
  • Constructor Details

    • Distance

      public Distance()
      Creates a Distance with value 0 and weight 1.
    • Distance

      public Distance(Double distance)
      Creates a Distance with the given value and unit weight.
      Parameters:
      distance - the distance value
    • Distance

      public Distance(Double distance, Double weight)
      Creates a Distance with the given value and weight.
      Parameters:
      distance - the distance value
      weight - the weight associated with this distance
  • Method Details

    • getDistance

      public Double getDistance()
      Gets the distance value.
      Returns:
      the distance value (may be null)
    • setDistance

      public void setDistance(Double distance)
      Sets the distance value.
      Parameters:
      distance - the distance value to set
    • getWeight

      public Double getWeight()
      Gets the weight.
      Returns:
      the weight
    • setWeight

      public void setWeight(Double weight)
      Sets the weight.
      Parameters:
      weight - the weight to set
    • isNaN

      public boolean isNaN()
      Checks whether the distance value is NaN or undefined.
      Returns:
      true if the distance is null or NaN; false otherwise
    • compareTo

      public int compareTo(Distance distance)
      Compares by distance value, with null other treated as greater (this invalid input: '<' other).
      Specified by:
      compareTo in interface Comparable<Distance>
      Parameters:
      distance - the other Distance to compare to
      Returns:
      negative, zero, or positive per Comparable contract
    • toString

      public String toString()
      Returns a string containing distance and weight values.
      Overrides:
      toString in class Object
      Returns:
      formatted string representation
    • clone

      public Distance clone()
      Creates a clone of this Distance.
      Overrides:
      clone in class Object
      Returns:
      a clone of this Distance