Example usage for android.graphics Matrix reset

List of usage examples for android.graphics Matrix reset

Introduction

In this page you can find the example usage for android.graphics Matrix reset.

Prototype

public void reset() 

Source Link

Document

Set the matrix to identity

Usage

From source file:android.support.transition.ChangeTransform.java

private void setMatricesForParent(TransitionValues startValues, TransitionValues endValues) {
    Matrix endParentMatrix = (Matrix) endValues.values.get(PROPNAME_PARENT_MATRIX);
    endValues.view.setTag(R.id.parent_matrix, endParentMatrix);

    Matrix toLocal = mTempMatrix;
    toLocal.reset();
    endParentMatrix.invert(toLocal);//from  w  ww . j a  v a  2  s.co  m

    Matrix startLocal = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    if (startLocal == null) {
        startLocal = new Matrix();
        startValues.values.put(PROPNAME_MATRIX, startLocal);
    }

    Matrix startParentMatrix = (Matrix) startValues.values.get(PROPNAME_PARENT_MATRIX);
    startLocal.postConcat(startParentMatrix);
    startLocal.postConcat(toLocal);
}

From source file:com.artioml.practice.activities.LicenseActivity.java

public BitmapDrawable drawParallelogramLine(int width) {
    Matrix matrix = new Matrix();
    Path path = new Path();
    path.addRect(0, 0, (4 * width) / 40, (4 * width) / 200, Path.Direction.CW);
    Path pathStamp = new Path();
    Paint p;/*w  w w  .  j  a  va2  s. co m*/
    Bitmap bitmap;

    p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setStyle(Paint.Style.FILL);

    bitmap = Bitmap.createBitmap(width / 4, width / 80 * 2 + (4 * width) / 200, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    p.setColor(ContextCompat.getColor(this, R.color.colorPrimaryLight));

    matrix.reset();
    matrix.setTranslate(0, 0);
    matrix.postSkew(-1f, 0.0f, 0, (4 * width) / 200);
    path.transform(matrix, pathStamp);
    canvas.drawPath(pathStamp, p);

    p.setColor(ContextCompat.getColor(this, R.color.colorAccent));

    matrix.reset();
    matrix.setTranslate(width / 8, 0);
    matrix.postSkew(-1f, 0.0f, width / 8, (4 * width) / 200);
    path.transform(matrix, pathStamp);
    canvas.drawPath(pathStamp, p);

    BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
    bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);

    return bitmapDrawable;
}

From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java

private void setBaseMatrix(Bitmap bitmap, Matrix matrix) {
    float viewWidth = getWidth();
    float viewHeight = getHeight();

    matrix.reset();
    float widthScale = Math.min(viewWidth / (float) bitmap.getWidth(), 1.0f);
    float heightScale = Math.min(viewHeight / (float) bitmap.getHeight(), 1.0f);
    float scale;/* w  w w  .  jav  a  2  s .  c o  m*/
    if (widthScale > heightScale) {
        scale = heightScale;
    } else {
        scale = widthScale;
    }
    matrix.setScale(scale, scale);
    matrix.postTranslate((viewWidth - ((float) bitmap.getWidth() * scale)) / 2F,
            (viewHeight - ((float) bitmap.getHeight() * scale)) / 2F);
}

From source file:de.tlabs.ssr.g1.client.SourcesView.java

private void recalculateViewportTransformation(Matrix dstMatrix, float centerRotation, float scaling,
        float[] translation) {
    dstMatrix.reset();
    // translate to center
    dstMatrix.preTranslate((float) getWidth() / 2.0f, (float) getHeight() / 2.0f);
    // rotate around center
    dstMatrix.preRotate(-centerRotation); // negative rotation, because y axis not yet inverted
    // translate//  w  w  w  . j a v a  2  s.  c o m
    dstMatrix.preTranslate(translation[0], translation[1]);
    // scale and invert y axis
    dstMatrix.preScale(scaling, -scaling);
    // rotate to look north always (instead of east)
    dstMatrix.preRotate(90.0f);
}

From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java

