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:
java.io.Serializable, java.lang.Iterable<java.awt.geom.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 10192 2013-06-18 19:50:36Z 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(java.util.List<java.lang.Double> x, java.util.List<java.lang.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(java.lang.Object obj)
           
 java.awt.geom.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
 java.lang.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
 int getNum()
          returns the number of points in this function list
 double getX(int index)
          Returns the x-value given an index
 double getY(int index)
          Returns the y-value given an index
 boolean hasPoint(double x, double y)
          Determine wheither a point exists in the list, as determined by it's x-value within tolerance.
 boolean hasPoint(java.awt.geom.Point2D point)
          Determine wheither a point exists in the list, as determined by it's x-value within tolerance.
 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(java.awt.geom.Point2D point)
          Either adds a new DataPoint, or replaces an existing one, within tolerance
 java.lang.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, java.lang.String elName)
           
 
Methods inherited from class org.opensha.commons.data.function.AbstractXY_DataSet
areAllXValuesInteger, getClosestX, getClosestY, 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(java.util.List<java.lang.Double> x,
                         java.util.List<java.lang.Double> y)
Initializes a new data set with the supplied Lists of x and y data

Parameters:
x - values
y - values
Throws:
java.lang.NullPointerException - if either data list is null
java.lang.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(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

get

public java.awt.geom.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


getNum

public int getNum()
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


hasPoint

public boolean hasPoint(java.awt.geom.Point2D point)
Description copied from interface: XY_DataSet
Determine wheither a point exists in the list, as determined by it's x-value within tolerance. Will return false if given a null value.


hasPoint

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


set

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

Throws:
Point2DException

set

public void set(double x,
                double y)
         throws Point2DException
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

Throws:
Point2DException

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,
                             java.lang.String elName)

toString

public java.lang.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 java.lang.Object
Returns:

getMetadataString

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