Enum DataType

Object
Enum<DataType>
DataType
All Implemented Interfaces:
Serializable, Comparable<Data­Type>, Constable

public enum DataType extends Enum<DataType>
Identification of the primitive type used for storing sample values in an image. This is a type-safe version of the TYPE_* constants defined in Data­Buffer.
Since:
1.1

Defined in the sis-feature module

  • Enum Constant Details

    • BYTE

      public static final DataType BYTE
      Unsigned 8-bits data.
    • USHORT

      public static final DataType USHORT
      Unsigned 16-bits data.
    • SHORT

      public static final DataType SHORT
      Signed 16-bits data.
    • INT

      public static final DataType INT
      Signed 32-bits data. Also used for storing unsigned data; the Java2D API such as Raster​.get­Sample(int, int, int) can not distinguish the two cases.
    • FLOAT

      public static final DataType FLOAT
      Single precision (32-bits) floating point data.
    • DOUBLE

      public static final DataType DOUBLE
      Double precision (64-bits) floating point data.
  • Method Details

    • values

      public static DataType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static DataType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      Illegal­Argument­Exception - if this enum type has no constant with the specified name
      Null­Pointer­Exception - if the argument is null
    • forBands

      public static DataType forBands(RenderedImage image)
      Returns the data type of the bands in the given image. This is often the storage data type, but not necessarily. For example if an ARGB image uses a storage mode where the sample values in the 4 bands are packed in a single 32-bits integer, then this method returns BYTE (the type of a single band), not INT (the type of a whole pixel).
      Parameters:
      image - the image for which to get the type.
      Returns:
      type of the given image (never null).
      Throws:
      Raster­Format­Exception - if the image does not use a recognized data type.
    • forRange

      public static DataType forRange(NumberRange<?> range, boolean asInteger)
      Returns the smallest data type capable to store the given range of values. If the given range uses a floating point type, there there is a choice:
      • If as­Integer is false, then this method returns FLOAT or DOUBLE depending on the range type.
      • Otherwise this method treats the floating point values as if they were integers, with minimum value rounded toward negative infinity and maximum value rounded toward positive infinity.
      Parameters:
      range - the range of values.
      as­Integer - whether to handle floating point values as integers.
      Returns:
      smallest data type for the given range of values.
    • forPrimitiveType

      public static DataType forPrimitiveType(Class<?> type, boolean unsigned)
      Returns the data type for the given primitive type. The given type should be a primitive type such as Short​.TYPE, but wrappers class such as Short​.class are also accepted.
      Parameters:
      type - the primitive type or its wrapper class.
      unsigned - whether the type should be considered unsigned.
      Returns:
      the data type (never null) for the given primitive type.
      Throws:
      Raster­Format­Exception - if the given type is not a recognized.
    • forDataBufferType

      public static DataType forDataBufferType(int type)
      Returns the enumeration value for the given Data­Buffer constant. This method is the converse of to­Data­Buffer­Type(). It is provided for interoperability with Java2D.
      Parameters:
      type - one of Data­Buffer​.TYPE_* constants.
      Returns:
      the data type (never null) for the given data buffer type.
      Throws:
      Raster­Format­Exception - if the given type is not a recognized Data­Buffer​.TYPE_* constant.
    • size

      public final int size()
      Returns the size in bits of this data type.
      Returns:
      size in bits of this data type.
    • isUnsigned

      public final boolean isUnsigned()
      Returns whether this type is an unsigned integer type. Unsigned types are BYTE and USHORT.
      Returns:
      true if this type is an unsigned integer type.
    • isInteger

      public final boolean isInteger()
      Returns whether this type is an integer type, signed or not. Integer types are BYTE, USHORT, SHORT and INT.
      Returns:
      true if this type is an integer type.
    • toFloat

      public final DataType toFloat()
      Returns the smallest floating point type capable to store all values of this type without precision lost. This method returns: The promotion of integer values to floating point values is sometime necessary when the image may contain Float​.Na­N values.
      Returns:
      the smallest of FLOAT or DOUBLE types which can store all values of this type without any lost.
    • toDataBufferType

      public final int toDataBufferType()
      Returns the Data­Buffer constant for this enumeration value. This method is the converse of for­Data­Buffer­Type(int). It is provided for interoperability with Java2D.
      Returns:
      one of the Data­Buffer constants.