Code example for Transformation

Methods: clear, getMatrix, setTransformationType

0
  public boolean getChildTransformation(float scale, int flowCenter, View child, Transformation trans)
  { 
    final float childCenter = child.getLeft() + (child.getWidth() / 2);
    final float childWidth = child.getWidth();
 
    trans.clear();
    trans.setTransformationType(Transformation.TYPE_MATRIX);
 
    int rotationAngle = 0;
    if (childCenter != flowCenter) {
      rotationAngle = (int) (((flowCenter - childCenter)/ childWidth) * MAX_ROTATION_ANGLE);
      if (Math.abs(rotationAngle) > MAX_ROTATION_ANGLE) {
        rotationAngle = (rotationAngle < 0) ? -MAX_ROTATION_ANGLE : MAX_ROTATION_ANGLE;
      } 
    } 
    transformImageBitmap((ImageView) child, trans, rotationAngle);
 
    return true; 
  } 
 
 
 
  /** 
   * Transform the Image Bitmap by the Angle passed 
   * 
   * @param imageView ImageView the ImageView whose bitmap we want to rotate 
   * @param t transformation 
   * @param rotationAngle the Angle by which to rotate the Bitmap 
   */ 
  private void transformImageBitmap(ImageView child, Transformation trans, int rotationAngle)
  { 
    mCamera.save();
    final Matrix imageMatrix = trans.getMatrix();
    final int imageHeight = child.getLayoutParams().height;
    final int imageWidth = child.getLayoutParams().width;
    final int rotation = Math.abs(rotationAngle);
 
    mCamera.translate(0.0f, 0.0f, 100.0f);