public abstract class GraphType extends TrianaType implements Arithmetic, AsciiComm
GraphType defines Triana's most general numerical data structures along with methods for reading the data, modifying it, providing information to a graphing object, restricting the data to a sub-domain, and doing element-by- element arithmetic on the data (implementing the Arithmetic interface). The arithmetic methods include for example adding and multiplying by other GraphType data objects and by Const type objects. GraphType implements arithmetic for data arrays of arbitrary dimensionality holding arbitrary primitive arithmetic Java data types (double, int, float, etc.); the data may be real or complex (in which the real and imaginary parts are held in separate arrays). The arithmetic implementation relies heavily on the class methods of FlatArray, which also provides methods that graphical display objects can use for rescaling and translating graphs. GraphType distinguishes between data for dependent and independent variables, both of which may be complex. GraphType's data model is described below.
GraphType is an abstract class, so it cannot be used directly to store data. Rather, "raw data" classes should be derived from GraphType for specific values of dimensions of the data structures. Raw data types derived from GraphType include VectorType (1D array) and MatrixType (2D array), and Curve (1D curve in several dimensions). These permit one to use strong type checking in Units, while losing none of the functionality of GraphType. Therefore, although GraphType provides methods for modifying or replacing data, it does not provide methods for changing the basic dimensionality parameters that determine (i) the number of dimensions in the multi-dimensional arrays used to store data, and (ii) the number of dependent variable arrays.
GraphType also does not provide parameters (auxilliary data) that will be needed for some applications, nor should the "raw" types derived directly from GraphType include extra parameters. It is recommended that types needing new parameters be derived as subclasses of these raw types and that the methods used to manipulate parameters be implemented via Interfaces. Interfaces allow such types to be defined anywhere in the inheritance tree of GraphType, i.e. for any kinds of data structures that are needed. Interfaces already implemented include Signal, Spectral, and Histogramming.
GraphType's data model is designed to allow very general representations of functions and geometical objects. The data represent the values of a number dependentVariables of functions of another number independentVariables of independent variables. The independent variables span the domain of the problem, and they are represented by a set of one-dimensional arrays of doubles (or, to save storage, by Triplets, which are basically iteration counters -- see below).
The data arrays (dependent variables) must each have independentVariables dimensions, but their lengths in each of the dimensions can differ from one another. Thus, there is no requirement that they span the domain. The data arrays can store any kind of data. The data could be primitive data types (such as doubles) or other Java Ojbects, such as colors. The data elements could also be arrays, such as vectors; this would define a vector field over the independent variables. The data can be complex (two similar arrays for each variable), and the independent variables can also be complex.
To use this data model one should think of the independent variables as parameters describing the dependent variables. Thus, for an ordinary graph representing a function of one variable there would be one independent variable and one dependent variable. But to describe a curve that is not a single-valued function, such as a circle in the x-y plane, one would use two dependent variables (x and y) and a single independent variable (distance along the curve). The first would be an instance of VectorType, the second of Curve. A sphere in 3 dimensions would need 3 dependent variables (x, y, and z) depending on two independent variables (the spherical coordinates on the sphere, perhaps).
Often the independent variable in this data model is implicit; it could be just the index of the one-dimensional array of points describing the function of one variable. GraphType does not require that all the values of the independent variable be stored as doubles. Instead, it allows storage of a Triplet. The Triplet class contains three numbers: an integer length, a double starting value and a double step. These can be used to generate the independent variable by iteration. If the independent variable data are not uniformly spaced, however, then they must be stored in GraphType as a double[] array.
GraphType stores its data in the Hashtable called dataContainer that is defined in its super-class TrianaType. The keys used for the Hashtable are defined internally in GraphType, but they do not need to be known to the user. The data are accessed by methods that assign an index to each data set, as if they were stored in an ordered list. If imaginary parts do not exist for certain data then the associated elements are not stored. Parameters defined in this class include arrays of flags and lengths.
GraphType communicates with Units by implementing TrianaType, and with other programs (or computers) by implementing AsciiComm. Types derived from GraphType should call these inherited functions first before implementing their own specific data transfer. The key methods are CopyMe, outputToStream, and inputFromStream. These and the following methods will normally be over-ridden in classes derived from GraphType by methods of the same name that extend their functionality: testDataModel, copyData, copyParameters, and the methods demanded by the Arithmetic Interface -- isCompatible, equals, add, subtract, multiply, divide. Note that GraphType implements the methods of Arithmetic in such a way that they work on any data array that holds numerical data, regardless of its dimension or size. It does this by invoking the utilities of FlatArray. If a GraphType data object contains non-numerical data, such as images, these are ignored by the arithmetic operations.
TrianaType
,
Arithmetic
,
Triplet
,
VectorType
,
MatrixType
,
Curve
,
Serialized FormNOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
GraphType()
Creates a new GraphType that is empty.
|
GraphType(int iv,
int dv)
Creates a new GraphType with specified dimensions and an empty dataContainer hashtable.
|
Modifier and Type | Method and Description |
---|---|
Arithmetic |
add(java.lang.Object obj)
Adds the argument TrianaType to the current object.
|
void |
addToTitle(java.lang.String str)
Appends the argument String str to the existing title String.
|
void |
convertDependentDataArraysToBytes()
Converts all of the arithmetic dependent data from their present format to byte arrays.
|
void |
convertDependentDataArraysToDoubles()
Converts all of the arithmetic dependent data from their present format to double arrays.
|
void |
convertDependentDataArraysToFloats()
Converts all of the arithmetic dependent data from their present format to float arrays.
|
void |
convertDependentDataArraysToInts()
Converts all of the arithmetic dependent data from their present format to int arrays.
|
void |
convertDependentDataArraysToLongs()
Converts all of the arithmetic dependent data from their present format to long arrays.
|
void |
convertDependentDataArraysToShorts()
Converts all of the arithmetic dependent data from their present format to short arrays.
|
protected void |
copyData(TrianaType source)
Copies data held in dataContainer from the argument object to the current object.
|
java.util.Hashtable |
copyLabels()
Returns a Hashtable copy of labels, by value, not by reference.
|
abstract TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
protected void |
copyParameters(TrianaType source)
Copies modifiable parameters from the argument object to the current object.
|
Arithmetic |
divide(java.lang.Object obj)
Divides the argument TrianaType into the current object.
|
boolean |
equals(java.lang.Object obj)
Tests if the argument Object is equal to the current object.
|
java.lang.Class |
getDataArrayClass(int dv)
Returns the Class of the data array (dependent variable) associated with the argument index dv.
|
java.lang.Object |
getDataArrayImag(int dv)
Returns the imaginary part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImag(int dv,
java.lang.Class outClass)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsBytes(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsDoubles(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsFloats(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsInts(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsLongs(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayImagAsShorts(int dv)
Returns the imag part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayReal(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayReal(int dv,
java.lang.Class outClass)
Returns the real part of the array for the dependent variable indexed by dv; if the elements of the array
can be converted to the data type of the given Class (second argument) then they are; if the given Class is an
array, then the method tries to convert to the type of the elements of that array.
|
java.lang.Object |
getDataArrayRealAsBytes(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayRealAsDoubles(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayRealAsFloats(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayRealAsInts(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayRealAsLongs(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.Object |
getDataArrayRealAsShorts(int dv)
Returns the real part of the array for the dependent variable indexed by dv.
|
java.lang.String |
getDataArrayTypeNames(int dv)
Returns the type name of the data array (dependent variable) associated with the argument index dv.
|
java.lang.String |
getDependentLabels(int dv)
Returns a String containing the label to be displayed along the axis associated with the dependent variable
dv.
|
int[] |
getDependentVariableDimensions(int dv)
Returns an int[] containing the lengths of the dimensions of the dependent variable given by the argument
dv.
|
int |
getDependentVariables()
Returns the number of dependent dimensions dependentVariables of the data set.
|
int[] |
getDimensionLengths()
Returns an integer array containing the number of points in each of the independent variable dimensions, numbered
0 to independentVariables - 1.
|
int |
getDimensionLengths(int dim)
Returns the number of domain points in the independent variable dimension given by argument dim.
|
java.lang.Object |
getGraphArrayImag(int dv)
Returns an array containing the imaginary part of the graphing values for the dependent variable indexed by
dv.
|
java.lang.Object |
getGraphArrayImagLog10(int dv)
Returns an array containing the logarithms (base 10) of the imag part of the graphing values for the dependent
variable indexed by dv.
|
java.lang.Object |
getGraphArrayReal(int dv)
Returns an array containing the real part of the graphing values for the dependent variable indexed by dv
as an array of doubles.
|
java.lang.Object |
getGraphArrayRealLog10(int dv)
Returns an array containing the logarithms (base 10) of the real part of the graphing values for the dependent
variable indexed by dv.
|
double[] |
getIndependentArrayImag(int dim)
Returns the imaginary part of the array for the independent variable indexed by dim.
|
double[] |
getIndependentArrayReal(int dim)
Returns the real part of the array for the independent variable indexed by dim.
|
java.lang.String |
getIndependentLabels(int dim)
Returns a String containing the label to be displayed along the axis associated with the independent variable
dim.
|
double[] |
getIndependentScaleImag(int dim)
Returns an array containing the imaginary part of the graphing scale associated with the independent variable
indexed by dim.
|
double[] |
getIndependentScaleImagLog10(int dim)
Returns an array containing the logarithms (base 10) of the imag part of the graphing scale values associated
with the dependent variable indexed by dim.
|
double[] |
getIndependentScaleReal(int dim)
Returns an array containing the real part of the graphing scale associated with the independent variable indexed
by dim.
|
double[] |
getIndependentScaleRealLog10(int dim)
Returns an array containing the logarithms (base 10) of the real part of the graphing scale values associated
with the dependent variable indexed by dim.
|
Triplet |
getIndependentTriplet(int dim)
Returns the Triplet object which specifies how values of the independent variable indexed by dim are
generated.
|
int |
getIndependentVariables()
Returns the number of independent dimensions independentVariables of the data set.
|
java.util.Hashtable |
getLabels()
Returns a Hashtable containing all the labels to be displayed along the axes of the independent and dependent
variables.
|
java.lang.String |
getLabelsColumn()
Returns all the axis labels that have been defined, along with their keys.
|
java.lang.String |
getTitle()
Returns a String containing the title to be written on a displayed graph.
|
void |
inputFromStream(java.io.BufferedReader dis)
Used when Triana types want to be able to create a new data object from ASCII data it receives from a stream.
|
boolean |
isArithmeticArray(int dv)
Returns true if the dependent variable associated with the argument index dv is an array of
primitive Java data types for numerical data: byte, short, int, long, float, or double.
|
boolean |
isArithmeticData(int dv)
Returns true if the dependent variable associated with the argument index dv is an array of
primitive Java arithmetic data types at the level of independentVariables, i.e.
|
boolean |
isCompatible(java.lang.Object obj)
Tests the argument object to determine if it makes sense to perform arithmetic operations between it and the
current object.
|
boolean |
isDependentComplex(int dv)
Returns true if the data associated with the dependent variable dv is complex,
falseotherwise.
|
boolean |
isIndependentComplex(int dim)
Returns true if the data associated with the independent variable dim is complex, false
otherwise.
|
boolean |
isPrimitiveArray(int dv)
Returns true if the dependent variable associated with the argument index dv is an array of
primitive Java data types.
|
boolean |
isPrimitiveData(int dv)
Returns true if the dependent variable associated with the argument index dv is an array of
primitive Java data types at the level of independentVariables.
|
boolean |
isTriplet(int dim)
Returns true if (i) isIndependentComplex returns false for the same argument and (ii) the
independent variable numbered by the argument dim is generated from a Triplet (length,
start, step).
|
boolean |
isUniform(int dim)
Tests to see if the independent variable in the given direction is uniformly sampled.
|
double[] |
maxDependentGraphingValuesImag()
Returns a double[] containing the maximum value of the imaginary part of the graphing values associated with each
of the dependent variables that is an arithmetic data type, as determined by the method isArithmeticData.
|
double[] |
maxDependentGraphingValuesReal()
Returns a double[] containing the maximum value of the real part of the graphing values associated with each of
the dependent variables that is an arithmetic data type, as determined by the method isArithmeticData.
|
double[] |
maxDependentVariablesImag()
Returns a double[] containing the maximum value of the imaginary part of each of the dependent variables that is
an arithmetic data type, as determined by method isArithmeticData.
|
double[] |
maxDependentVariablesReal()
Returns a double[] containing the maximum value of the real part of each of the dependent variables that is an
arithmetic data type, as determined by method isArithmeticData.
|
double[] |
maxIndependentScalesImag()
Returns a double[] containing the largest values of the elements of the imaginary parts of the graphing scales of
all the independent variables.
|
double[] |
maxIndependentScalesReal()
Returns a double[] containing the largest values on the graphing scales of all the independent variables.
|
double[] |
maxIndependentVariablesImag()
Returns a double[] containing the largest values of the elements of the imaginary parts of all the independent
variables.
|
double[] |
maxIndependentVariablesReal()
Returns a double[] containing the largest values of the elements of the real parts of all the independent
variables.
|
double[] |
minDependentGraphingValuesImag()
Returns a double[] containing the minimum value of the imaginary part of the graphing values associated with each
of the dependent variables that is an arithmetic data type, as determined by the method isArithmeticData.
|
double[] |
minDependentGraphingValuesReal()
Returns a double[] containing the minimum value of the real part of the graphing values associated with each of
the dependent variables that is an arithmetic data type, as determined by the method isArithmeticData.
|
double[] |
minDependentVariablesImag()
Returns a double[] containing the minimum value of the imaginary part of each of the dependent variables that is
an arithmetic data type, as determined by method isArithmeticData.
|
double[] |
minDependentVariablesReal()
Returns a double[] containing the minimum value of the real parts of each of the dependent variables that is an
arithmetic data type, as determined by method isArithmeticData.
|
double[] |
minIndependentScalesImag()
Returns a double[] containing the largest values of the elements of the imaginary parts of the graphing scales of
all the independent variables.
|
double[] |
minIndependentScalesReal()
Returns a double[] containing the largest values on the graphing scales of all the independent variables.
|
double[] |
minIndependentVariablesImag()
Returns a double[] containing the smallest values elements of the imaginary parts of all the independent
variables.
|
double[] |
minIndependentVariablesReal()
Returns a double[] containing the smallest values of the elements of the real parts of all the independent
variables.
|
Arithmetic |
multiply(java.lang.Object obj)
Multiplies the argument TrianaType into the current object.
|
void |
outputToStream(java.io.PrintWriter dos)
Used when Triana types want to be able to send ASCII data to other programs using strings.
|
void |
resetDependent(int dv)
Checks the dependent data in the given dimension for consistency and resets all the boolean flags etc.
|
void |
resetIndependent(int dim)
Checks the independent data in the given dimension for consistency and resets all the boolean flags etc.
|
GraphType |
restrictToSubdomain(int dim,
double from,
double to)
Returns a new GraphType object with data restricted to a subdomain of one of the independent variables.
|
GraphType |
restrictToSubdomain(int dim,
int from,
int to)
Returns a new GraphType object with data restricted to a subdomain of one of the independent variables.
|
void |
setDataArrayImag(java.lang.Object A,
int dv)
Assigns the appropriately dimensioned argument array A to the storage location in this data object for the
imaginary part of the data associated with independent variable dv.
|
void |
setDataArrayReal(java.lang.Object A,
int dv)
Assigns the appropriately dimensioned argument array A to the storage location in this data object for the
real part of the data associated with dependent variable dv.
|
void |
setDefaultAxisLabelling()
Added by I.
|
void |
setDependentLabels(int dv,
java.lang.String lbl)
Sets the axis label for the dependent (data) variable dim to the argument String l.
|
void |
setDependentVariableDimensions(int[] size,
int dv)
Sets an int[] into the ArrayList containing the lengths of the dimensions of the dependent variable given by the
argument dv.
|
void |
setDimensionLengths(int[] dimLen)
Sets the integer array containing the number of domain points in each of the independent variable dimensions to
the elements of the argument dimLen.
|
void |
setDimensionLengths(int length,
int dim)
Sets the number of domain points in the independent variable dimension given by argument dim to the value
given by the argument length.
|
void |
setDimensions(int iv,
int dv)
Sets up the Graph Type to the specified dimensions and an empty dataContainer hashtable.
|
void |
setIndependentArrayImag(double[] A,
int dim)
Assigns the argument array of doubles A to the storage location in this data object for the imaginary part
of the data associated with independent variable dim.
|
void |
setIndependentArrayReal(double[] A,
int dim)
Assigns the argument array of doubles A to the storage location in this data object for the real part of
the data associated with independent variable dim.
|
void |
setIndependentLabels(int dim,
java.lang.String lbl)
Sets the axis label for the independent variable dim to the argument String l.
|
void |
setIndependentTriplet(int len,
double strt,
double stp,
int dim)
Sets the argument values into a new Triplet object and then sets this object to be the data object for uniformly
spaced values of the independent variable given by dim: length is given by the argument len,
starting value by the argument strt, and the step by the argument stp.
|
void |
setIndependentTriplet(Triplet tr,
int dim)
Sets the Triplet object which specifies how values of the independent variable indexed by dim to the
argument tr.
|
void |
setLabels(java.util.Hashtable newLab)
Sets the axis labels Hashtable, by reference.
|
void |
setTitle(java.lang.String t)
Sets the title String to the argument String t by reference.
|
Arithmetic |
subtract(java.lang.Object obj)
Subtracts the argument TrianaType from the current object.
|
boolean |
testDataModel()
Tests to make sure this object obeys the GraphType data model.
|
containerSize, dataExists, deleteFromContainer, getDataContainer, getFromContainer, getSequenceNumber, insertIntoContainer, inspectDataContainer, setDataContainer, setSequenceNumber, updateObsoletePointers
public GraphType()
public GraphType(int iv, int dv)
iv
- The number of independent variables (must be positive)dv
- The number of dependent variables (must be positive)public void setDefaultAxisLabelling()
public void setDimensions(int iv, int dv)
iv
- The number of independent variables (must be positive)dv
- The number of dependent variables (must be positive)public boolean testDataModel()
This method returns true if the data sets exist, if the independent variables are determined either by Triplets or by one-dimensional arrays of doubles, if the dependent data arrays have independentVariables dimensions, and if the lengths of the dimensions of the dependent variable arrays is the same as the lengths of the independent variable data sets. Otherwise it returns false.
Triplet
public void resetIndependent(int dim)
dim
- The dimension being resetpublic void resetDependent(int dv)
dv
- The index of the dependent data being resetpublic boolean isIndependentComplex(int dim)
If there is no data array (i.e. if the data are generated by a Triplet -- see the method isTriplet below) then this returns false.
dim
- The number indicating the variable in questionTriplet
public boolean isDependentComplex(int dv)
dv
- The number indicating the variable in questionpublic boolean isTriplet(int dim)
dim
- The independent variable dimensionTriplet
public java.lang.String getDataArrayTypeNames(int dv)
dv
- The dependent variable dimensionpublic java.lang.Class getDataArrayClass(int dv)
dv
- The dependent variable dimensionpublic boolean isPrimitiveArray(int dv)
dv
- The index of the dependent variable being inspectedpublic boolean isPrimitiveData(int dv)
This can be used to determine if the data are to be interpreted as arrays of arrays, such as vector fields.
dv
- The index of the dependent variable being inspectedpublic boolean isArithmeticArray(int dv)
public boolean isArithmeticData(int dv)
dv
- The index of the dependent variable being inspectedpublic boolean isUniform(int dim)
public int getIndependentVariables()
public int getDependentVariables()
public int getDimensionLengths(int dim)
dim
- The number indicating the variable in questionpublic int[] getDimensionLengths()
public int[] getDependentVariableDimensions(int dv)
dv
- The dependent variable under considerationpublic Triplet getIndependentTriplet(int dim)
dim
- The spatial dimensionTriplet
public double[] getIndependentArrayReal(int dim)
dim
- The independent variable dimensionTriplet
public double[] getIndependentScaleReal(int dim)
dim
- The independent variable dimensionpublic double[] getIndependentScaleRealLog10(int dim)
dim
- The dependent variable dimensionpublic double[] getIndependentArrayImag(int dim)
dim
- The independent variable dimensionTriplet
public double[] getIndependentScaleImag(int dim)
dim
- The independent variable dimensionpublic double[] getIndependentScaleImagLog10(int dim)
dim
- The dependent variable dimensionpublic java.lang.Object getDataArrayReal(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsDoubles(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsFloats(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsInts(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsLongs(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsShorts(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayRealAsBytes(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayReal(int dv, java.lang.Class outClass)
dv
- The dependent variable dimensionoutClass
- The desired type of the output elementspublic java.lang.Object getGraphArrayReal(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getGraphArrayRealLog10(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImag(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsDoubles(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsFloats(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsInts(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsLongs(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsShorts(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImagAsBytes(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getDataArrayImag(int dv, java.lang.Class outClass)
dv
- The dependent variable dimensionoutClass
- The desired type of the output elementspublic void convertDependentDataArraysToDoubles()
public void convertDependentDataArraysToFloats()
public void convertDependentDataArraysToInts()
public void convertDependentDataArraysToLongs()
public void convertDependentDataArraysToShorts()
public void convertDependentDataArraysToBytes()
public java.lang.Object getGraphArrayImag(int dv)
dv
- The dependent variable dimensionpublic java.lang.Object getGraphArrayImagLog10(int dv)
dv
- The dependent variable dimensionpublic java.lang.String getTitle()
public java.lang.String getIndependentLabels(int dim)
dim
- The spatial dimensionpublic java.lang.String getDependentLabels(int dv)
dv
- The index of the dependent variablepublic java.util.Hashtable getLabels()
public java.lang.String getLabelsColumn()
public java.util.Hashtable copyLabels()
public void setDimensionLengths(int length, int dim)
length
- The number of values of this variabledim
- The number indicating the independent variable in questionpublic void setDimensionLengths(int[] dimLen)
dimLen
- An array containing the lengths of the independent variable dimensionspublic void setDependentVariableDimensions(int[] size, int dv)
size
- The array of the lengths of the dimensions of the variabledv
- The dependent variable under considerationpublic void setIndependentTriplet(Triplet tr, int dim)
tr
- The Triplet to be used to repesent data for this dimensiondim
- The independent variable dimensionTriplet
public void setIndependentTriplet(int len, double strt, double stp, int dim)
len
- The length of the data set to be represented by a Tripletstrt
- The starting value of the uniformly spaced datastp
- The step between the uniformly spaced data valuesdim
- The independent variable dimensionTriplet
public void setIndependentArrayReal(double[] A, int dim)
A
- The (real part of the) data to be stored in this independent variabledim
- The spatial dimensionTriplet
public void setIndependentArrayImag(double[] A, int dim)
A
- The (real part of the) data to be stored in this independent variabledim
- The spatial dimensionTriplet
public void setDataArrayReal(java.lang.Object A, int dv)
Warning to programmers: the independent variables associated with the array are not automatically reset when a new array is stored. This is because it is not possible to know whether the independent variable should be a uniformly spaced index starting at zero, or something more complicated. Therefore users should be sure that they call setIndependentTriplet or setIndependentArrayReal if the new dependent array has a different size from the previous one. However, to catch the most frequent case, the method resetDependent will reset the independent variable in one situation, where the previous dependent variable was a Triplet and the new dependent array has a size in that direction that is different from the length of the Triplet. Then the independent variable is reset to a Triplet of the correct length, starting at zero with step 1.
A
- The (real part of the) data to be stored in this dependent variabledv
- The dimension in the data space (dependent variable)public void setDataArrayImag(java.lang.Object A, int dv)
Warning to programmers: the independent variables associated with the array are not automatically reset when a new array is stored. This is because it is not possible to know whether the independent variable should be a uniformly spaced index starting at zero, or something more complicated. Therefore users should be sure that they call setIndependentTriplet or setIndependentArrayReal if the new dependent array has a different size from the previous one. However, to catch the most frequent case, the method resetDependent will reset the independent variable in one situation, where the previous dependent variable was a Triplet and the new dependent array has a size in that direction that is different from the length of the Triplet. Then the independent variable is reset to a Triplet of the correct length, starting at zero with step 1.
A
- The imaginary part of the data to be stored in this dependent variabledv
- The dimension of the data space (dependent variable)public void setTitle(java.lang.String t)
t
- The new graph titlepublic void addToTitle(java.lang.String str)
str
- The String to be appendedpublic void setIndependentLabels(int dim, java.lang.String lbl)
dim
- The independent variable indexlbl
- The new axis label for this variablepublic void setDependentLabels(int dv, java.lang.String lbl)
dv
- The data variable indexlbl
- The new axis label for this variablepublic void setLabels(java.util.Hashtable newLab)
newLab
- The new axis labelspublic abstract 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.
copyMe
in class TrianaType
protected void copyData(TrianaType source)
However, a derived type that defines a dependent variable array of reference types (eg colors, streams, hashtables, ...) MUST implement copy-by-value in its own over-riding method copyData. The over-riding method should first invoke
super.copyData( source )and then proceed with remaining copies. This method is protected so that it cannot be called except by objects that inherit from this one. It is called by copyMe.
copyData
in class TrianaType
source
- Object that contains the data to be copied.protected void copyParameters(TrianaType source)
copyParameters
in class TrianaType
source
- Object that contains the data to be copied.public void outputToStream(java.io.PrintWriter dos) throws java.io.IOException
This method takes care of the output of data held in dataContainer in arrays of primitive Java data types (double, int, boolean, etc) and of parameters defined in GraphType. It must be overridden in every subclass that defines new parameters or dependent variable arrays holding reference types at their lowest level. The problem of representing such reference types as ASCII data is left to the programmer! The overriding method should first call
super.outputToStream( dos )to get output from superior classes, and then new parameters and/or arrays of reference values defined for the current subclass must be output.
Unlike copyData and copyParameters, this method explicitly outputs the boolean and other arrays that have no set... methods. Although this is not necessary for the arrays to be reconstructed, it is useful because it allows the output stream to be written to a text editor for inspecting all the contents of the object.
Programmers must ensure that all parameters are written to output before the data arrays that they describe, so that the input method can correctly dimension and createTool the data.outputToStream
in interface AsciiComm
dos
- The data output streamjava.io.IOException
public void inputFromStream(java.io.BufferedReader dis) throws java.io.IOException
This method must be overridden in every subclass that defines new data or parameters. The overriding method should first call
super.inputFromStream(dis)to get input from superior classes, and then new parameters defined for the current subclass must be input. Data arrays that contain only primitive Java data types will be correctly input by the methods implemented here in GraphType, but programmers who define dependent variable data arrays that contain reference types will have to take care of ASCII I/O for these types themselves in the over-riding method. The over-riding method must be written to createTool data that are in the format created by outputToStream.
inputFromStream
in interface AsciiComm
dis
- The data input streamjava.io.IOException
public double[] maxIndependentVariablesReal()
public double[] maxIndependentVariablesImag()
public double[] maxIndependentScalesReal()
public double[] maxIndependentScalesImag()
public double[] minIndependentVariablesReal()
public double[] minIndependentVariablesImag()
public double[] minIndependentScalesReal()
public double[] minIndependentScalesImag()
public double[] maxDependentVariablesReal()
public double[] maxDependentVariablesImag()
public double[] maxDependentGraphingValuesReal()
public double[] maxDependentGraphingValuesImag()
public double[] minDependentVariablesReal()
public double[] minDependentVariablesImag()
public double[] minDependentGraphingValuesReal()
public double[] minDependentGraphingValuesImag()
public GraphType restrictToSubdomain(int dim, int from, int to)
dim
- The index of the independent variable being restrictedfrom
- The starting value of the new domainto
- The ending value of the new domainpublic GraphType restrictToSubdomain(int dim, double from, double to)
dim
- The index of the independent variable being restrictedfrom
- The starting value of the new domainto
- The ending value of the new domainpublic boolean isCompatible(java.lang.Object obj)
In GraphType, this method tests that the given Object is either another GraphType or a Const. If it is a GraphType Object, then the method tests that the number of independent dimensions and their sizes are the same. It does not inspect the dependent data or check the values of the independent variables. If the given Object is a Const, then it is automatically compatible.
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.
isCompatible
in interface Arithmetic
obj
- The data object to be compared with the current onepublic boolean equals(java.lang.Object obj)
In GraphType, this method inspects the data arrays and independent variables. The number of dependent variables and the values of the other parameters must be equal. The independent data values must also be equal. The dependent data arrays are then inspected, and all arrays of Java primitive data types are required to have equal elements. Arrays of non-primitive data types must have the same type, but are not tested further for equality.
This method must be over-ridden in derived types. In a derived type called xxx the method should begin
if ( !( obj instanceof xxx ) ) return false; if ( !isCompatible( obj ) ) return false;followed by tests that are specific to type xxx (testing its own parameters) and then (if all tests have been passed) the last line should be
return super.equals( obj );This line invokes the other equals methods up the chain to GraphType. Each superior object tests its own parameters. If subclasses implement dependent data that are not arrays of primitives, then they should implement suitable tests of equality for these in this method.
equals
in interface Arithmetic
equals
in class java.lang.Object
obj
- The data object to be compared with the current onepublic Arithmetic add(java.lang.Object obj) throws java.lang.ClassCastException
In the GraphType method, addition is performed if the given Object is a Const or another GraphType. In each case only data of the current object that are of an arithmetic nature are added to. When the given object is a GraphType, the addition is done between corresponding data sets, i.e. sets that have the same index when they are stored and retrieved. (If the given TrianaType passes the isCompatible test, then these sets are guaranteed to exist.) When the given TrianaType is a Const, its value is added to each element of all arithmetic data sets.
add
in interface Arithmetic
obj
- The new data object to be added to the current onejava.lang.ClassCastException
- if addition with the specified object is not validpublic Arithmetic subtract(java.lang.Object obj) throws java.lang.ClassCastException
In the GraphType method, subtraction is performed if the given Object is a Const or another GraphType. In each case only data of the current object that are of an arithmetic nature are subtracted from. When the given object is a GraphType, the subtraction is done between corresponding data sets, i.e. sets that have the same index when they are stored and retrieved. (If the given TrianaType passes the isCompatible test, then these sets are guaranteed to exist.) When the given TrianaType is a Const, its value is subtracted from each element of all arithmetic data sets.
subtract
in interface Arithmetic
obj
- The new data object to be subtracted from the current onejava.lang.ClassCastException
- if subtraction with the specified object is not validpublic Arithmetic multiply(java.lang.Object obj) throws java.lang.ClassCastException
In the GraphType method, multiplication is performed if the given Object is a Const or another GraphType. In each case only data of the current object that are of an arithmetic nature are multiplied. When the given object is a GraphType, the multiplication is done between corresponding data sets, i.e. sets that have the same index when they are stored and retrieved. (If the given TrianaType passes the isCompatible test, then these sets are guaranteed to exist.) When the given TrianaType is a Const, its value is multiplied into each element of all arithmetic data sets.
multiply
in interface Arithmetic
obj
- The new data object to be multiplied into the current onejava.lang.ClassCastException
- if multiplication with the specified object is not validpublic Arithmetic divide(java.lang.Object obj) throws java.lang.ClassCastException
In the GraphType method, division is performed if the given Object is a Const or another GraphType. In each case only data of the current object that are of an arithmetic nature are divided. When the given object is a GraphType, the division is done between corresponding data sets, i.e. sets that have the same index when they are stored and retrieved. (If the given TrianaType passes the isCompatible test, then these sets are guaranteed to exist.) When the given TrianaType is a Const, its value is divided into each element of all arithmetic data sets.
divide
in interface Arithmetic
obj
- The new data object to be divided into the current onejava.lang.ClassCastException
- if division with the specified object is not valid