Java 8 DataBuffer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DataBuffer class.

This code example shows how to use the following methods:getDataType, getNumBanks, getSize
        } 
 
        public void recycleTile(Raster tile) {
            DataBuffer db = tile.getDataBuffer();
 
            Long key = getKey(db.getDataType(), db.getNumBanks(), db.getSize());
            if (LOGGER.isLoggable(Level.FINER)) {
                LOGGER.log(Level.FINER,
                        "Recycling tile hit on type:{1}, banks: {2}, arrayLength: {3}", 
                        new Object[] { db.getDataType(), db.getNumBanks(), db.getSize() }); 
            } 
 
            ConcurrentLinkedQueue<SoftReference<?>> arrays = get(key);
            if (arrays == null) {
                arrays = new ConcurrentLinkedQueue<SoftReference<?>>();
                arrays.add(getBankReference(db));
                put(key, arrays);
                return; 
            } else { 
                arrays.add(getBankReference(db));

6
CodeRank
This code example shows how to use the following methods:getDataType, getNumBanks, getOffsets, getSize
        if (!isEnabled()) { 
            return; 
        } 
 
        if (buf != null) {
            traceObjStart(label, buf, sb, indent);
            indent += INDENT_INCR;
 
            if (isFlagSet(traceMask, F_ATTRIBUTES)) {
                traceField("dataType", ImageUtils.getDataTypeName(buf.getDataType()), sb, indent);
                traceField("size", buf.getSize(), sb, indent);
                traceField("numBanks", buf.getNumBanks(), sb, indent);
                traceField("offsets", buf.getOffsets(), sb, indent);
            } 
 
            indent -= INDENT_INCR;
            traceObjEnd(sb, indent);
        } else { 
            traceField(label, buf, sb, indent);
        } 

6
CodeRank
This code example shows how to use the following methods:getDataType, getNumBanks, getSize
 
        key = hashKey(owner, tileX, tileY);
 
        // tileMemorySize(Raster tile) inlined for performance 
        DataBuffer db = tile.getDataBuffer();
        memorySize = db.getDataTypeSize(db.getDataType()) / 8L *
                     db.getSize() * db.getNumBanks();
 
    } 
 
    /** 
     * Returns the hash table "key" as a <code>Object</code> for this 
     * tile.  For <code>PlanarImage</code> and 
     * <code>SerializableRenderedImage</code>, the key is generated by 
     * the method <code>ImageUtilgenerateID(Object) </code>.  For the 
     * other cases, a <code>Long</code> object is returned. 
     * The upper 32 bits for this <code>Long</code> is the tile owner's 
     * hash code, and the lower 32 bits is the tile's index. 
     */ 
    static Object hashKey(RenderedImage owner,
6
CodeRank
This code example shows how to use the following methods:getDataType, getOffsets, getSize
      * 
      * @param out The <code>ObjectOutputStream</code>. 
      */ 
    private void writeObject(ObjectOutputStream out) throws IOException {
        // Write serialized form to the stream. 
        int dataType = dataBuffer.getDataType();
        out.writeInt(dataType);
        out.writeObject(dataBuffer.getOffsets());
        out.writeInt(dataBuffer.getSize());
        Object dataArray = null; 
        switch (dataType) {
        case DataBuffer.TYPE_BYTE:
            dataArray = ((DataBufferByte)dataBuffer).getBankData();
            break; 
        case DataBuffer.TYPE_SHORT:
            dataArray = ((DataBufferShort)dataBuffer).getBankData();
            break; 
        case DataBuffer.TYPE_USHORT:
            dataArray = ((DataBufferUShort)dataBuffer).getBankData();
            break; 
6
CodeRank
This code example shows how to use the following methods:getDataType, getNumBanks, getSize
 
        key = hashKey(owner, tileX, tileY);
 
        // tileMemorySize(Raster tile) inlined for performance 
        DataBuffer db = tile.getDataBuffer();
        memorySize = db.getDataTypeSize(db.getDataType()) / 8L *
                     db.getSize() * db.getNumBanks();
 
    } 
 
    static Object fastHashKey(RenderedImage owner,
                              int tileX,
                              int tileY) {
        return new Integer(((Object) owner).hashCode() + tileY * owner.getNumXTiles() + tileX);
    } 
 
    /** 
     * Returns the hash table "key" as a <code>Object</code> for this 
     * tile.  For <code>PlanarImage</code> and 
     * <code>SerializableRenderedImage</code>, the key is generated by 
6
CodeRank
This code example shows how to use the following methods:getDataType
     * data of the <code>DataBuffer</code>. 
     */ 
    private static SoftReference getBankReference(DataBuffer db) {
        Object array = null; 
 
        switch(db.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            array = ((DataBufferByte)db).getBankData();
            break; 
        case DataBuffer.TYPE_USHORT:
            array = ((DataBufferUShort)db).getBankData();
            break; 
        case DataBuffer.TYPE_SHORT:
            array = ((DataBufferShort)db).getBankData();
            break; 
        case DataBuffer.TYPE_INT:
            array = ((DataBufferInt)db).getBankData();
            break; 
        case DataBuffer.TYPE_FLOAT:
            array = DataBufferUtils.getBankDataFloat(db);

5
CodeRank
This code example shows how to use the following methods:getDataType
        RgbeInfo info = new RgbeInfo( byteSource );
 
        try { 
            // It is necessary to create our own BufferedImage here as the 
            // org.apache.sanselan.common.IBufferedImageFactory interface does not expose this complexity 
            DataBuffer buffer = new DataBufferFloat( info.getPixelData(), info.getWidth() * info.getHeight() );
 
            return new BufferedImage(
                new ComponentColorModel( ColorSpace.getInstance( ColorSpace.CS_sRGB ),
                                         false, 
                                         false, 
                                         Transparency.OPAQUE,
                                         buffer.getDataType() ),
                Raster.createWritableRaster( new BandedSampleModel( buffer.getDataType(),
                                                                    info.getWidth(),
                                                                    info.getHeight(),
                                                                    3 ), 
                                             buffer,
                                             new Point() ),
                false, 
5
CodeRank
This code example shows how to use the following methods:getDataType, getNumBanks, getSize
        this.tileX = tileX;
        this.tileY = tileY;
        this.tileCacheMetric = tileCacheMetric;  // may be null
        this.key = hashKey(owner, tileX, tileY);
        DataBuffer db = tile.getDataBuffer();
        this.tileSize = DataBuffer.getDataTypeSize(db.getDataType()) / 8L *
                db.getSize() * db.getNumBanks();
    } 
 
    public int getTileX() { 
        return tileX;
    } 
 
    public int getTileY() { 
        return tileY;
    } 
 
    public Object getKey() { 
        return key; 
    } 
4
CodeRank
This code example shows how to use the following methods:getOffset, getBankData
        // is SinglePixelPackedSampleModel. 
        // Adjust for initial offset in DataBuffer and also for the scanline 
        // stride. 
        // 
        DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
        int[] pixels = rasterDB.getBankData()[0];
        int off = rasterDB.getOffset();
        int scanlineStride = ((SinglePixelPackedSampleModel)
                              raster.getSampleModel()).getScanlineStride();
        int adjust = scanlineStride - w;
 
        fillRaster(pixels, off, adjust, x, y, w, h); //delegate to subclass.
 
        GraphicsUtil.coerceData(raster, dataModel,
                                model.isAlphaPremultiplied());
 
 
        return raster;
    } 
 
4
CodeRank
This code example shows how to use the following methods:getDataType
     * data of the <code>DataBuffer</code>. 
     */ 
    private static SoftReference getBankReference(DataBuffer db) {
        Object array = null; 
 
        switch(db.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            array = ((DataBufferByte)db).getBankData();
            break; 
        case DataBuffer.TYPE_USHORT:
            array = ((DataBufferUShort)db).getBankData();
            break; 
        case DataBuffer.TYPE_SHORT:
            array = ((DataBufferShort)db).getBankData();
            break; 
        case DataBuffer.TYPE_INT:
            array = ((DataBufferInt)db).getBankData();
            break; 
        case DataBuffer.TYPE_FLOAT:
            array = DataBufferUtils.getBankDataFloat(db);
4
CodeRank
See Code Examples for Java 8 DataBuffer Methods: