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


Java Matrix.set方法代码示例

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


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

示例1: calculateGestureTransform

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Calculates the zoom transformation based on the current gesture.
 *
 * @param outTransform the matrix to store the result to
 * @param limitTypes whether to limit translation and/or scale.
 * @return whether or not the transform has been corrected due to limitation
 */
protected boolean calculateGestureTransform(
    Matrix outTransform,
    @LimitFlag int limitTypes) {
  TransformGestureDetector detector = mGestureDetector;
  boolean transformCorrected = false;
  outTransform.set(mPreviousTransform);
  if (mIsRotationEnabled) {
    float angle = detector.getRotation() * (float) (180 / Math.PI);
    outTransform.postRotate(angle, detector.getPivotX(), detector.getPivotY());
  }
  if (mIsScaleEnabled) {
    float scale = detector.getScale();
    outTransform.postScale(scale, scale, detector.getPivotX(), detector.getPivotY());
  }
  transformCorrected |=
      limitScale(outTransform, detector.getPivotX(), detector.getPivotY(), limitTypes);
  if (mIsTranslationEnabled) {
    outTransform.postTranslate(detector.getTranslationX(), detector.getTranslationY());
  }
  transformCorrected |= limitTranslation(outTransform, limitTypes);
  return transformCorrected;
}
 
开发者ID:idisfkj,项目名称:Zoomable,代码行数:30,代码来源:DefaultZoomableController.java

示例2: isXSide

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * @param current
 * @return
 */
