当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.preTranslate方法代码示例

本文整理汇总了Java中android.graphics.Matrix.preTranslate方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.preTranslate方法的具体用法?Java Matrix.preTranslate怎么用?Java Matrix.preTranslate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Matrix的用法示例。


在下文中一共展示了Matrix.preTranslate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final double radians = Math.PI * interpolatedTime;
    float degrees = (float) (180.0 * radians / Math.PI);

    if (interpolatedTime >= 0.5f) { // Alternate the visibility of views at the exact half of animation duration.
        degrees -= 180.f;
        fromView.setVisibility(View.GONE);
        toView.setVisibility(View.VISIBLE);
    }

    if (forward)
        degrees = -degrees;

    final Matrix matrix = t.getMatrix();
    camera.save();
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
开发者ID:riteshakya037,项目名称:Flashcards-Demo,代码行数:23,代码来源:FlipAnimation.java

示例2: getSymmetricalMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 关于两个control连线的对称矩阵
 * @return
 */
private Matrix getSymmetricalMatrix() {
    // 根据网上资料,有一点错误,就是先-b,再b
    float k = (mBzControl1.y - mBzControl2.y) / (mBzControl1.x - mBzControl2.x);
    float[] values = new float[9];
    values[0] = -1 * (k * k - 1) / (k * k + 1);
    values[1] = 2 * k / (k * k + 1);
    values[3] = values[1];
    values[4] = -values[0];
    values[8] = 1;

    float b = mBzControl1.y - mBzControl1.x * k;
    Matrix matrix = new Matrix();
    matrix.setValues(values);
    matrix.preTranslate(0, -b);
    matrix.postTranslate(0, b);

    return matrix;
}
 
开发者ID:1014277960,项目名称:DailyReader,代码行数:23,代码来源:ReadView.java

示例3: transformImageBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
private void transformImageBitmap(View child, Transformation t,
                                  int rotationAngle) {
    mCamera.save();
    final Matrix imageMatrix = t.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);

    // As the angle of the view gets less, zoom in
    if (rotation < mMaxRotationAngle) {
        float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
        mCamera.translate(0.0f, 0.0f, zoomAmount);
    }

    mCamera.rotateY(rotationAngle);
    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
    mCamera.restore();
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:23,代码来源:CourseInfoGallery.java

示例4: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@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);
}
 
开发者ID:kingwang666,项目名称:BookLoadingView,代码行数:25,代码来源:Rotate3dAnimation.java

示例5: cropAndRescaleBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
public static void cropAndRescaleBitmap(final Bitmap src, final Bitmap dst, int sensorOrientation) {
    Assert.assertEquals(dst.getWidth(), dst.getHeight());
    final float minDim = Math.min(src.getWidth(), src.getHeight());

    final Matrix matrix = new Matrix();

    // We only want the center square out of the original rectangle.
    final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
    final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
    matrix.preTranslate(translateX, translateY);

    final float scaleFactor = dst.getHeight() / minDim;
    matrix.postScale(scaleFactor, scaleFactor);

    // Rotate around the center if necessary.
    if (sensorOrientation != 0) {
        matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
        matrix.postRotate(sensorOrientation);
        matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
    }

    final Canvas canvas = new Canvas(dst);
    canvas.drawBitmap(src, matrix, null);
}
 
开发者ID:googlecodelabs,项目名称:androidthings-imageclassifier,代码行数:25,代码来源:Helper.java

示例6: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    Camera camera = new Camera();
    camera.save();

    // 设置camera动作为绕Y轴旋转
    // 总共旋转180度,因此计算在每个补间时间点interpolatedTime的角度即为两着相乘
//    camera.rotateX(deg * interpolatedTime);
    camera.rotateY(180 * interpolatedTime);
//    camera.rotateZ(180 * interpolatedTime);
//
    // 根据camera动作产生一个matrix,赋给Transformation的matrix,以用来设置动画效果
    Matrix matrix = t.getMatrix();
    camera.getMatrix(matrix);

    camera.restore();
    //经过以下平移,才能以view的中心点进行翻转
    matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2);
    matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2);
  }
 
开发者ID:JustKiddingBaby,项目名称:FragmentRigger,代码行数:21,代码来源:Rotate3d.java

