org.opensha.commons.data.function
Class DefaultXY_DataSet

java.lang.Object
  extended by org.opensha.commons.data.function.AbstractXY_DataSet
      extended by org.opensha.commons.data.function.DefaultXY_DataSet
All Implemented Interfaces:
Serializable, Iterable<Point2D>, XY_DataSet, Named, PlotElement, XMLSaveable

public class DefaultXY_DataSet
extends AbstractXY_DataSet

Container for a data set of (X,Y) values. Internally, value pairs are stored as Point2Ds.

Version:
$Id: DefaultXY_DataSet.java 10931 2015-01-27 22:04:06Z kmilner $
Author:
Peter Powers, Kevin Milner
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opensha.commons.data.function.AbstractXY_DataSet
info, name, xAxisName, yAxisName
 
Fields inherited from interface org.opensha.commons.metadata.XMLSaveable
XML_METADATA_NAME
 
Constructor Summary
DefaultXY_DataSet()
          Initializes a new, empty data set.
DefaultXY_DataSet(double[] x, double[] y)
          Initializes a new data set with the supplied arrays of x and y data
DefaultXY_DataSet(List<Double> x, List<Double> y)
          Initializes a new data set with the supplied Lists of x and y data
 
Method Summary
 XY_DataSet deepClone()
          This function returns a new copy of this list, including copies of all the points.
 boolean equals(Object obj)
           
 Point2D get(int index)
          Returns the nth (x,y) point in the Function by index, or null if no such point exists
 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
 double getY(int index)
          Returns the y-value given an index
 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
 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)
           
 Element toXMLMetadata(Element root, String elName)
           
 
Methods inherited from class org.opensha.commons.data.function.AbstractXY_DataSet
areAllXValuesInteger, getClosestXtoY, getClosestYtoX, getDatasetsToPlot, getInfo, getName, getPlotNumColorList, getXAxisName, getXValuesIterator, getYAxisName, getYValuesIterator, iterator, setInfo, setName, setXAxisName, setYAxisName, xValues, yValues
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultXY_DataSet

public DefaultXY_DataSet()
Initializes a new, empty data set.


DefaultXY_DataSet

public DefaultXY_DataSet(List<Double> x,
                         List<Double> y)
Initializes a new data set with the supplied Lists of x and y data

Parameters:
x - values
y - values
Throws:
NullPointerException - if either data list is null
IllegalArgumentException - if either data list is empty

DefaultXY_DataSet

public DefaultXY_DataSet(double[] x,
                         double[] y)
Initializes a new data set with the supplied arrays of x and y data

Parameters:
x - values
y - values
Method Detail

deepClone

public XY_DataSet deepClone()
Description copied from interface: XY_DataSet
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.


equals

public boolean equals(Object obj)
Overrides:
equals in class Object

get

public Point2D get(int index)
Description copied from interface: XY_DataSet
Returns the nth (x,y) point in the Function by index, or null if no such point exists


getMaxX

public double getMaxX()
Description copied from interface: XY_DataSet
return the maximum x value along the x-axis


getMaxY

public double getMaxY()
Description copied from interface: XY_DataSet
return the maximum y value along the y-axis


getMinX

public double getMinX()
Description copied from interface: XY_DataSet
return the minimum x value along the x-axis.


getMinY

public double getMinY()
Description copied from interface: XY_DataSet
return the minimum y value along the y-axis


size

public int size()
Description copied from interface: XY_DataSet
returns the number of points in this function list


getX

public double getX(int index)
Description copied from interface: XY_DataSet
Returns the x-value given an index


getY

public double getY(int index)
Description copied from interface: XY_DataSet
Returns the y-value given an index


set

public void set(Point2D point)
Description copied from interface: XY_DataSet
Either adds a new DataPoint, or replaces an existing one, within tolerance


set

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


set

public void set(int index,
                double y)
Description copied from interface: XY_DataSet
Replaces a DataPoint y-value at the specifed index.


toXMLMetadata

public Element toXMLMetadata(Element root)

toXMLMetadata

public Element toXMLMetadata(Element root,
                             String elName)

toString

public 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.

Specified by:
toString in interface XY_DataSet
Overrides:
toString in class Object
Returns:

getMetadataString

public String getMetadataString()
Description copied from interface: XY_DataSet
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

hasX

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