org.opensha.commons.data.function
Interface XY_DataSet

All Superinterfaces:
Iterable<Point2D>, Named, PlotElement, Serializable, XMLSaveable
All Known Subinterfaces:
DiscretizedFunc
All Known Implementing Classes:
AbstractDiscretizedFunc, AbstractXY_DataSet, ArbDiscrEmpiricalDistFunc, ArbDiscrFuncWithParams, ArbIncrementalMagFreqDist, ArbitrarilyDiscretizedFunc, DefaultXY_DataSet, EvenlyDiscretizedFunc, EvenlyDiscrFuncWithParams, GaussianMagFreqDist, GutenbergRichterMagFreqDist, HistogramFunction, IncrementalMagFreqDist, LightFixedXFunc, SingleMagFreqDist, SummedMagFreqDist, TaperedGR_MagFreqDist, UncertainArbDiscDataset, UnmodifiableDiscrFunc, YC_1985_CharMagFreqDist

public interface XY_DataSet
extends PlotElement, Named, XMLSaveable, Serializable, Iterable<Point2D>

A wrapper for 2D double-valued data that provides access to data points via Point2Ds.

Note: Use of the word 'Set' in this class does not imply adherence to the Set interface. An XY_DataSet may contain multiple identical points, although subclasses are free to provide alternate behavior.

Version:
$Id: XY_DataSet.java 10931 2015-01-27 22:04:06Z kmilner $
Author:
Kevin Milner, Peter Powers

Field Summary
 
Fields inherited from interface org.opensha.commons.metadata.XMLSaveable
XML_METADATA_NAME
 
Method Summary
 boolean areAllXValuesInteger(double tolerance)
          It finds out whether the X values are within tolerance of an integer value
 XY_DataSet deepClone()
          This function returns a new copy of this list, including copies of all the points.
 Point2D get(int index)
          Returns the nth (x,y) point in the Function by index, or null if no such point exists
 double getClosestXtoY(double y)
          Get the X value for the point with closest Y.
 double getClosestYtoX(double x)
          Get the Y value for the point with closest X.
 String getInfo()
          Returns the info of this function.
 double getMaxX()
          return the maximum x value along the x-axis
 double getMaxY()
          return the maximum y value along the y-axis
 String getMetadataString()
          prints out the state of the list, such as number of points, the value of each point, etc.
 double getMinX()
          return the minimum x value along the x-axis.
 double getMinY()
          return the minimum y value along the y-axis
 double getX(int index)
          Returns the x-value given an index
 String getXAxisName()
          Gets the name of the X Axis
 Iterator<Double> getXValuesIterator()
          Returns an iterator over all x-values in the list.
 double getY(int index)
          Returns the y-value given an index
 String getYAxisName()
          Gets the name of the Y Axis
 Iterator<Double> getYValuesIterator()
          Returns an iterator over all y-values in the list.
 boolean hasX(double x)
          Determine whether a point exists in the list, as determined by it's x-value within tolerance (if applicable).
 void set(double x, double y)
          Creates a new DataPoint, then either adds it if it doesn't exist, or replaces an existing one, within tolerance
 void set(int index, double Y)
          Replaces a DataPoint y-value at the specifed index.
 void set(Point2D point)
          Either adds a new DataPoint, or replaces an existing one, within tolerance
 void setInfo(String info)
          Sets the info string of this function.
 void setName(String name)
          Sets the name of this function.
 void setXAxisName(String xName)
          Sets the name of the X Axis
 void setYAxisName(String xName)
          Sets the name of the X Axis
 int size()
          returns the number of points in this function list
 String toString()
          Standard java function, usually used for debugging, prints out the state of the list, such as number of points, the value of each point, etc.
 Element toXMLMetadata(Element root, String elName)
           
 List<Double> xValues()
           
 List<Double> yValues()
           
 
Methods inherited from interface org.opensha.commons.gui.plot.PlotElement
getDatasetsToPlot, getPlotNumColorList
 