/**
 *  Setup the base matrix so that the image is centered and scaled properly.
 * ?BitmapRect?Matrix//ww  w  .j  a  va2  s . c o m
 * @author Linleja
 * @date 2014-4-29
 * @param bitmap
 * @param matrix
 * @param selection
 */
private void setBaseMatrix(Bitmap bitmap, Matrix matrix, Rect selection) {
    if (selection == null) {
        return;
    }

    float viewWidth = selection.right - selection.left;
    float viewHeight = selection.bottom - selection.top;

    matrix.reset();

    float widthRatio = viewWidth / (float) bitmap.getWidth();
    float heighRatio = viewHeight / (float) bitmap.getHeight();
    float scale = 1.0f;
    if (widthRatio > heighRatio) {
        scale = widthRatio;

    } else {
        scale = heighRatio;

    }

    matrix.setScale(scale, scale);
    matrix.postTranslate(((getWidth() - (float) bitmap.getWidth() * scale)) / 2F,
            ((getHeight() - (float) bitmap.getHeight() * scale)) / 2F);
}

From source file:org.adw.library.widgets.discreteseekbar.internal.drawable.MarkerDrawable.java

private void computePath(Rect bounds) {
    final float currentScale = mCurrentScale;
    final Path path = mPath;
    final RectF rect = mRect;
    final Matrix matrix = mMatrix;

    path.reset();//from  ww  w.  j a v a  2  s.  c  o m
    int totalSize = Math.min(bounds.width(), bounds.height());

    float initial = mClosedStateSize;
    float destination = totalSize;
    float currentSize = initial + (destination - initial) * currentScale;

    float halfSize = currentSize / 2f;
    float inverseScale = 1f - currentScale;
    float cornerSize = halfSize * inverseScale;
    float[] corners = new float[] { halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize,
            cornerSize };
    rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize);
    path.addRoundRect(rect, corners, Path.Direction.CCW);
    matrix.reset();
    matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize);
    matrix.postTranslate((bounds.width() - currentSize) / 2, 0);
    float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
    matrix.postTranslate(0, hDiff);
    path.transform(matrix);
}

From source file:com.goka.flickableview.ImageViewTouchBase.java

protected void getProperBaseMatrix(Drawable drawable, Matrix matrix, RectF rect) {
    float w = mBitmapRect.width();
    float h = mBitmapRect.height();
    float widthScale, heightScale;

    matrix.reset();

    widthScale = rect.width() / w;/*w  w  w.j  a va2 s . c o m*/
    heightScale = rect.height() / h;
    float scale = Math.min(widthScale, heightScale);
    matrix.postScale(scale, scale);
    matrix.postTranslate(rect.left, rect.top);

    float tw = (rect.width() - w * scale) / 2.0f;
    float th = (rect.height() - h * scale) / 2.0f;
    matrix.postTranslate(tw, th);
    printMatrix(matrix);
}

From source file:com.skumar.flexibleciruclarseekbar.CircularSeekBar.java

/**
 * Method to drawing the gradient color for the arc
 *///from  w w w.j a va 2  s.co m
public void setShader() {
    SweepGradient sweepgradient = new SweepGradient(mArcRadius, mArcRadius, Color.parseColor("#2f8bca"),
            Color.parseColor("#c91200"));
    Matrix matrix = new Matrix();
    matrix.reset();
    sweepgradient.getLocalMatrix(matrix);
    matrix.postRotate(90, mArcRadius, mArcRadius);
    sweepgradient.setLocalMatrix(matrix);
    mArcPaint.setShader(sweepgradient);
    mNeedleScalePaint.setShader(sweepgradient);
}

From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java

private void setChildTransformation(View child, Matrix m) {
    m.reset();

    // TODO FIXME
    //        addChildRotation(child, m);
    addChildScale(child, m);/*w ww  .java  2s .c  o  m*/
    addChildCircularPathZOffset(child, m);
    addChildAdjustPosition(child, m);

    //set coordinate system origin to center of child
    m.preTranslate(-child.getWidth() / 2f, -child.getHeight() / 2f);
    //move back
    m.postTranslate(child.getWidth() / 2f, child.getHeight() / 2f);

}