Search in sources :

Example 26 with AffineTransform

use of java.awt.geom.AffineTransform in project limelight by slagyr.

the class PropPanelTest method hasChangesWhenTextIsChanged.

@Test
public void hasChangesWhenTextIsChanged() throws Exception {
    TextPanel.staticFontRenderingContext = new FontRenderContext(new AffineTransform(), true, true);
    Layouts.on(panel, panel.getDefaultLayout());
    panel.resetNeededLayout();
    panel.setText("blah");
    assertEquals(true, panel.needsLayout());
    panel.resetNeededLayout();
    panel.setText("blah");
    assertEquals(false, panel.needsLayout());
    panel.setText("new text");
    assertEquals(true, panel.needsLayout());
}
Also used : AffineTransform(java.awt.geom.AffineTransform) FontRenderContext(java.awt.font.FontRenderContext) Test(org.junit.Test)

Example 27 with AffineTransform

use of java.awt.geom.AffineTransform in project limelight by slagyr.

the class ImagePanelLayoutTest method hasConstrainedProportionsWhenHeightIsNotAuto.

@Test
public void hasConstrainedProportionsWhenHeightIsNotAuto() throws Exception {
    panel.setFilename(TestUtil.DATA_DIR + "/star.gif");
    parent.style.setHeight("100");
    parent.childConsumableBounds = new Box(0, 0, 200, 100);
    Layouts.on(parent, parent.getDefaultLayout());
    AffineTransform tranform = panel.getTransform();
    assertEquals(0.5, tranform.getScaleX(), 0.001);
    assertEquals(0.5, tranform.getScaleY(), 0.001);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) Box(limelight.util.Box) Test(org.junit.Test)

Example 28 with AffineTransform

use of java.awt.geom.AffineTransform in project limelight by slagyr.

the class ImagePanelLayoutTest method getRotationTransformWhenDimensionsAreAuto.

@Test
public void getRotationTransformWhenDimensionsAreAuto() throws Exception {
    panel.setFilename(TestUtil.DATA_DIR + "/star.gif");
    panel.setRotation(45);
    Layouts.on(panel, panel.getDefaultLayout());
    AffineTransform tranform = panel.getTransform();
    // No good way to test rotation....
    assertEquals(141.0, tranform.getTranslateX(), 0.5);
    assertEquals(0.0, tranform.getTranslateY(), 0.5);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) Test(org.junit.Test)

Example 29 with AffineTransform

use of java.awt.geom.AffineTransform in project platform_frameworks_base by android.

the class Canvas_Delegate method nativeDrawBitmapMatrix.

@LayoutlibDelegate
public static void nativeDrawBitmapMatrix(long nCanvas, Bitmap bitmap, long nMatrix, long nPaint) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    // get the delegate from the native int, which can be null
    Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(nPaint);
    // get the delegate from the native int.
    Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
    if (bitmapDelegate == null) {
        return;
    }
    final BufferedImage image = getImageToDraw(bitmapDelegate, paintDelegate, sBoolOut);
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    final AffineTransform mtx = matrixDelegate.getAffineTransform();
    canvasDelegate.getSnapshot().draw(new GcSnapshot.Drawable() {

        @Override
        public void draw(Graphics2D graphics, Paint_Delegate paint) {
            if (paint != null && paint.isFilterBitmap()) {
                graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            }
            //FIXME add support for canvas, screen and bitmap densities.
            graphics.drawImage(image, mtx, null);
        }
    }, paintDelegate, true, /*compositeOnly*/
    false);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 30 with AffineTransform

use of java.awt.geom.AffineTransform in project platform_frameworks_base by android.

the class Canvas_Delegate method native_getCTM.

@LayoutlibDelegate
public static void native_getCTM(long canvas, long matrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(matrix);
    if (matrixDelegate == null) {
        return;
    }
    AffineTransform transform = canvasDelegate.getSnapshot().getTransform();
    matrixDelegate.set(Matrix_Delegate.makeValues(transform));
}
Also used : AffineTransform(java.awt.geom.AffineTransform) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Aggregations

AffineTransform (java.awt.geom.AffineTransform)335 BufferedImage (java.awt.image.BufferedImage)55 Graphics2D (java.awt.Graphics2D)43 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)42 Rectangle2D (java.awt.geom.Rectangle2D)38 Point2D (java.awt.geom.Point2D)26 Paint (java.awt.Paint)22 Font (java.awt.Font)21 Shape (java.awt.Shape)21 GcSnapshot (com.android.layoutlib.bridge.impl.GcSnapshot)20 NoninvertibleTransformException (java.awt.geom.NoninvertibleTransformException)17 PathIterator (java.awt.geom.PathIterator)16 ArrayList (java.util.ArrayList)16 FontRenderContext (java.awt.font.FontRenderContext)15 Color (java.awt.Color)14 Area (java.awt.geom.Area)14 GeneralPath (java.awt.geom.GeneralPath)14 Rectangle (java.awt.Rectangle)11 Path2D (java.awt.geom.Path2D)11 Test (org.junit.Test)11