Methods inherited from interface org.opensha.commons.data.Named
getName
 
Methods inherited from interface org.opensha.commons.metadata.XMLSaveable
toXMLMetadata
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

setName

void setName(String name)
Sets the name of this function.


setInfo

void setInfo(String info)
Sets the info string of this function.


getInfo

String getInfo()
Returns the info of this function.

Specified by:
getInfo in interface PlotElement
Returns:

size

int size()
returns the number of points in this function list


getMinX

double getMinX()
               throws IndexOutOfBoundsException
return the minimum x value along the x-axis.

Throws:
IndexOutOfBoundsException

getMaxX

double getMaxX()
               throws IndexOutOfBoundsException
return the maximum x value along the x-axis

Throws:
IndexOutOfBoundsException

getMinY

double getMinY()
               throws IndexOutOfBoundsException
return the minimum y value along the y-axis

Throws:
IndexOutOfBoundsException

getMaxY

double getMaxY()
               throws IndexOutOfBoundsException
return the maximum y value along the y-axis

Throws:
IndexOutOfBoundsException

get

Point2D get(int index)
Returns the nth (x,y) point in the Function by index, or null if no such point exists


getX

double getX(int index)
            throws IndexOutOfBoundsException
Returns the x-value given an index

Throws:
IndexOutOfBoundsException

getY

double getY(int index)
            throws IndexOutOfBoundsException
Returns the y-value given an index

Throws:
IndexOutOfBoundsException

getClosestYtoX

double getClosestYtoX(double x)
Get the Y value for the point with closest X. If multiple points are equidistant, the smaller X will be returned.

Parameters:
x -
Returns:

getClosestXtoY

double getClosestXtoY(double y)
Get the X value for the point with closest Y. If multiple points are equidistant, the smaller X will be returned.

Parameters:
y -
Returns:

set

void set(Point2D point)
Either adds a new DataPoint, or replaces an existing one, within tolerance


set

void set(double x,
         double y)
Creates a new DataPoint, then either adds it if it doesn't exist, or replaces an existing one, within tolerance


set

void set(int index,
         double Y)
         throws IndexOutOfBoundsException
Replaces a DataPoint y-value at the specifed index.

Throws:
IndexOutOfBoundsException

hasX

boolean hasX(double x)
Determine whether a point exists in the list, as determined by it's x-value within tolerance (if applicable).


getXValuesIterator

Iterator<Double> getXValuesIterator()
Returns an iterator over all x-values in the list. Results returned in sorted order.

Returns:

getYValuesIterator

Iterator<Double> getYValuesIterator()
Returns an iterator over all y-values in the list. Results returned in sorted order along the x-axis.

Returns:

toString

String toString()
Standard java function, usually used for debugging, prints out the state of the list, such as number of points, the value of each point, etc.

Overrides:
toString in class Object

getMetadataString

String getMetadataString()
prints out the state of the list, such as number of points, the value of each point, etc.

Returns:
value of each point in the function in String format

deepClone

XY_DataSet deepClone()
This function returns a new copy of this list, including copies of all the points. A shallow clone would only create a new DiscretizedFunc instance, but would maintain a reference to the original points.

Since this is a clone, you can modify it without changing the original.


areAllXValuesInteger

boolean areAllXValuesInteger(double tolerance)
It finds out whether the X values are within tolerance of an integer value

Parameters:
tolerance - tolerance value to consider rounding errors
Returns:
true if all X values are within the tolerance of an integer value else returns false

setXAxisName

void setXAxisName(String xName)
Sets the name of the X Axis

Parameters:
xName - String

getXAxisName

String getXAxisName()
Gets the name of the X Axis


setYAxisName

void setYAxisName(String xName)
Sets the name of the X Axis

Parameters:
xName - String

getYAxisName

String getYAxisName()
Gets the name of the Y Axis


xValues

List<Double> xValues()

yValues

List<Double> yValues()

toXMLMetadata

Element toXMLMetadata(Element root,
                      String elName)