Java Code Examples for android.view.animation.Transformation#getMatrix()
The following examples show how to use
android.view.animation.Transformation#getMatrix() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rotate3dAnimation.java From AndroidTVWidget with Apache License 2.0 | 6 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 2
Source File: Rotate3dAnimation.java From Android-tv-widget with Apache License 2.0 | 6 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 3
Source File: Rotate3dAnimation.java From FragmentRigger with MIT License | 6 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 4
Source File: EBrowserAnimation.java From appcan-android with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = m_fromDegree; float degrees = fromDegrees + ((m_toDegree - fromDegrees) * interpolatedTime); final float centerX = m_centerX; final float centerY = m_centerY; final Camera camera = m_camera; final Matrix matrix = t.getMatrix(); camera.save(); if (m_reverse) { camera.translate(0.0f, 0.0f, m_depthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, m_depthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 5
Source File: Rotate3dAnimation.java From HaiNaBaiChuan with Apache License 2.0 | 6 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final Matrix matrix = t.getMatrix(); mCamera.save(); switch (mRollType) { case ROLL_BY_X: mCamera.rotateX(degrees); break; case ROLL_BY_Y: mCamera.rotateY(degrees); break; case ROLL_BY_Z: mCamera.rotateZ(degrees); break; } mCamera.getMatrix(matrix); mCamera.restore(); matrix.preTranslate(-mPivotX, -mPivotY); matrix.postTranslate(mPivotX, mPivotY); }
Example 6
Source File: PathAnimator.java From KSYMediaPlayer_Android with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float factor, Transformation transformation) { Matrix matrix = transformation.getMatrix(); mPm.getMatrix(mDistance * factor, matrix, PathMeasure.POSITION_MATRIX_FLAG); mView.setRotation(mRotation * factor); float scale = 1F; if (3000.0F * factor < 200.0F) { scale = scale(factor, 0.0D, 0.06666667014360428D, 0.20000000298023224D, 1.100000023841858D); } else if (3000.0F * factor < 300.0F) { scale = scale(factor, 0.06666667014360428D, 0.10000000149011612D, 1.100000023841858D, 1.0D); } mView.setScaleX(scale); mView.setScaleY(scale); transformation.setAlpha(1.0F - factor); }
Example 7
Source File: RotateActivityFrom90.java From nono-android with GNU General Public License v3.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); Matrix matrix = t.getMatrix(); Camera camera = new Camera(); camera.save(); camera.rotateY(90-90 * interpolatedTime); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-mcenterX,-mcenterY); matrix.postTranslate(mcenterX,mcenterY); }
Example 8
Source File: TwoDScrollerListview.java From 2DScroller with Apache License 2.0 | 5 votes |
@Override protected boolean getChildStaticTransformation(View child, Transformation t) { int topCenterView = mHeightCenter - mChildrenHeightMiddle; int childTop = Math.max(0,child.getTop()); float offset = (-childTop + topCenterView)/ (float) mSpaceBetweenViews; final Matrix matrix = t.getMatrix(); if (offset != 0) { float absOffset = Math.abs(offset); t.clear(); t.setTransformationType(Transformation.TYPE_MATRIX); float px = child.getLeft() + (child.getWidth()) / 2; float py = child.getTop() + (child.getHeight()) / 2; if (mTranslatateEnbabled){ matrix.setTranslate(mTranslate * absOffset, 0); } if (offset > 0) { matrix.preTranslate(-px,0); matrix.postTranslate(px,0); } else { matrix.preTranslate(-px, -py); matrix.postTranslate(px, py); } } return true; }
Example 9
Source File: FlipAnimator.java From CreditCardEntry with MIT License | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { // Angle around the y-axis of the rotation at the given time. It is // calculated both in radians and in the equivalent degrees. final double radians = Math.PI * interpolatedTime; float degrees = (float) (180.0 * radians / Math.PI); // Once we reach the midpoint in the animation, we need to hide the // source view and show the destination view. We also need to change // the angle by 180 degrees so that the destination does not come in // flipped around. This is the main problem with SDK sample, it does not // do this. if (interpolatedTime >= 0.5f) { degrees -= 180.f; if (!visibilitySwapped) { fromView.setVisibility(View.GONE); toView.setVisibility(View.VISIBLE); visibilitySwapped = true; } } if (forward) degrees = -degrees; final Matrix matrix = t.getMatrix(); camera.save(); camera.translate(0.0f, 0.0f, (float) (150.0 * Math.sin(radians))); camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 10
Source File: Rotate3dAnimation.java From SUtil with Artistic License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; // 生成中间角度 float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); // 取得变换后的矩阵 camera.getMatrix(matrix); camera.restore(); float[] mValues = {0, 0, 0, 0, 0, 0, 0, 0, 0}; matrix.getValues(mValues); //获取数值 mValues[6] = mValues[6] / scale; //数值修正 matrix.setValues(mValues); //重新赋值 matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 11
Source File: TileView.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { // Angle around the y-axis of the rotation at the given time // calculated both in radians and degrees. final double radians = Math.PI * interpolatedTime; float degrees = (float) (180.0 * radians / Math.PI); // Once we reach the midpoint in the animation, we need to hide the // source view and show the destination view. We also need to change // the angle by 180 degrees so that the destination does not come in // flipped around if (interpolatedTime >= 0.5f) { degrees -= 180.f; fromView.setVisibility(View.GONE); toView.setVisibility(View.VISIBLE); } if (forward) degrees = -degrees; // determines direction of rotation when // flip begins final Matrix matrix = t.getMatrix(); camera.save(); camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 12
Source File: RotateAnimation.java From GoogleTotpAuth with Apache License 2.0 | 5 votes |
protected void applyTransformation(float interpolatedTime, Transformation transformation) { // interpolatedTime:动画进度值,范围为[0.0f,1.0f] if (listener != null) { listener.interpolatedTime(interpolatedTime); } // Log.i("debug",interpolatedTime+""); float from = 0.0f, to = 0.0f; if (type == ROTATE_DECREASE) { from = 0.0f; to = 180.0f;// 0~180 } else if (type == ROTATE_INCREASE) { from = 360.0f; to = 180.0f;// 360~180 } float degree = from + (to - from) * interpolatedTime; boolean overHalf = (interpolatedTime > 0.5f); if (overHalf) { // 翻转过半的情况下,为保证数字仍为可读的文字而非镜面效果的文字,需翻转180度。 degree = degree - 180; } // float depth = 0.0f; float depth = (0.5f - Math.abs(interpolatedTime - 0.5f)) * DEPTH_Z; final Matrix matrix = transformation.getMatrix(); camera.save(); camera.translate(0.0f, 0.0f, depth); camera.rotateX(degree); camera.getMatrix(matrix); camera.restore(); if (DEBUG) { if (overHalf) { matrix.preTranslate(-centerX * 2, -centerY); matrix.postTranslate(centerX * 2, centerY); } } else { //确保图片的翻转过程一直处于组件的中心点位置 matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } }
Example 13
Source File: Rotate3dAnimation.java From pandroid with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } switch (rotationAxis) { case X: camera.rotateX(degrees); break; case Y: camera.rotateY(degrees); break; case Z: camera.rotateZ(degrees); break; } camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 14
Source File: Rotate3dAnimation.java From AnimationApiDemos with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { // 根据时间和起始终止的角度值,插值算出当前的角度:degrees final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); //pre: matrix.preTranslate(-centerX, -centerY); //post: matrix.postTranslate(centerX, centerY); }
Example 15
Source File: Rotate3dAnimation.java From CloudPan with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } if (mRotateType == TYPEX) { camera.rotateX(degrees); } else if (mRotateType == TYPEY) { camera.rotateY(degrees); } else if (mRotateType == TYPEZ) { camera.rotateZ(degrees); } camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 16
Source File: PathAnimator.java From MousePaint with MIT License | 5 votes |
@Override protected void applyTransformation(float factor, Transformation transformation) { Matrix matrix = transformation.getMatrix(); mPm.getMatrix(mDistance * factor, matrix, PathMeasure.POSITION_MATRIX_FLAG); mView.setRotation(mRotation * factor); float scale = 1F; if (3000.0F * factor < 200.0F) { scale = scale(factor, 0.0D, 0.06666667014360428D, 0.20000000298023224D, 1.100000023841858D); } else if (3000.0F * factor < 300.0F) { scale = scale(factor, 0.06666667014360428D, 0.10000000149011612D, 1.100000023841858D, 1.0D); } mView.setScaleX(scale); mView.setScaleY(scale); transformation.setAlpha(1.0F - factor); }
Example 17
Source File: Rotate3dAnimation.java From ViewSupport with Apache License 2.0 | 4 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * interpolatedTime); final Matrix matrix = t.getMatrix(); mCamera.save(); // 调节深度 if (mReverse) { mCamera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { mCamera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } // 绕轴旋转 switch (mAxis) { case 1: mCamera.rotateX(degrees); break; case 2: mCamera.rotateY(degrees); break; case 3: mCamera.rotateZ(degrees); break; } mCamera.getMatrix(matrix); mCamera.restore(); // 修复失真 float[] mValues = new float[9]; matrix.getValues(mValues); //获取数值 mValues[6] = mValues[6] / scale; //数值修正 mValues[7] = mValues[7] / scale; //数值修正 matrix.setValues(mValues); //重新赋值 // 设置中心 matrix.preTranslate(-mCenterX, -mCenterY); matrix.postTranslate(mCenterX, mCenterY); }
Example 18
Source File: Rotate3dAnimation.java From Rotate3dAnimation with Eclipse Public License 1.0 | 4 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; // 生成中间角度 float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); // 取得变换后的矩阵 camera.getMatrix(matrix); camera.restore(); //---------------------------------------------------------------------------- /** * 修复打脸问题 ( ̄ε(# ̄)☆╰╮( ̄▽ ̄///) * 简要介绍: * 原来的3D翻转会由于屏幕像素密度问题而出现效果相差很大 * 例如在屏幕像素比为1,5的手机上显示效果基本正常, * 而在像素比3,0的手机上面感觉翻转感觉要超出屏幕边缘, * 有种迎面打脸的感觉、 * * 解决方案 * 利用屏幕像素密度对变换矩阵进行校正, * 保证了在所有清晰度的手机上显示的效果基本相同。 * */ float[] mValues = {0,0,0,0,0,0,0,0,0}; matrix.getValues(mValues); //获取数值 mValues[6] = mValues[6]/scale; //数值修正 matrix.setValues(mValues); //重新赋值 // Log.e("TAG", "mValues["+0+"]="+mValues[0]+"------------\t"+"mValues["+6+"]="+mValues[6]); //---------------------------------------------------------------------------- matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 19
Source File: FlipLayout.java From FlipAnimation with MIT License | 4 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { // Angle around the y-axis of the rotation at the given time. It is // calculated both in radians and in the equivalent degrees. final double radians = Math.PI * interpolatedTime; float degrees = (float) (180.0 * radians / Math.PI); if (direction == Direction.UP || direction == Direction.LEFT) { degrees = -degrees; } // Once we reach the midpoint in the animation, we need to hide the // source view and show the destination view. We also need to change // the angle by 180 degrees so that the destination does not come in // flipped around. This is the main problem with SDK sample, it does // not // do this. if (interpolatedTime >= 0.5f) { switch (direction) { case LEFT: case UP: degrees += 180.f; break; case RIGHT: case DOWN: degrees -= 180.f; break; } if (!visibilitySwapped) { toggleView(); visibilitySwapped = true; } } final Matrix matrix = t.getMatrix(); camera.save(); //you can delete this line, it move camera a little far from view and get back camera.translate(0.0f, 0.0f, (float) (EXPERIMENTAL_VALUE * Math.sin(radians))); switch (direction) { case DOWN: case UP: camera.rotateX(degrees); camera.rotateY(0); break; case LEFT: case RIGHT: camera.rotateY(degrees); camera.rotateX(0); break; } camera.rotateZ(0); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }
Example 20
Source File: ViewPropertyAnimation.java From FragmentAnimations with Apache License 2.0 | 4 votes |
protected void applyTransformation(Transformation t) { final Matrix m = t.getMatrix(); final float w = mWidth; final float h = mHeight; final float pX = mPivotX; final float pY = mPivotY; final float rX = mRotationX; final float rY = mRotationY; final float rZ = mRotationZ; if ((rX != 0) || (rY != 0) || (rZ != 0)) { final Camera camera = mCamera; camera.save(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { camera.setLocation(mCameraX, mCameraY, mCameraZ); } if (mTranslationZ != 0) { camera.translate(0, 0, mTranslationZ); } camera.rotateX(rX); camera.rotateY(rY); camera.rotateZ(-rZ); camera.getMatrix(m); camera.restore(); m.preTranslate(-pX, -pY); m.postTranslate(pX, pY); } final float sX = mScaleX; final float sY = mScaleY; if ((sX != 1.0f) || (sY != 1.0f)) { m.postScale(sX, sY); final float sPX = -(pX / w) * ((sX * w) - w); final float sPY = -(pY / h) * ((sY * h) - h); m.postTranslate(sPX, sPY); } m.postTranslate(mTranslationX, mTranslationY); t.setAlpha(mAlpha); }