Package de.gsi.dataset.spi
Class DataSetBuilder
- java.lang.Object
-
- de.gsi.dataset.spi.DataSetBuilder
-
public class DataSetBuilder extends java.lang.ObjectHelps allocating new DataSets in a flexible and efficient way. Values, Errors and Metadata can be added along with requirements for the resulting DataSet. Values are automatically converted between float and double if needed.Currently the builder generates the following DataSet types:
- dim:2, useFloat=false, errors=false:
DefaultDataSet - dim:2, useFloat=false, errors=true:
DefaultErrorDataSet - dim:2, useFloat=true, errors=false:
FloatDataSet - dim:3+, useFloat=false, errors=false:
MultiDimDoubleDataSet - All other combinations throw a
UnsupportedOperationException
- Author:
- Alexander Krimm
- dim:2, useFloat=false, errors=false:
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Integer,AxisDescription>axisDescriptionsprotected java.util.Map<java.lang.Integer,java.lang.String>dataLabelsprotected java.util.Map<java.lang.Integer,java.lang.String>dataStylesprotected java.util.List<java.lang.String>errorListprotected java.util.Map<java.lang.Integer,double[]>errorsNegprotected java.util.Map<java.lang.Integer,float[]>errorsNegFloatprotected java.util.Map<java.lang.Integer,double[]>errorsPosprotected java.util.Map<java.lang.Integer,float[]>errorsPosFloatprotected java.util.List<java.lang.String>infoListprotected int[]initialCapacityprotected java.util.Map<java.lang.String,java.lang.String>metaInfoMapprotected java.lang.Stringnameprotected java.util.Map<java.lang.Integer,double[]>valuesprotected java.util.Map<java.lang.Integer,float[]>valuesFloatprotected java.util.List<java.lang.String>warningList
-
Constructor Summary
Constructors Constructor Description DataSetBuilder()default DataSet factoryDataSetBuilder(java.lang.String dataSetName)DataSet factory with data set name
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddDataLabelStyleMap(DataSet dataSet)protected voidaddDataRanges(DataSet dataSet)protected voidaddMetaData(DataSet dataSet)DataSetbuild()<T extends DataSet>
Tbuild(java.lang.Class<T> clazz)Tries to build a DataSet of the specified typeprotected DataSetbuildRawDataSet(java.lang.String dsName, int dim, int[] size)DataSetBuildersetAxisMax(int dimension, double value)DataSetBuildersetAxisMin(int dimension, double value)DataSetBuildersetAxisName(int dimension, java.lang.String name)DataSetBuildersetAxisUnit(int dimension, java.lang.String unit)DataSetBuildersetDataLabelMap(java.util.Map<java.lang.Integer,java.lang.String> map)DataSetBuildersetDataStyleMap(java.util.Map<java.lang.Integer,java.lang.String> map)DataSetBuildersetDimension(int nDims)DataSetBuildersetEnableErrors(boolean enableErrors)Determines wether an error DataSet should be returned.DataSetBuildersetInitalCapacity(int... newInitialCapacity)Sets the initial size of the dataset.DataSetBuildersetMetaErrorList(java.lang.String... errors)DataSetBuildersetMetaInfoList(java.lang.String... infos)DataSetBuildersetMetaInfoMap(java.util.Map<java.lang.String,java.lang.String> map)DataSetBuildersetMetaWarningList(java.lang.String... warning)DataSetBuildersetName(java.lang.String name)DataSetBuildersetNegError(int dimIndex, double[] errors)DataSetBuildersetNegError(int dimIndex, float[] errors)DataSetBuildersetNegErrorNoCopy(int dimIndex, double[] errors)DataSetBuildersetNegErrorNoCopy(int dimIndex, float[] errors)DataSetBuildersetPosError(int dimIndex, double[] errors)DataSetBuildersetPosError(int dimIndex, float[] errors)DataSetBuildersetPosErrorNoCopy(int dimIndex, double[] errors)DataSetBuildersetPosErrorNoCopy(int dimIndex, float[] errors)DataSetBuildersetUseFloat(boolean useFloat)DataSetBuildersetValues(int dimIndex, double[] values)DataSetBuildersetValues(int dimIndex, double[][] values)Convenience function to use data given as nested arrays.DataSetBuildersetValues(int dimIndex, float[] values)DataSetBuildersetValuesNoCopy(int dimIndex, double[] values)DataSetBuildersetValuesNoCopy(int dimIndex, float[] values)DataSetBuildersetXNegError(double[] errors)Deprecated.DataSetBuildersetXNegErrorNoCopy(double[] errors)Deprecated.DataSetBuildersetXPosError(double[] errors)Deprecated.Use#setPosError(DataSet.DIM_X, values)insteadDataSetBuildersetXPosErrorNoCopy(double[] errors)Deprecated.Use#setPosErrorNoCopy(DataSet.DIM_X, values)insteadDataSetBuildersetXValues(double[] values)Deprecated.Use#setValues(DataSet.DIM_X, values)insteadDataSetBuildersetXValuesNoCopy(double[] values)Deprecated.Use#setValuesNoCopy(DataSet.DIM_X, values)insteadDataSetBuildersetYNegError(double[] errors)Deprecated.DataSetBuildersetYNegErrorNoCopy(double[] errors)Deprecated.DataSetBuildersetYPosError(double[] errors)Deprecated.Use#setPosError(DataSet.DIM_Y, values)insteadDataSetBuildersetYPosErrorNoCopy(double[] errors)Deprecated.Use#setPosErrorNoCopy(DataSet.DIM_Y, values)insteadDataSetBuildersetYValues(double[] values)Deprecated.Use#setValues(DataSet.DIM_Y, values)insteadDataSetBuildersetYValuesNoCopy(double[] values)Deprecated.Use#setValuesNoCopy(DataSet.DIM_Y, values)instead
-
-
-
Field Detail
-
name
protected java.lang.String name
-
values
protected java.util.Map<java.lang.Integer,double[]> values
-
errorsPos
protected java.util.Map<java.lang.Integer,double[]> errorsPos
-
errorsNeg
protected java.util.Map<java.lang.Integer,double[]> errorsNeg
-
valuesFloat
protected java.util.Map<java.lang.Integer,float[]> valuesFloat
-
errorsPosFloat
protected java.util.Map<java.lang.Integer,float[]> errorsPosFloat
-
errorsNegFloat
protected java.util.Map<java.lang.Integer,float[]> errorsNegFloat
-
initialCapacity
protected int[] initialCapacity
-
infoList
protected java.util.List<java.lang.String> infoList
-
warningList
protected java.util.List<java.lang.String> warningList
-
errorList
protected java.util.List<java.lang.String> errorList
-
metaInfoMap
protected java.util.Map<java.lang.String,java.lang.String> metaInfoMap
-
dataLabels
protected java.util.Map<java.lang.Integer,java.lang.String> dataLabels
-
dataStyles
protected java.util.Map<java.lang.Integer,java.lang.String> dataStyles
-
axisDescriptions
protected java.util.Map<java.lang.Integer,AxisDescription> axisDescriptions
-
-
Method Detail
-
addDataLabelStyleMap
protected void addDataLabelStyleMap(DataSet dataSet)
-
addDataRanges
protected void addDataRanges(DataSet dataSet)
-
addMetaData
protected void addMetaData(DataSet dataSet)
-
build
public DataSet build()
- Returns:
- The requested DataSet
-
build
public <T extends DataSet> T build(java.lang.Class<T> clazz)
Tries to build a DataSet of the specified type- Type Parameters:
T- The DataSet return type- Parameters:
clazz- type of the return value- Returns:
- The initialized DataSet of type T
-
buildRawDataSet
protected DataSet buildRawDataSet(java.lang.String dsName, int dim, int[] size)
-
setAxisMax
public DataSetBuilder setAxisMax(int dimension, double value)
-
setAxisMin
public DataSetBuilder setAxisMin(int dimension, double value)
-
setAxisName
public DataSetBuilder setAxisName(int dimension, java.lang.String name)
-
setAxisUnit
public DataSetBuilder setAxisUnit(int dimension, java.lang.String unit)
-
setDataLabelMap
public DataSetBuilder setDataLabelMap(java.util.Map<java.lang.Integer,java.lang.String> map)
-
setDataStyleMap
public DataSetBuilder setDataStyleMap(java.util.Map<java.lang.Integer,java.lang.String> map)
-
setMetaErrorList
public DataSetBuilder setMetaErrorList(java.lang.String... errors)
-
setMetaInfoList
public DataSetBuilder setMetaInfoList(java.lang.String... infos)
-
setMetaInfoMap
public DataSetBuilder setMetaInfoMap(java.util.Map<java.lang.String,java.lang.String> map)
-
setMetaWarningList
public DataSetBuilder setMetaWarningList(java.lang.String... warning)
-
setName
public final DataSetBuilder setName(java.lang.String name)
-
setNegError
public DataSetBuilder setNegError(int dimIndex, double[] errors)
-
setNegError
public final DataSetBuilder setNegError(int dimIndex, float[] errors)
-
setNegErrorNoCopy
public DataSetBuilder setNegErrorNoCopy(int dimIndex, double[] errors)
-
setNegErrorNoCopy
public DataSetBuilder setNegErrorNoCopy(int dimIndex, float[] errors)
-
setPosError
public final DataSetBuilder setPosError(int dimIndex, double[] errors)
- Parameters:
dimIndex- The dimension index this error is used forerrors- double array with the errors (will only be copied if double DataSet is requested)- Returns:
- itself for method chaining
-
setPosError
public final DataSetBuilder setPosError(int dimIndex, float[] errors)
- Parameters:
dimIndex- The dimension index this error is used forerrors- float array with the errors (will only be copied if double DataSet is requested)- Returns:
- itself for method chaining
-
setPosErrorNoCopy
public final DataSetBuilder setPosErrorNoCopy(int dimIndex, double[] errors)
- Parameters:
dimIndex- The dimension index this error is used forerrors- double array with the errors (will only be copied if double DataSet is requested)- Returns:
- itself for method chaining
-
setPosErrorNoCopy
public final DataSetBuilder setPosErrorNoCopy(int dimIndex, float[] errors)
- Parameters:
dimIndex- The dimension index this error is used forerrors- float array with the errors (will only be copied if double DataSet is requested)- Returns:
- itself for method chaining
-
setValues
public final DataSetBuilder setValues(int dimIndex, double[] values)
- Parameters:
dimIndex- the dim index the data is for.values- double array with data for the x dimension (will be copied)- Returns:
- itself for method chaining
-
setValues
public final DataSetBuilder setValues(int dimIndex, float[] values)
- Parameters:
dimIndex- the dim index the data is for.values- double array with data for the x dimension (will be copied)- Returns:
- itself for method chaining
-
setValues
public final DataSetBuilder setValues(int dimIndex, double[][] values)
Convenience function to use data given as nested arrays. Converts the nested array to a linear strided array.- Parameters:
dimIndex- the dim index the data is for.values- double[][] array with data for the x dimension- Returns:
- itself for method chaining
-
setValuesNoCopy
public DataSetBuilder setValuesNoCopy(int dimIndex, double[] values)
- Parameters:
dimIndex- the dim index the data is for.values- double array with data for the x dimension- Returns:
- itself for method chaining
-
setValuesNoCopy
public DataSetBuilder setValuesNoCopy(int dimIndex, float[] values)
- Parameters:
dimIndex- the dim index the data is for.values- float array with data for the x dimension- Returns:
- itself for method chaining
-
setDimension
public DataSetBuilder setDimension(int nDims)
- Parameters:
nDims- the number of dimensions of the dataSet to build- Returns:
- itself for method chaining
-
setEnableErrors
public DataSetBuilder setEnableErrors(boolean enableErrors)
Determines wether an error DataSet should be returned. Note that all setError* functions implicitly set this to true.- Parameters:
enableErrors- whether to build a data set with errors- Returns:
- itself for method chaining
-
setUseFloat
public DataSetBuilder setUseFloat(boolean useFloat)
- Parameters:
useFloat- whether to return a float DataSet- Returns:
- itself for method chaining
-
setInitalCapacity
public DataSetBuilder setInitalCapacity(int... newInitialCapacity)
Sets the initial size of the dataset. A value for each dimension can be specified. If the number of dimensions exceeds the given sizes, the last one will be used. This means, that you can use a single value for a data set with the same number of data points in each dimension.- Parameters:
newInitialCapacity- varArgs sizes for the first n dimensions- Returns:
- itself for method chaining
-
setXValuesNoCopy
@Deprecated public DataSetBuilder setXValuesNoCopy(double[] values)
Deprecated.Use#setValuesNoCopy(DataSet.DIM_X, values)instead- Parameters:
values- double array with data for the x dimension- Returns:
- itself for method chaining
-
setYValuesNoCopy
@Deprecated public DataSetBuilder setYValuesNoCopy(double[] values)
Deprecated.Use#setValuesNoCopy(DataSet.DIM_Y, values)instead- Parameters:
values- double array with data for the y dimension- Returns:
- itself for method chaining
-
setXValues
@Deprecated public DataSetBuilder setXValues(double[] values)
Deprecated.Use#setValues(DataSet.DIM_X, values)instead- Parameters:
values- double array with data for the x dimension- Returns:
- itself for method chaining
-
setYValues
@Deprecated public DataSetBuilder setYValues(double[] values)
Deprecated.Use#setValues(DataSet.DIM_Y, values)instead- Parameters:
values- double array with data for the y dimension- Returns:
- itself for method chaining
-
setXPosErrorNoCopy
@Deprecated public DataSetBuilder setXPosErrorNoCopy(double[] errors)
Deprecated.Use#setPosErrorNoCopy(DataSet.DIM_X, values)instead- Parameters:
errors- double array with data for the x dimension positive error- Returns:
- itself for method chaining
-
setYPosErrorNoCopy
@Deprecated public DataSetBuilder setYPosErrorNoCopy(double[] errors)
Deprecated.Use#setPosErrorNoCopy(DataSet.DIM_Y, values)instead- Parameters:
errors- double array with data for the y dimension positive error- Returns:
- itself for method chaining
-
setXPosError
@Deprecated public DataSetBuilder setXPosError(double[] errors)
Deprecated.Use#setPosError(DataSet.DIM_X, values)instead- Parameters:
errors- double array with data for the x dimension positive error- Returns:
- itself for method chaining
-
setYPosError
@Deprecated public DataSetBuilder setYPosError(double[] errors)
Deprecated.Use#setPosError(DataSet.DIM_Y, values)instead- Parameters:
errors- double array with data for the y dimension positive error- Returns:
- itself for method chaining
-
setXNegErrorNoCopy
@Deprecated public DataSetBuilder setXNegErrorNoCopy(double[] errors)
Deprecated.
-
setYNegErrorNoCopy
@Deprecated public DataSetBuilder setYNegErrorNoCopy(double[] errors)
Deprecated.
-
setXNegError
@Deprecated public DataSetBuilder setXNegError(double[] errors)
Deprecated.
-
setYNegError
@Deprecated public DataSetBuilder setYNegError(double[] errors)
Deprecated.
-
-