Record Class ErrorBarPoint

java.lang.Object
java.lang.Record
com.arbergashi.charts.model.ErrorBarPoint
All Implemented Interfaces:
Serializable

public record ErrorBarPoint(double x, double y, double errorLow, double errorHigh) extends Record implements Serializable

ErrorBarPoint - Type-Safe Statistical Data Point

Immutable record representing a data point with error bars or uncertainty range. Designed for scientific data, statistical analysis, and uncertainty visualization.

Usage Example:

// Create point with symmetric error bars
ErrorBarPoint point = ErrorBarPoint.symmetric(1.0, 100.0, 5.0);

// Create point with asymmetric error bars
ErrorBarPoint asymmetric = ErrorBarPoint.of(2.0, 100.0, 95.0, 108.0);

// Add to chart model
DefaultChartModel model = new DefaultChartModel("Temperature");
model.addWithError(point);

Field Mapping:

  • x: X-axis value (time, category, independent variable)
  • y: Y-axis value (measurement, mean, central value)
  • errorLow: Lower bound of uncertainty range
  • errorHigh: Upper bound of uncertainty range
Since:
2026-01-16
Version:
1.0.0
Author:
Arber Gashi
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ErrorBarPoint(double x, double y, double errorLow, double errorHigh)
    Validates error bar data integrity.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    double
    Returns the value of the errorHigh record component.
    double
    Returns the value of the errorLow record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns true if error bars are symmetric.
    double
    Returns the lower error margin (y - errorLow).
    of(double x, double y, double errorLow, double errorHigh)
    Factory method for creating error bar points with asymmetric errors.
    double
    Returns the total uncertainty range (errorHigh - errorLow).
    symmetric(double x, double y, double error)
    Factory method for creating error bar points with symmetric errors.
    Converts to ChartPoint for internal rendering.
    final String
    Returns a string representation of this record class.
    double
    Returns the upper error margin (errorHigh - y).
    withStdDev(double x, double mean, double stdDev, double sigmas)
    Factory method for creating error bar points with standard deviation.
    double
    x()
    Returns the value of the x record component.
    double
    y()
    Returns the value of the y record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ErrorBarPoint

      public ErrorBarPoint(double x, double y, double errorLow, double errorHigh)
      Validates error bar data integrity.
  • Method Details

    • of

      public static ErrorBarPoint of(double x, double y, double errorLow, double errorHigh)
      Factory method for creating error bar points with asymmetric errors.
      Parameters:
      x - X-axis value
      y - Y-axis value (central measurement)
      errorLow - Lower bound of uncertainty
      errorHigh - Upper bound of uncertainty
      Returns:
      new ErrorBarPoint instance
    • symmetric

      public static ErrorBarPoint symmetric(double x, double y, double error)
      Factory method for creating error bar points with symmetric errors.
      Parameters:
      x - X-axis value
      y - Y-axis value (central measurement)
      error - Symmetric error margin (±)
      Returns:
      new ErrorBarPoint instance
    • withStdDev

      public static ErrorBarPoint withStdDev(double x, double mean, double stdDev, double sigmas)
      Factory method for creating error bar points with standard deviation.
      Parameters:
      x - X-axis value
      mean - Mean value
      stdDev - Standard deviation
      sigmas - Number of standard deviations (e.g., 1.96 for 95% CI)
      Returns:
      new ErrorBarPoint instance
    • toChartPoint

      public ChartPoint toChartPoint()
      Converts to ChartPoint for internal rendering. Mapping: x→x, y→y, min→errorLow, max→errorHigh
    • lowerError

      public double lowerError()
      Returns the lower error margin (y - errorLow).
    • upperError

      public double upperError()
      Returns the upper error margin (errorHigh - y).
    • range

      public double range()
      Returns the total uncertainty range (errorHigh - errorLow).
    • isSymmetric

      public boolean isSymmetric()
      Returns true if error bars are symmetric.
    • toString

      public final 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
    • errorLow

      public double errorLow()
      Returns the value of the errorLow record component.
      Returns:
      the value of the errorLow record component
    • errorHigh

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