示例7: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
	float deg = 0.0F + 360.0F * interpolatedTime;
	Matrix matrix = t.getMatrix();
	mCamera.save();
	if (mMode == Mode.X)
		mCamera.rotateX(deg);
	if (mMode == Mode.Y)
		mCamera.rotateY(deg);
	if (mMode == Mode.Z)
		mCamera.rotateZ(deg);

	mCamera.getMatrix(matrix);
	mCamera.restore();
	matrix.preTranslate(-mCenterX, -mCenterY);
	matrix.postTranslate(mCenterX, mCenterY);

}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:19,代码来源:RotateAnimation.java

示例8: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
    final Matrix matrix = t.getMatrix();

    final Camera camera = mCamera;
    camera.save();

    camera.rotateY(degrees);
    camera.getMatrix(matrix);

    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:17,代码来源:FlipAnimation.java

示例9: transformMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    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();
        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);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:34,代码来源:AnimatorProxy.java

示例10: offsetDescendantMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
    ViewParent parent = view.getParent();
    if ((parent instanceof View) && parent != target) {
        View vp = (View) parent;
        offsetDescendantMatrix(target, vp, m);
        m.preTranslate((float) (-vp.getScrollX()), (float) (-vp.getScrollY()));
    }
    m.preTranslate((float) view.getLeft(), (float) view.getTop());
    if (!view.getMatrix().isIdentity()) {
        m.preConcat(view.getMatrix());
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:ViewGroupUtilsHoneycomb.java

示例11: offsetDescendantMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
    final ViewParent parent = view.getParent();
    if (parent instanceof View && parent != target) {
        final View vp = (View) parent;
        offsetDescendantMatrix(target, vp, m);
        m.preTranslate(-vp.getScrollX(), -vp.getScrollY());
    }

    m.preTranslate(view.getLeft(), view.getTop());

    if (!view.getMatrix().isIdentity()) {
        m.preConcat(view.getMatrix());
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:15,代码来源:ViewGroupUtilsHoneycomb.java

示例12: getRotateMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
public Matrix getRotateMatrix() {
    // By default this is an identity matrix
    Matrix matrix = new Matrix();
    if (bitmap != null && rotation != 0) {
        // We want to do the rotation at origin, but since the bounding
        // rectangle will be changed after rotation, so the delta values
        // are based on old & new width/height respectively.
        int cx = bitmap.getWidth() / 2;
        int cy = bitmap.getHeight() / 2;
        matrix.preTranslate(-cx, -cy);
        matrix.postRotate(rotation);
        matrix.postTranslate(getWidth() / 2, getHeight() / 2);
    }
    return matrix;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:16,代码来源:RotateBitmap.java

示例13: drawResizedBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {

        Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int orientation = Configuration.ORIENTATION_UNDEFINED;
        Point point = new Point();
        getOrient.getSize(point);
        int screen_width = point.x;
        int screen_height = point.y;
        Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
        if (screen_width < screen_height) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
            mScreenRotation = -90;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
            mScreenRotation = 0;
        }

        Assert.assertEquals(dst.getWidth(), dst.getHeight());
        final float minDim = Math.min(src.getWidth(), src.getHeight());

        final Matrix matrix = new Matrix();

        // We only want the center square out of the original rectangle.
        final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
        final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
        matrix.preTranslate(translateX, translateY);

        final float scaleFactor = dst.getHeight() / minDim;
        matrix.postScale(scaleFactor, scaleFactor);

        // Rotate around the center if necessary.
        if (mScreenRotation != 0) {
            matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
            matrix.postRotate(mScreenRotation);
            matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
        }

        final Canvas canvas = new Canvas(dst);
        canvas.drawBitmap(src, matrix, null);
    }
 
开发者ID:gicheonkang,项目名称:fast_face_android,代码行数:41,代码来源:OnGetImageListener.java

示例14: offsetDescendantMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
private static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
    final ViewParent parent = view.getParent();
    if (parent instanceof View && parent != target) {
        final View vp = (View) parent;
        offsetDescendantMatrix(target, vp, m);
        m.preTranslate(-vp.getScrollX(), -vp.getScrollY());
    }

    m.preTranslate(view.getLeft(), view.getTop());

    if (!view.getMatrix().isIdentity()) {
        m.preConcat(view.getMatrix());
    }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:15,代码来源:ViewGroupUtils.java

示例15: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@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 (mRotateX)
        camera.rotateX(degrees);
    else
        camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:28,代码来源:AnimUtil.java


注:本文中的android.graphics.Matrix.preTranslate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。