public class Curve extends GraphType implements AsciiComm
( x(t), y(t), ... )where (x, y, ...) are the coordinates of a point on the curve and t is the parameter. Curve uses the GraphType convention that (x, y, ...) are the dependent variables, and t is the independent variable. Only one independent variable is allowed, but any number of dependent variables may be defined. Data are held as doubles. Curve does not define extra parameters, so it is a "raw" data type. It can hold real or complex data sets.
Curve sets independentVariables = 1. If the independent variable is sampled uniformly, then the object holds only the dependent data and a Triplet indicating how the sampling is done. If the independent variable is sampled irregularly, then the object holds the sampling values as well. Users can test isIndependentTriplet(0) (or method isUniform() ) to see which case holds.
Curve replaces the old Triana type TwoD.
TrianaType
,
GraphType
,
VectorType
,
Triplet
,
Serialized FormNOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
Curve()
Creates a new empty Curve in 2 dimensions by default
|
Curve(double[] x,
double[] y)
Creates a new real 2D Curve with a uniformly sampled independent variable and (x,y) data given by two 1D
arrays of doubles.
|
Curve(double[] x,
double[] y,
double[] z)
Creates a new real 3D Curve with a uniformly sampled independent variable and (x,y,z) data given by three
1D arrays of doubles.
|
Curve(int n)
Creates a new empty Curve in n dimensions.
|
Modifier and Type | Method and Description |
---|---|
TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
double[] |
getData(int dv)
Returns the real part of the data array for the given dependent variable.
|
double[] |
getDataImag(int dv)
Returns the imaginary part of the data array for the given dependent variable.
|
double[] |
getDataReal(int dv)
A synonym for getData.
|
java.lang.Object |
getGraphArrayImag(int dv)
Overrides a method of the same name in GraphType, to return the imaginary part of the values for the dependent
axes of a graph.
|
java.lang.Object |
getGraphArrayReal(int dv)
Overrides a method of the same name in GraphType, to return the real part of the values for the dependent axes of
a graph.
|
double[] |
getIndependentScaleImag(int dim)
Overrides a method of the same name in GraphType, to return the imaginary parts of values for the independent
axes of a graph.
|
double[] |
getIndependentScaleReal(int dim)
Overrides a method of the same name in GraphType, to return the real parts of values for the independent axes of
a graph.
|
double[] |
getXArray()
Returns the real part of the data array for the independent variable.
|
double[] |
getXImag()
Returns the imaginary part of the data array for the independent variable.
|
double[] |
getXReal()
A synonym for getXArray.
|
Triplet |
getXTriplet()
Returns the Triplet giving the independent data.
|
void |
initialiseData(int dv)
Sets the data array(s) to zero if they have been allocated.
|
void |
initialiseDataComplex(int len,
int dv)
Allocates the real and imaginary parts of the data for the given dimension to double arrays of the given length
and then sets their elements to zero.
|
void |
initialiseDataReal(int len,
int dv)
Allocates the real part of the data for a given dimension to a double array of the given length and then sets its
elements to zero.
|
boolean |
isCompatible(TrianaType obj)
Tests the argument object to determine if it makes sense to perform arithmetic operations between it and the
current object.
|
boolean |
isTriplet()
Tests to see if the independent variable is represented by a Triplet.
|
boolean |
isUniform()
Tests to see if the independent variable is uniformly sampled.
|
int |
length()
Synonym for method size.
|
void |
setData(double[] dataReal,
double[] dataImag,
int dv)
Sets the two argument double[] arrays as the real and imaginary parts of the dependent variable for the given
dimension
|
void |
setData(double[] data,
int dv)
An alias for setDataReal, useful in derived classes where the data is assumed to be real all the time.
|
void |
setDataImag(double[] data,
int dv)
Sets the argument double[] array as the imaginary part of the dependent variable for the given dimension.
|
void |
setDataReal(double[] data,
int dv)
Sets the argument double[] array as the (real part of) the dependent variable for the given dimension.
|
void |
setX(double[] xReal,
double[] xImag)
Sets the two argument double[] arrays as the real and imaginary parts of the independent variable.
|
void |
setX(java.lang.Object data)
Sets the argument double[] as the independent variable.
|
void |
setX(Triplet tr)
Sets the argument Triplet as the independent variable.
|
int |
size()
Returns the size or length of each of the data arrays.
|
boolean |
testDataModel()
Tests to make sure this Object obeys the Curve data model.
|
add, addToTitle, convertDependentDataArraysToBytes, convertDependentDataArraysToDoubles, convertDependentDataArraysToFloats, convertDependentDataArraysToInts, convertDependentDataArraysToLongs, convertDependentDataArraysToShorts, copyData, copyLabels, copyParameters, divide, equals, getDataArrayClass, getDataArrayImag, getDataArrayImag, getDataArrayImagAsBytes, getDataArrayImagAsDoubles, getDataArrayImagAsFloats, getDataArrayImagAsInts, getDataArrayImagAsLongs, getDataArrayImagAsShorts, getDataArrayReal, getDataArrayReal, getDataArrayRealAsBytes, getDataArrayRealAsDoubles, getDataArrayRealAsFloats, getDataArrayRealAsInts, getDataArrayRealAsLongs, getDataArrayRealAsShorts, getDataArrayTypeNames, getDependentLabels, getDependentVariableDimensions, getDependentVariables, getDimensionLengths, getDimensionLengths, getGraphArrayImagLog10, getGraphArrayRealLog10, getIndependentArrayImag, getIndependentArrayReal, getIndependentLabels, getIndependentScaleImagLog10, getIndependentScaleRealLog10, getIndependentTriplet, getIndependentVariables, getLabels, getLabelsColumn, getTitle, inputFromStream, isArithmeticArray, isArithmeticData, isCompatible, isDependentComplex, isIndependentComplex, isPrimitiveArray, isPrimitiveData, isTriplet, isUniform, maxDependentGraphingValuesImag, maxDependentGraphingValuesReal, maxDependentVariablesImag, maxDependentVariablesReal, maxIndependentScalesImag, maxIndependentScalesReal, maxIndependentVariablesImag, maxIndependentVariablesReal, minDependentGraphingValuesImag, minDependentGraphingValuesReal, minDependentVariablesImag, minDependentVariablesReal, minIndependentScalesImag, minIndependentScalesReal, minIndependentVariablesImag, minIndependentVariablesReal, multiply, outputToStream, resetDependent, resetIndependent, restrictToSubdomain, restrictToSubdomain, setDataArrayImag, setDataArrayReal, setDefaultAxisLabelling, setDependentLabels, setDependentVariableDimensions, setDimensionLengths, setDimensionLengths, setDimensions, setIndependentArrayImag, setIndependentArrayReal, setIndependentLabels, setIndependentTriplet, setIndependentTriplet, setLabels, setTitle, subtract
containerSize, dataExists, deleteFromContainer, getDataContainer, getFromContainer, getSequenceNumber, insertIntoContainer, inspectDataContainer, setDataContainer, setSequenceNumber, updateObsoletePointers
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
inputFromStream, outputToStream
public Curve()
public Curve(int n)
n
- The number of dimensions in which the curve is representedpublic Curve(double[] x, double[] y)
If it is desired to have a different parametrization, use this constructor to create the curve and then use the method setIndependentArrayReal of GraphType to change the parametrization.
x
- A one-dimensional array giving the x-values of points on the curvey
- A one-dimensional array giving the y-values of points on the curvepublic Curve(double[] x, double[] y, double[] z)
If it is desired to have a different parametrization, use this constructor to create the curve and then use the methods setIndependentArrayReal or setIndependentTriplet of GraphType to change the parametrization.
x
- A one-dimensional array giving the x-values of points on the curvey
- A one-dimensional array giving the y-values of points on the curvez
- A one-dimensional array giving the z-values of points on the curvepublic boolean isUniform()
public boolean isTriplet()
Triplet
public int size()
public int length()
public double[] getData(int dv)
dv
- the dimension whose data is requiredpublic double[] getDataImag(int dv)
dv
- the dimension whose data is requiredpublic double[] getDataReal(int dv)
dv
- the dimension whose data is requiredpublic void setDataReal(double[] data, int dv)
data
- The new datadv
- the dimension whose data is setpublic void setData(double[] data, int dv)
data
- The new datadv
- the dimension whose data is setpublic void setDataImag(double[] data, int dv)
data
- The new datadv
- the dimension whose data is setpublic void setData(double[] dataReal, double[] dataImag, int dv)
dataReal
- The real part of the new datadataImag
- The imaginary part of the new datadv
- the dimension whose data is setpublic void initialiseData(int dv)
dv
- the dimension whose data is initializedpublic void initialiseDataReal(int len, int dv)
len
- the length of the data set being initializeddv
- the dimension whose data is setpublic void initialiseDataComplex(int len, int dv)
len
- the length of the data set being initializeddv
- the dimension whose data is setpublic double[] getXArray()
Triplet
public Triplet getXTriplet()
Triplet
public double[] getXImag()
public double[] getXReal()
public double[] getIndependentScaleReal(int dim)
The Graphing method must be careful how it uses this method. The use depends on the dimensionality of the grapher. If it is a 2D grapher, it can display only a two-dimensional projection of the Curve. It can access the data for the two chosen dimensions with either the present method or getGraphArrayReal. Using the present method, the grapher should supply an integer argument equal to the index of the desired dimension.
getIndependentScaleReal
in class GraphType
dim
- The dimension of the Curve that is desiredpublic double[] getIndependentScaleImag(int dim)
The Graphing method must be careful how it uses this method. The use depends on the dimensionality of the grapher. If it is a 2D grapher, it can display only a two-dimensional projection of the Curve. It can access the data for the two chosen dimensions with either the present method or getGraphArrayImag. Using the present method, the grapher should supply an integer argument equal to the index of the desired dimension.
getIndependentScaleImag
in class GraphType
dim
- The dimension of the Curve that is desiredpublic java.lang.Object getGraphArrayReal(int dv)
The Graphing method must be careful how it uses this method. The use depends on the dimensionality of the grapher. If it is a 2D grapher, it can display only a two-dimensional projection of the Curve. It can access the data for the two chosen dimensions with either the present method or getIndependentScaleReal. Using the present method, the grapher should supply an integer argument equal to one less than the index of the desired dimension in Curve. This is an arbitrary shift to make 2D graphers easy to use: they get y-data for the vertical axis by using the present method with argument 0.
getGraphArrayReal
in class GraphType
dv
- One less than the dimension of the Curve that is desiredpublic java.lang.Object getGraphArrayImag(int dv)
The Graphing method must be careful how it uses this method. The use depends on the dimensionality of the grapher. If it is a 2D grapher, it can display only a two-dimensional projection of the Curve. It can access the data for the two chosen dimensions with either the present method or getIndependentScaleImag. Using the present method, the grapher should supply an integer argument equal to one less than the index of the desired dimension in Curve. This is an arbitrary shift to make 2D graphers easy to use: they get y-data for the vertical axis by using the present method with argument 0.
getGraphArrayImag
in class GraphType
dv
- One less than the dimension of the Curve that is desiredpublic void setX(Triplet tr)
tr
- The new dataTriplet
public void setX(java.lang.Object data)
data
- The new data for the independent variablepublic void setX(double[] xReal, double[] xImag)
xReal
- The real part of the independent variablexImag
- The imaginary part of the independent variablepublic boolean testDataModel()
testDataModel
in class GraphType
Triplet
public TrianaType copyMe()
To override, the programmer should not invoke the super.copyMe method. Instead, create an object of the current type and call methods copyData and copyParameters. If these have been written correctly, then they will do the copying. The code should createTool, for type YourType:
YourType y = null; try { y = (YourType)getClass().newInstance(); y.copyData( this ); y.copyParameters( this ); y.setLegend( this.getLegend() ); } catch (IllegalAccessException ee) { System.out.println("Illegal Access: " + ee.getMessage()); } catch (InstantiationException ee) { System.out.println("Couldn't be instantiated: " + ee.getMessage()); } return y;
The copied object's data should be identical to the original. The method here modifies only one item: a String indicating that the object was created as a copy is added to the description StringVector.
public boolean isCompatible(TrianaType obj)
In Curve, this method first tests for compatibility with superior classes, and then (if the input object is a Curve) tests that the input has the same uniformity and same number of dependent variables as the current object. (Independent variable number is tested in GraphType.)
Classes derived from this should over-ride this method with further tests as appropriate. The over-riding method should normally have the first lines
boolean test = super.isCompatible( obj );followed by other tests. If other types not subclassed from GraphType or Const should be allowed to be compatible then other tests must be implemented.
obj
- The data object to be compared with the current one