Java Code Examples for java.awt.image.DataBuffer#TYPE_UNDEFINED

The following examples show how to use java.awt.image.DataBuffer#TYPE_UNDEFINED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColConvTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 2
Source File: Util.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
/** Turns a DataBuffer.TYPE_* integer into a string

      @param datatype the DataBuffer.TYPE_* integer
      @return human readable form */

  public static String getDataType(int datatype) {
    switch (datatype) {
    case DataBuffer.TYPE_BYTE:
      return "TYPE_BYTE";
    case DataBuffer.TYPE_DOUBLE:
      return "TYPE_DOUBLE";
    case DataBuffer.TYPE_FLOAT:
      return "TYPE_FLOAT";
    case DataBuffer.TYPE_INT:
      return "TYPE_INT";
    case DataBuffer.TYPE_SHORT:
      return "TYPE_SHORT";
    case DataBuffer.TYPE_UNDEFINED:
      return "TYPE_UNDEFINED";
    case DataBuffer.TYPE_USHORT:
      return "TYPE_USHORT";
    default:
      return "unknown";
    }
  }
 
Example 3
Source File: ImageRenderer.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the data as vectors. The number of vectors must be equal to the {@linkplain #getNumBands() expected number of bands}.
 * All vectors must be backed by arrays (indirectly, through {@linkplain Vector#buffer() buffers} backed by arrays) and have
 * the same {@linkplain Vector#size() size}.
 * This method wraps the underlying arrays of a primitive type into a Java2D buffer; data are not copied.
 *
 * <p><b>Implementation note:</b> the NIO buffers are set by a call to {@link #setData(int, Buffer...)},
 * which can be overridden by subclasses if desired.</p>
 *
 * @param  data  the vectors wrapping arrays of primitive type.
 * @throws NullArgumentException if {@code data} is null or one of {@code data} element is null.
 * @throws MismatchedCoverageRangeException if the number of specified vectors is not equal to the number of bands.
 * @throws UnsupportedOperationException if a vector is not backed by an accessible array or is read-only.
 * @throws RasterFormatException if vectors do not have the same size.
 * @throws ArithmeticException if a buffer position overflows the 32 bits integer capacity.
 */
public void setData(final Vector... data) {
    ArgumentChecks.ensureNonNull("data", data);
    ensureExpectedBandCount(data.length, true);
    final Buffer[] buffers = new Buffer[data.length];
    int dataType = DataBuffer.TYPE_UNDEFINED;
    for (int i=0; i<data.length; i++) {
        final Vector v = data[i];
        ArgumentChecks.ensureNonNullElement("data", i, v);
        final int t = RasterFactory.getType(v.getElementType(), v.isUnsigned());
        if (dataType != t) {
            if (i != 0) {
                throw new RasterFormatException(Resources.format(Resources.Keys.MismatchedDataType));
            }
            dataType = t;
        }
        buffers[i] = v.buffer().orElseThrow(UnsupportedOperationException::new);
    }
    setData(dataType, buffers);
}
 
Example 4
Source File: ColConvTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 5
Source File: ColConvTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 6
Source File: ColConvTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 7
Source File: ColConvTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 8
Source File: ColConvTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 9
Source File: ColConvTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 10
Source File: ColConvTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 11
Source File: ColConvTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 12
Source File: ColConvTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 13
Source File: ColConvTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 14
Source File: ColConvTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 15
Source File: ColConvTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static String getDTName(int dType) {
    switch(dType) {
        case DataBuffer.TYPE_BYTE:
            return "TYPE_BYTE";
        case DataBuffer.TYPE_DOUBLE:
            return "TYPE_DOUBLE";
        case DataBuffer.TYPE_FLOAT:
            return "TYPE_FLOAT";
        case DataBuffer.TYPE_INT:
            return "TYPE_INT";
        case DataBuffer.TYPE_SHORT:
            return "TYPE_SHORT";
        case DataBuffer.TYPE_USHORT:
            return "TYPE_USHORT";
        case DataBuffer.TYPE_UNDEFINED:
            return "TYPE_UNDEFINED";
    }
    return "UNKNOWN";
}
 
Example 16
Source File: RasterFactory.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the {@link DataBuffer} constant for the given type. The given {@code sample} class
 * should be a primitive type such as {@link Float#TYPE}. Wrappers class are also accepted.
 *
 * @param  sample    the primitive type or its wrapper class. May be {@code null}.
 * @param  unsigned  whether the type should be considered unsigned.
 * @return the {@link DataBuffer} type, or {@link DataBuffer#TYPE_UNDEFINED}.
 */
public static int getType(final Class<?> sample, final boolean unsigned) {
    switch (Numbers.getEnumConstant(sample)) {
        case Numbers.BYTE:    if (unsigned) return DataBuffer.TYPE_BYTE; else break;
        case Numbers.SHORT:   return unsigned ? DataBuffer.TYPE_USHORT : DataBuffer.TYPE_SHORT;
        case Numbers.INTEGER: if (!unsigned) return DataBuffer.TYPE_INT; else break;
        case Numbers.FLOAT:   return DataBuffer.TYPE_FLOAT;
        case Numbers.DOUBLE:  return DataBuffer.TYPE_DOUBLE;
    }
    return DataBuffer.TYPE_UNDEFINED;
}
 
Example 17
Source File: Convention.java    From sis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given variable is used as a coordinate system axis, a coverage or something else.
 * In particular this method shall return {@link VariableRole#AXIS} if the given variable seems to be a
 * coordinate system axis instead than the actual data. By netCDF convention, coordinate system axes
 * have the name of one of the dimensions defined in the netCDF header.
 *
 * <p>The default implementation returns {@link VariableRole#COVERAGE} if the given variable can be used
 * for generating an image, by checking the following conditions:</p>
 *
 * <ul>
 *   <li>Images require at least {@value Grid#MIN_DIMENSION} dimensions of size equals or greater than {@value Grid#MIN_SPAN}.
 *       They may have more dimensions, in which case a slice will be taken later.</li>
 *   <li>Exclude axes. Axes are often already excluded by the above condition because axis are usually 1-dimensional,
 *       but some axes are 2-dimensional (e.g. a localization grid).</li>
 *   <li>Excludes characters, strings and structures, which can not be easily mapped to an image type.
 *       In addition, 2-dimensional character arrays are often used for annotations and we do not want
 *       to confuse them with images.</li>
 * </ul>
 *
 * @param  variable  the variable for which to get the role.
 * @return role of the given variable.
 */
public VariableRole roleOf(final Variable variable) {
    if (variable.isCoordinateSystemAxis()) {
        return VariableRole.AXIS;
    }
    int numVectors = 0;                                     // Number of dimension having more than 1 value.
    for (final Dimension dimension : variable.getGridDimensions()) {
        if (dimension.length() >= Grid.MIN_SPAN) {
            numVectors++;
        }
    }
    if (numVectors >= Grid.MIN_DIMENSION) {
        final DataType dataType = variable.getDataType();
        if (dataType.rasterDataType != DataBuffer.TYPE_UNDEFINED) {
            return VariableRole.COVERAGE;
        }
    }
    return VariableRole.OTHER;
}