Search in sources :

Example 11 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class Canvas_Delegate method native_drawBitmap.

@LayoutlibDelegate
static /*package*/
void native_drawBitmap(int nativeCanvas, int bitmap, Rect src, Rect dst, int nativePaintOrZero, int screenDensity, int bitmapDensity) {
    // get the delegate from the native int.
    Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
    if (bitmapDelegate == null) {
        return;
    }
    BufferedImage image = bitmapDelegate.getImage();
    if (src == null) {
        drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), dst.left, dst.top, dst.right, dst.bottom);
    } else {
        drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), dst.left, dst.top, dst.right, dst.bottom);
    }
}
Also used : BufferedImage(java.awt.image.BufferedImage) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 12 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class Matrix_Delegate method native_invert.

@LayoutlibDelegate
static /*package*/
boolean native_invert(int native_object, int inverse) {
    Matrix_Delegate d = sManager.getDelegate(native_object);
    if (d == null) {
        return false;
    }
    Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
    if (inv_mtx == null) {
        return false;
    }
    try {
        AffineTransform affineTransform = d.getAffineTransform();
        AffineTransform inverseTransform = affineTransform.createInverse();
        inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
        inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
        inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
        inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
        return true;
    } catch (NoninvertibleTransformException e) {
        return false;
    }
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AffineTransform(java.awt.geom.AffineTransform) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 13 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class InputMethodManager_Delegate method getInstance.

// ---- Overridden methods ----
@LayoutlibDelegate
static /*package*/
InputMethodManager getInstance() {
    synchronized (InputMethodManager.class) {
        InputMethodManager imm = InputMethodManager.peekInstance();
        if (imm == null) {
            imm = new InputMethodManager(new BridgeIInputMethodManager(), Looper.getMainLooper());
            InputMethodManager.sInstance = imm;
        }
        return imm;
    }
}
Also used : BridgeIInputMethodManager(com.android.layoutlib.bridge.android.BridgeIInputMethodManager) BridgeIInputMethodManager(com.android.layoutlib.bridge.android.BridgeIInputMethodManager) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 14 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class Region_Delegate method nativeSetRect.

@LayoutlibDelegate
static /*package*/
boolean nativeSetRect(int native_dst, int left, int top, int right, int bottom) {
    Region_Delegate dstRegion = sManager.getDelegate(native_dst);
    if (dstRegion == null) {
        return true;
    }
    dstRegion.mArea = new Area(new Rectangle2D.Float(left, top, right - left, bottom - top));
    return dstRegion.mArea.getBounds().isEmpty() == false;
}
Also used : Area(java.awt.geom.Area) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 15 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class Typeface_Delegate method nativeCreateFromFile.

@LayoutlibDelegate
static synchronized /*package*/
int nativeCreateFromFile(String path) {
    if (path.startsWith(SYSTEM_FONTS)) {
        String relativePath = path.substring(SYSTEM_FONTS.length());
        File f = new File(sFontLoader.getOsFontsLocation(), relativePath);
        try {
            Font font = Font.createFont(Font.TRUETYPE_FONT, f);
            if (font != null) {
                Typeface_Delegate newDelegate = new Typeface_Delegate(font);
                return sManager.addNewDelegate(newDelegate);
            }
        } catch (Exception e) {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_BROKEN, String.format("Unable to load font %1$s", relativePath), null, /*throwable*/
            null);
        }
    } else {
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Typeface.createFromFile() can only work with platform fonts located in " + SYSTEM_FONTS, null, /*throwable*/
        null);
    }
    // return a copy of the base font
    return nativeCreate(null, 0);
}
Also used : File(java.io.File) Font(java.awt.Font) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Aggregations

LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)334 ArrayResourceValue (com.android.ide.common.rendering.api.ArrayResourceValue)56 DensityBasedResourceValue (com.android.ide.common.rendering.api.DensityBasedResourceValue)56 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)56 BufferedImage (java.awt.image.BufferedImage)46 AffineTransform (java.awt.geom.AffineTransform)42 Area (java.awt.geom.Area)42 File (java.io.File)30 GcSnapshot (com.android.layoutlib.bridge.impl.GcSnapshot)29 FileNotFoundException (java.io.FileNotFoundException)24 Graphics2D (java.awt.Graphics2D)19 TypedValue (android.util.TypedValue)17 NotFoundException (android.content.res.Resources.NotFoundException)16 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)16 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)16 ArrayList (java.util.ArrayList)16 XmlPullParser (org.xmlpull.v1.XmlPullParser)16 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)16 IOException (java.io.IOException)14 NinePatchInputStream (com.android.layoutlib.bridge.util.NinePatchInputStream)12