Package no.uib.jsparklines.data
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.
-
Constructor Details
-
XYDataPoint
public XYDataPoint()Empty default constructor. -
XYDataPoint
public XYDataPoint(double x, double y)Create a new XYDataPoint.- Parameters:
x
- the x valuey
- the y value
-
XYDataPoint
public XYDataPoint(double x, double y, boolean compareBasedOnFirstDataPoint)Create a new XYDataPoint.- Parameters:
x
- the x valuey
- the y valuecompareBasedOnFirstDataPoint
- 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
Returns the x-value as a string. Note that the values are rounded to two decimals. -
compareTo
Compares based on the x-value or the sum of the x- and y-value, depending on the compareBasedOnFirstDataPoint settings.- Specified by:
compareTo
in interfaceComparable<XYDataPoint>
-