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());
}
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);
}
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);
}
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);
}
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));
}
Aggregations