private boolean isXSide(PointF current) {
    Matrix retainMatrix = new Matrix();
    retainMatrix.set(matrix);

    float deltaX = getMoveDraggingDelta(current.x - last.x, viewWidth,
            afterScaleDrawableWidth * currentScale);
    float deltaY = getMoveDraggingDelta(current.y - last.y, viewHeight,
            afterScaleDrawableHeight * currentScale);
    retainMatrix.postTranslate(deltaX, deltaY);

    retainMatrix.getValues(finalTransformation);
    float finalXTransformation = finalTransformation[Matrix.MTRANS_X];

    float deltaX1 = getScaleDraggingDelta(finalXTransformation, viewWidth,
            afterScaleDrawableWidth * currentScale);

    return deltaX + deltaX1 == 0;
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:23,代码来源:ZoomableImageView.java

示例3: setUpScaleType

import android.graphics.Matrix; //导入方法依赖的package包/类
private Matrix setUpScaleType(Bitmap bitmap, ImageView iv, float width, float height) {
    float scaleX = 1, scaleY = 1, dx = 0, dy = 0;
    Matrix shaderMatrix = new Matrix();
    if (bitmap == null) {
        return null;
    }
    shaderMatrix.set(null);
    if (iv.getScaleType() == ImageView.ScaleType.CENTER_CROP) {
        if (width != bitmap.getWidth()) {
            scaleX = width / bitmap.getWidth();
        }
        if (scaleX * bitmap.getHeight() < height) {
            scaleX = height / bitmap.getHeight();
        }
        dy = (height - bitmap.getHeight() * scaleX) * 0.5f;
        dx = (width - bitmap.getWidth() * scaleX) * 0.5f;
        shaderMatrix.setScale(scaleX, scaleX);
    } else {
        scaleX = width / bitmap.getWidth();
        scaleY = height / bitmap.getHeight();
        dy = (height - bitmap.getHeight() * scaleY) * 0.5f;
        dx = (width - bitmap.getWidth() * scaleX) * 0.5f;
        shaderMatrix.setScale(scaleX, scaleY);
    }
    shaderMatrix.postTranslate(dx + 0.5f, dy + 0.5f);
    return shaderMatrix;
}
 
开发者ID:akshay2211,项目名称:Oblique,代码行数:28,代码来源:ObliqueView.java

示例4: fitScreen

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Resets all zooming and dragging and makes the chart fit exactly it's
 * bounds.  Output Matrix is available for those who wish to cache the object.
 */
public void fitScreen(Matrix outputMatrix) {
    mMinScaleX = 1f;
    mMinScaleY = 1f;

    outputMatrix.set(mMatrixTouch);

    float[] vals = valsBufferForFitScreen;
    for (int i = 0; i < 9; i++) {
        vals[i] = 0;
    }

    outputMatrix.getValues(vals);

    // reset all translations and scaling
    vals[Matrix.MTRANS_X] = 0f;
    vals[Matrix.MTRANS_Y] = 0f;
    vals[Matrix.MSCALE_X] = 1f;
    vals[Matrix.MSCALE_Y] = 1f;

    outputMatrix.setValues(vals);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ViewPortHandler.java

示例5: updateShaderMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
private BitmapShader updateShaderMatrix(BitmapShader shader) {
    float scale;
    float dx = 0;
    float dy = 0;

    calculateBounds();

    Matrix shaderMatrix = new Matrix();
    shaderMatrix.set(null);

    if (mBitmapWidth * mBoundsRect.height() > mBitmapHeight * mBoundsRect.width()) {
        scale = mBoundsRect.height() / (float) mBitmapHeight;
        dx = (mBoundsRect.width() - mBitmapWidth * scale) * 0.5f;

    } else {
        scale = mBoundsRect.width() / (float) mBitmapWidth;
        dy = (mBoundsRect.height() - mBitmapHeight * scale) * 0.5f;
    }

    shaderMatrix.setScale(scale, scale);
    shaderMatrix.postTranslate((int)(dx + 0.5f) + mBoundsRect.left, (int)(dy + 0.5f) + mBoundsRect.top);

    shader.setLocalMatrix(shaderMatrix);

    return shader;
}
 
开发者ID:WGPlaner,项目名称:wg_planer,代码行数:27,代码来源:CircularImageView.java

示例6: centerViewPort

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Centers the viewport around the specified position (x-index and y-value)
 * in the chart. Centering the viewport outside the bounds of the chart is
 * not possible. Makes most sense in combination with the
 * setScaleMinima(...) method.
 *
 * @param transformedPts the position to center view viewport to
 * @param view
 * @return save
 */
public void centerViewPort(final float[] transformedPts, final View view) {

    Matrix save = mCenterViewPortMatrixBuffer;
    save.reset();
    save.set(mMatrixTouch);

    final float x = transformedPts[0] - offsetLeft();
    final float y = transformedPts[1] - offsetTop();

    save.postTranslate(-x, -y);

    refresh(save, view, true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ViewPortHandler.java

示例7: center

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 横向、纵向居中
 */
protected void center(boolean horizontal, boolean vertical) {

	 Matrix m = new Matrix();
     m.set(matrix);
     RectF rect = new RectF(0, 0, pic.getWidth(), pic.getHeight());
     m.mapRect(rect);

     float height = rect.height();
     float width = rect.width();

     float deltaX = 0, deltaY = 0;

     if (vertical) {
         // 图片小于屏幕大小,则居中显示。大于屏幕,上方留空则往上移,下方留空则往下移
         int screenHeight = dm.heightPixels;
         if (height < screenHeight) {
             deltaY = (screenHeight - height) / 2 - rect.top;
         } else if (rect.top > 0) {
             deltaY = -rect.top;
         } else if (rect.bottom < screenHeight) {
             deltaY = ivViewer.getHeight() - rect.bottom;
         }
     }

     if (horizontal) {
         int screenWidth = dm.widthPixels;
         if (width < screenWidth) {
             deltaX = (screenWidth - width) / 2 - rect.left;
         } else if (rect.left > 0) {
             deltaX = -rect.left;
         } else if (rect.right < screenWidth) {
             deltaX = ivViewer.getWidth() - rect.right;
         }
     }
     matrix.postTranslate(deltaX, deltaY);
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:40,代码来源:PicViewer.java

示例8: getSuppMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Get the current support matrix
 */
public void getSuppMatrix(Matrix matrix) {
    matrix.set(mSuppMatrix);
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:7,代码来源:PhotoViewAttacher.java

示例9: zoomIn

import android.graphics.Matrix; //导入方法依赖的package包/类
public void zoomIn(float x, float y, Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    outputMatrix.postScale(1.4f, 1.4f, x, y);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ViewPortHandler.java

示例10: resetZoom

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Zooms out to original size.
 * @param outputMatrix
 */
public void resetZoom(Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    outputMatrix.postScale(1.0f, 1.0f, 0.0f, 0.0f);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ViewPortHandler.java

示例11: resetZoom

import android.graphics.Matrix; //导入方法依赖的package包/类
public void resetZoom() {
    Matrix mCurrentMatrix = new Matrix();
    mCurrentMatrix.set(mMatrix);//初始化Matrix
    mCurrentMatrix.postScale(1, 1,getWidth()/2,getHeight()/2);
    setImageMatrix(mCurrentMatrix);
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:7,代码来源:MatrixImageView.java

示例12: getDisplayMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Get the display matrix
 * @param matrix target matrix to copy to
 */
@Override
public void getDisplayMatrix(Matrix matrix) {
    matrix.set(getDrawMatrix());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:PhotoViewAttacher.java

示例13: getSuppMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
public void getSuppMatrix(Matrix matrix) {
    matrix.set(this.mSuppMatrix);
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:4,代码来源:PhotoViewAttacher.java

示例14: updateTextureViewSize

import android.graphics.Matrix; //导入方法依赖的package包/类
private void updateTextureViewSize(final GifInfoHandle gifInfoHandle) {
	final Matrix transform = new Matrix();
	final float viewWidth = getWidth();
	final float viewHeight = getHeight();
	final float scaleRef;
	final float scaleX = gifInfoHandle.width / viewWidth;
	final float scaleY = gifInfoHandle.height / viewHeight;
	RectF src = new RectF(0, 0, gifInfoHandle.width, gifInfoHandle.height);
	RectF dst = new RectF(0, 0, viewWidth, viewHeight);
	switch (mScaleType) {
	case CENTER:
		transform.setScale(scaleX, scaleY, viewWidth / 2, viewHeight / 2);
		break;
	case CENTER_CROP:
		scaleRef = 1 / Math.min(scaleX, scaleY);
		transform.setScale(scaleRef * scaleX, scaleRef * scaleY,
				viewWidth / 2, viewHeight / 2);
		break;
	case CENTER_INSIDE:
		if (gifInfoHandle.width <= viewWidth
				&& gifInfoHandle.height <= viewHeight) {
			scaleRef = 1.0f;
		} else {
			scaleRef = Math.min(1 / scaleX, 1 / scaleY);
		}
		transform.setScale(scaleRef * scaleX, scaleRef * scaleY,
				viewWidth / 2, viewHeight / 2);
		break;
	case FIT_CENTER:
		transform.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
		transform.preScale(scaleX, scaleY);
		break;
	case FIT_END:
		transform.setRectToRect(src, dst, Matrix.ScaleToFit.END);
		transform.preScale(scaleX, scaleY);
		break;
	case FIT_START:
		transform.setRectToRect(src, dst, Matrix.ScaleToFit.START);
		transform.preScale(scaleX, scaleY);
		break;
	case FIT_XY:
		return;
	case MATRIX:
		transform.set(mTransform);
		transform.preScale(scaleX, scaleY);
		break;
	}
	super.setTransform(transform);
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:50,代码来源:GifTextureView.java

示例15: getDisplayMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Get the display matrix
 *
 * @param matrix target matrix to copy to
 */
@Override
public void getDisplayMatrix(Matrix matrix) {
    matrix.set(getDrawMatrix());
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:10,代码来源:PhotoViewAttacher.java


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