Class TypeMap

    • Method Detail

      • getSampleDimensionType

        public static SampleDimensionType getSampleDimensionType​(Range<?> range)
        Returns the smallest sample dimension type capable to hold the specified range of values.
        Parameters:
        range - The range of values.
        Returns:
        The smallest sample dimension type for the specified range.
      • getSampleDimensionType

        public static SampleDimensionType getSampleDimensionType​(double min,
                                                                 double max)
        Returns the smallest sample dimension type capable to hold the specified range of values. An heuristic approach is used for non-integer values.
        Parameters:
        min - The lower value, inclusive.
        max - The upper value, inclusive as well.
        Returns:
        The smallest sample dimension type for the specified range.
      • getSampleDimensionType

        public static SampleDimensionType getSampleDimensionType​(long min,
                                                                 long max)
        Returns the smallest sample dimension type capable to hold the specified range of values.
        Parameters:
        min - The lower value, inclusive.
        max - The upper value, inclusive as well.
        Returns:
        The smallest sample dimension type for the specified range.
      • getSampleDimensionType

        public static SampleDimensionType getSampleDimensionType​(SampleModel model,
                                                                 int band)
                                                          throws IllegalArgumentException
        Returns the sample dimension type for the specified sample model and band number. If the sample model use an undefined data type, then this method returns null.
        Parameters:
        model - The sample model.
        band - The band to query.
        Returns:
        The sample dimension type for the specified sample model and band number.
        Throws:
        IllegalArgumentException - if the band number is not in the valid range.
      • isSigned

        public static boolean isSigned​(SampleDimensionType type)
        Returns true for signed sample type.
      • isFloatingPoint

        public static boolean isFloatingPoint​(SampleDimensionType type)
        Returns true for floating-point data type.
      • getPositiveRange

        public static NumberRange<? extends Number> getPositiveRange​(SampleDimensionType type)
        Returns the range of positive sample values (excluding 0). This range is non-null only for unsigned type. A range excluding 0 is sometime usefull when the 0 value is reserved for a "no data" category.
      • wrapSample

        public static Number wrapSample​(double value,
                                        SampleDimensionType type,
                                        boolean allowWidening)
                                 throws IllegalArgumentException
        Wraps the specified value into a number of the specified data type. If the value can't fit in the specified type, then a wider type is choosen unless allowWidening is false.
        Parameters:
        value - The value to wrap in a Number object.
        type - A constant from the SampleDimensionType code list.
        allowWidening - true if this method is allowed to returns a wider type than the usual one for the specified type.
        Returns:
        The value as a Number.
        Throws:
        IllegalArgumentException - if type is not a recognized constant.
        IllegalArgumentException - if allowWidening is false and the specified value can't fit in the specified sample type.
      • getColorInterpretation

        public static ColorInterpretation getColorInterpretation​(ColorModel model,
                                                                 int band)
                                                          throws IllegalArgumentException
        Returns the color interpretation code for the specified color model and band number.
        Parameters:
        model - The color model.
        band - The band to query.
        Returns:
        The code for the specified color model and band number.
        Throws:
        IllegalArgumentException - if the band number is not in the valid range.