FileDocCategorySizeDatePackage
SimpleFrame.javaAPI DocAndroid 5.1 API4622Thu Mar 12 22:22:30 GMT 2015android.filterfw.core

SimpleFrame

public class SimpleFrame extends android.filterfw.core.Frame
hide

Fields Summary
private Object
mObject
Constructors Summary
SimpleFrame(android.filterfw.core.FrameFormat format, android.filterfw.core.FrameManager frameManager)

        super(format, frameManager);
        initWithFormat(format);
        setReusable(false);
    
Methods Summary
public android.graphics.BitmapgetBitmap()

        return (mObject instanceof Bitmap) ? (Bitmap)mObject : null;
    
public java.nio.ByteBuffergetData()

        return (mObject instanceof ByteBuffer) ? (ByteBuffer)mObject : null;
    
public float[]getFloats()

        return (mObject instanceof float[]) ? (float[])mObject : null;
    
public int[]getInts()

        return (mObject instanceof int[]) ? (int[])mObject : null;
    
public java.lang.ObjectgetObjectValue()

        return mObject;
    
protected booleanhasNativeAllocation()

        return false;
    
private voidinitWithFormat(android.filterfw.core.FrameFormat format)

        final int count = format.getLength();
        final int baseType = format.getBaseType();
        switch (baseType) {
            case FrameFormat.TYPE_BYTE:
                mObject = new byte[count];
                break;
            case FrameFormat.TYPE_INT16:
                mObject = new short[count];
                break;
            case FrameFormat.TYPE_INT32:
                mObject = new int[count];
                break;
            case FrameFormat.TYPE_FLOAT:
                mObject = new float[count];
                break;
            case FrameFormat.TYPE_DOUBLE:
                mObject = new double[count];
                break;
            default:
                mObject = null;
                break;
        }
    
protected voidreleaseNativeAllocation()

    
public voidsetBitmap(android.graphics.Bitmap bitmap)

        assertFrameMutable();
        setGenericObjectValue(bitmap);
    
public voidsetData(java.nio.ByteBuffer buffer, int offset, int length)

        assertFrameMutable();
        setGenericObjectValue(ByteBuffer.wrap(buffer.array(), offset, length));
    
public voidsetFloats(float[] floats)

        assertFrameMutable();
        setGenericObjectValue(floats);
    
private voidsetFormatObjectClass(java.lang.Class objectClass)

        MutableFrameFormat format = getFormat().mutableCopy();
        format.setObjectClass(objectClass);
        setFormat(format);
    
protected voidsetGenericObjectValue(java.lang.Object object)

        // Update the FrameFormat class
        // TODO: Take this out! FrameFormats should not be modified and convenience formats used
        // instead!
        FrameFormat format = getFormat();
        if (format.getObjectClass() == null) {
            setFormatObjectClass(object.getClass());
        } else if (!format.getObjectClass().isAssignableFrom(object.getClass())) {
            throw new RuntimeException(
                "Attempting to set object value of type '" + object.getClass() + "' on " +
                "SimpleFrame of type '" + format.getObjectClass() + "'!");
        }

        // Set the object value
        mObject = object;
    
public voidsetInts(int[] ints)

        assertFrameMutable();
        setGenericObjectValue(ints);
    
public java.lang.StringtoString()

        return "SimpleFrame (" + getFormat() + ")";
    
static android.filterfw.core.SimpleFramewrapObject(java.lang.Object object, android.filterfw.core.FrameManager frameManager)

        FrameFormat format = ObjectFormat.fromObject(object, FrameFormat.TARGET_SIMPLE);
        SimpleFrame result = new SimpleFrame(format, frameManager);
        result.setObjectValue(object);
        return result;