Class XYDataPoint

java.lang.Object
no.uib.jsparklines.data.XYDataPoint
All Implemented Interfaces:
Serializable, Comparable<XYDataPoint>

public class XYDataPoint
extends Object
implements Comparable<XYDataPoint>, Serializable
Object storing data about one data point in an XY plot.
Author:
Harald Barsnes
See Also:
Serialized Form
  • Constructor Summary

    Constructors 
    Constructor Description
    XYDataPoint()
    Empty default constructor.
    XYDataPoint​(double x, double y)
    Create a new XYDataPoint.
    XYDataPoint​(double x, double y, boolean compareBasedOnFirstDataPoint)
    Create a new XYDataPoint.
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(XYDataPoint o)
    Compares based on the x-value or the sum of the x- and y-value, depending on the compareBasedOnFirstDataPoint settings.
    double getX()
    Returns the x value.
    double getY()
    Returns the y value.
    void setX​(double x)
    Set the x value.
    void setY​(double y)
    Set the y value.
    String toString()
    Returns the x-value as a string.

    Methods inherited from class java.lang.Object

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

    • XYDataPoint

      public XYDataPoint()
      Empty default constructor.
    • XYDataPoint

      public XYDataPoint​(double x, double y)
      Create a new XYDataPoint.
      Parameters:
      x - the x value
      y - the y value
    • XYDataPoint

      public XYDataPoint​(double x, double y, boolean compareBasedOnFirstDataPoint)
      Create a new XYDataPoint.
      Parameters:
      x - the x value
      y - the y value
      compareBasedOnFirstDataPoint - if true, the compare method will use the first data point, false will use the sum
  • Method Details

    • getX

      public double getX()
      Returns the x value.
      Returns:
      the x value
    • setX

      public void setX​(double x)
      Set the x value.
      Parameters:
      x - the x to set
    • getY

      public double getY()
      Returns the y value.
      Returns:
      the y value
    • setY

      public void setY​(double y)
      Set the y value.
      Parameters:
      y - the y to set
    • toString

      public String toString()
      Returns the x-value as a string. Note that the values are rounded to two decimals.
      Overrides:
      toString in class Object
      Returns:
      the xy-values as a string
    • compareTo

      public int compareTo​(XYDataPoint o)
      Compares based on the x-value or the sum of the x- and y-value, depending on the compareBasedOnFirstDataPoint settings.
      Specified by:
      compareTo in interface Comparable<XYDataPoint>