Class DataSetBuilder


  • public class DataSetBuilder
    extends java.lang.Object
    Helps 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:

    Author:
    Alexander Krimm
    • 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
    • Constructor Detail

      • DataSetBuilder

        public DataSetBuilder()
        default DataSet factory
      • DataSetBuilder

        public DataSetBuilder​(java.lang.String dataSetName)
        DataSet factory with data set name
        Parameters:
        dataSetName - data set name
    • 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 for
        errors - 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 for
        errors - 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 for
        errors - 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 for
        errors - 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