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


Java Matrix.MTRANS_X属性代码示例

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


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

示例1: fitScreen

/**
 * 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,代码行数:25,代码来源:ViewPortHandler.java

示例2: setZoom

/**
 * Set zoom to the specified scale. Image will be centered around the point
 * (focusX, focusY). These floats range from 0 to 1 and denote the focus point
 * as a fraction from the left and top of the view. For example, the top left
 * corner of the image would be (0, 0). And the bottom right corner would be (1, 1).
 *
 * @param scale
 * @param focusX
 * @param focusY
 * @param scaleType
 */
public void setZoom(float scale, float focusX, float focusY, ScaleType scaleType) {
    //
    // setZoom can be called before the image is on the screen, but at this point,
    // image and view sizes have not yet been calculated in onMeasure. Thus, we should
    // delay calling setZoom until the view has been measured.
    //
    if (!onDrawReady) {
        delayedZoomVariables = new ZoomVariables(scale, focusX, focusY, scaleType);
        return;
    }

    if (scaleType != mScaleType) {
        setScaleType(scaleType);
    }
    resetZoom();
    scaleImage(scale, viewWidth / 2, viewHeight / 2, true);
    matrix.getValues(m);
    m[Matrix.MTRANS_X] = -((focusX * getImageWidth()) - (viewWidth * 0.5f));
    m[Matrix.MTRANS_Y] = -((focusY * getImageHeight()) - (viewHeight * 0.5f));
    matrix.setValues(m);
    fixTrans();
    setImageMatrix(matrix);
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:34,代码来源:TouchImageView.java

示例3: handleImage

@Override
public void handleImage(Canvas canvas, Matrix m) {
    float[] f = new float[9];
    m.getValues(f);
    int dx = (int) f[Matrix.MTRANS_X];
    int dy = (int) f[Matrix.MTRANS_Y];
    float scale_x = f[Matrix.MSCALE_X];
    float scale_y = f[Matrix.MSCALE_Y];
    canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
    canvas.save();
    canvas.translate(dx, dy);
    canvas.scale(scale_x, scale_y);

    if (mHollowView.getPaintBit() != null) {
        canvas.drawBitmap(mHollowView.getPaintBit(), 0, 0, null);
    }
    canvas.restore();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:18,代码来源:HollowFragment.java

示例4: transformCoordTouchToBitmap

/**
 * This function will transform the coordinates in the touch event to the coordinate
 * system of the drawable that the imageview contain
 *
 * @param x            x-coordinate of touch event
 * @param y            y-coordinate of touch event
 * @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
 *                     to the bounds of the bitmap size.
 * @return Coordinates of the point touched, in the coordinate system of the original drawable.
 */
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
    matrix.getValues(m);
    float origW = getDrawable().getIntrinsicWidth();
    float origH = getDrawable().getIntrinsicHeight();
    float transX = m[Matrix.MTRANS_X];
    float transY = m[Matrix.MTRANS_Y];
    float finalX = ((x - transX) * origW) / getImageWidth();
    float finalY = ((y - transY) * origH) / getImageHeight();

    if (clipToBitmap) {
        finalX = Math.min(Math.max(finalX, 0), origW);
        finalY = Math.min(Math.max(finalY, 0), origH);
    }

    return new PointF(finalX, finalY);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:26,代码来源:TouchImageView.java

示例5: transformCoordTouchToBitmap

/**
 * This function will transform the coordinates in the touch event to the coordinate
 * system of the drawable that the imageview contain
 * @param x x-coordinate of touch event
 * @param y y-coordinate of touch event
 * @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
 * 			to the bounds of the bitmap size.
 * @return Coordinates of the point touched, in the coordinate system of the original drawable.
 */
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
    matrix.getValues(m);
    float origW = getDrawable().getIntrinsicWidth();
    float origH = getDrawable().getIntrinsicHeight();
    float transX = m[Matrix.MTRANS_X];
    float transY = m[Matrix.MTRANS_Y];
    float finalX = ((x - transX) * origW) / getImageWidth();
    float finalY = ((y - transY) * origH) / getImageHeight();

    if (clipToBitmap) {
        finalX = Math.min(Math.max(finalX, 0), origW);
        finalY = Math.min(Math.max(finalY, 0), origH);
    }

    return new PointF(finalX , finalY);
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:25,代码来源:TouchImageView.java

示例6: handleImage

@Override
public void handleImage(Canvas canvas, Matrix m) {
    float[] f = new float[9];
    m.getValues(f);
    int dx = (int) f[Matrix.MTRANS_X];
    int dy = (int) f[Matrix.MTRANS_Y];
    float scale_x = f[Matrix.MSCALE_X];
    float scale_y = f[Matrix.MSCALE_Y];
    canvas.save();
    canvas.translate(dx, dy);
    canvas.scale(scale_x, scale_y);

    if (mPaintView.getPaintBit() != null) {
        canvas.drawBitmap(mPaintView.getPaintBit(), 0, 0, null);
    }
    canvas.restore();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:17,代码来源:PaintFragment.java

示例7: canScrollHorizontally

@Override
public boolean canScrollHorizontally(int direction) {
    matrix.getValues(m);
    float x = m[Matrix.MTRANS_X];

    if (getImageWidth() < viewWidth) {
        return false;

    } else if (x >= -1 && direction < 0) {
        return false;

    } else if (Math.abs(x) + viewWidth + 1 >= getImageWidth() && direction > 0) {
        return false;
    }

    return true;
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:17,代码来源:TouchImageView.java

示例8: limitTransAndScale

/**
 * limits the maximum scale and X translation of the given matrix
 *
 * @param matrix
 */
public void limitTransAndScale(Matrix matrix, RectF content) {

    matrix.getValues(matrixBuffer);

    float curTransX = matrixBuffer[Matrix.MTRANS_X];
    float curScaleX = matrixBuffer[Matrix.MSCALE_X];

    float curTransY = matrixBuffer[Matrix.MTRANS_Y];
    float curScaleY = matrixBuffer[Matrix.MSCALE_Y];

    // min scale-x is 1f
    mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX);

    // min scale-y is 1f
    mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY);

    float width = 0f;
    float height = 0f;

    if (content != null) {
        width = content.width();
        height = content.height();
    }

    float maxTransX = -width * (mScaleX - 1f);
    mTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);

    float maxTransY = height * (mScaleY - 1f);
    mTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);

    matrixBuffer[Matrix.MTRANS_X] = mTransX;
    matrixBuffer[Matrix.MSCALE_X] = mScaleX;

    matrixBuffer[Matrix.MTRANS_Y] = mTransY;
    matrixBuffer[Matrix.MSCALE_Y] = mScaleY;

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

示例9: fixTrans

/**
 * Performs boundary checking and fixes the image matrix if it
 * is out of bounds.
 */
private void fixTrans() {
    matrix.getValues(m);
    float transX = m[Matrix.MTRANS_X];
    float transY = m[Matrix.MTRANS_Y];

    float fixTransX = getFixTrans(transX, viewWidth, getImageWidth());
    float fixTransY = getFixTrans(transY, viewHeight, getImageHeight());

    if (fixTransX != 0 || fixTransY != 0) {
        matrix.postTranslate(fixTransX, fixTransY);
    }
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:16,代码来源:TouchImageView.java

示例10: Fling

Fling(int velocityX, int velocityY) {
    setState(State.FLING);
    scroller = new CompatScroller(context);
    matrix.getValues(m);

    int startX = (int) m[Matrix.MTRANS_X];
    int startY = (int) m[Matrix.MTRANS_Y];
    int minX, maxX, minY, maxY;

    if (getImageWidth() > viewWidth) {
        minX = viewWidth - (int) getImageWidth();
        maxX = 0;

    } else {
        minX = maxX = startX;
    }

    if (getImageHeight() > viewHeight) {
        minY = viewHeight - (int) getImageHeight();
        maxY = 0;

    } else {
        minY = maxY = startY;
    }

    scroller.fling(startX, startY, (int) velocityX, (int) velocityY, minX,
            maxX, minY, maxY);
    currX = startX;
    currY = startY;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:30,代码来源:TouchImageView.java

示例11: setZoom

/**
 * Set zoom to the specified scale. Image will be centered around the point
 * (focusX, focusY). These floats range from 0 to 1 and denote the focus
 * point as a fraction from the left and top of the view. For example, the
 * top left corner of the image would be (0, 0). And the bottom right corner
 * would be (1, 1).
 * 
 * @param scale
 * @param focusX
 * @param focusY
 * @param scaleType
 */
public void setZoom(float scale, float focusX, float focusY,
		ScaleType scaleType) {
	//
	// setZoom can be called before the image is on the screen, but at this
	// point,
	// image and view sizes have not yet been calculated in onMeasure. Thus,
	// we should
	// delay calling setZoom until the view has been measured.
	//
	if (!onDrawReady) {
		delayedZoomVariables = new ZoomVariables(scale, focusX, focusY,
				scaleType);
		return;
	}

	if (scaleType != mScaleType) {
		setScaleType(scaleType);
	}
	resetZoom();
	scaleImage(scale, viewWidth / 2, viewHeight / 2, true);
	matrix.getValues(m);
	m[Matrix.MTRANS_X] = -((focusX * getImageWidth()) - (viewWidth * 0.5f));
	m[Matrix.MTRANS_Y] = -((focusY * getImageHeight()) - (viewHeight * 0.5f));
	matrix.setValues(m);
	fixTrans();
	setImageMatrix(matrix);
}
 
开发者ID:newsof1111,项目名称:cordova-plugin-video-picture-preview-picker-V2,代码行数:39,代码来源:TouchImageView.java

示例12: transformCoordBitmapToTouch

/**
 * Inverse of transformCoordTouchToBitmap. This function will transform the coordinates in the
 * drawable's coordinate system to the view's coordinate system.
 * @param bx x-coordinate in original bitmap coordinate system
 * @param by y-coordinate in original bitmap coordinate system
 * @return Coordinates of the point in the view's coordinate system.
 */
private PointF transformCoordBitmapToTouch(float bx, float by) {
    matrix.getValues(m);
    float origW = getDrawable().getIntrinsicWidth();
    float origH = getDrawable().getIntrinsicHeight();
    float px = bx / origW;
    float py = by / origH;
    float finalX = m[Matrix.MTRANS_X] + getImageWidth() * px;
    float finalY = m[Matrix.MTRANS_Y] + getImageHeight() * py;
    return new PointF(finalX , finalY);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:17,代码来源:TouchImageView.java

示例13: fixScaleTrans

/**
 * When transitioning from zooming from focus to zoom from center (or vice versa)
 * the image can become unaligned within the view. This is apparent when zooming
 * quickly. When the content size is less than the view size, the content will often
 * be centered incorrectly within the view. fixScaleTrans first calls fixTrans() and
 * then makes sure the image is centered correctly within the view.
 */
private void fixScaleTrans() {
    fixTrans();
    matrix.getValues(m);
    if (getImageWidth() < viewWidth) {
        m[Matrix.MTRANS_X] = (viewWidth - getImageWidth()) / 2;
    }

    if (getImageHeight() < viewHeight) {
        m[Matrix.MTRANS_Y] = (viewHeight - getImageHeight()) / 2;
    }
    matrix.setValues(m);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:19,代码来源:TouchImageView.java

示例14: Fling

Fling(int velocityX, int velocityY) {
	setState(State.FLING);
	scroller = new CompatScroller(context);
	matrix.getValues(m);
	
	int startX = (int) m[Matrix.MTRANS_X];
	int startY = (int) m[Matrix.MTRANS_Y];
	int minX, maxX, minY, maxY;
	
	if (getImageWidth() > viewWidth) {
		minX = viewWidth - (int) getImageWidth();
		maxX = 0;
		
	} else {
		minX = maxX = startX;
	}
	
	if (getImageHeight() > viewHeight) {
		minY = viewHeight - (int) getImageHeight();
		maxY = 0;
		
	} else {
		minY = maxY = startY;
	}
	
	scroller.fling(startX, startY, (int) velocityX, (int) velocityY, minX,
               maxX, minY, maxY);
	currX = startX;
	currY = startY;
}
 
开发者ID:wajahatkarim3,项目名称:LongImageCamera,代码行数:30,代码来源:TouchImageView.java

示例15: transformCoordBitmapToTouch

/**
 * Inverse of transformCoordTouchToBitmap. This function will transform the coordinates in the
 * drawable's coordinate system to the view's coordinate system.
 *
 * @param bx x-coordinate in original bitmap coordinate system
 * @param by y-coordinate in original bitmap coordinate system
 * @return Coordinates of the point in the view's coordinate system.
 */
private PointF transformCoordBitmapToTouch(float bx, float by) {
    matrix.getValues(m);
    float origW = getDrawable().getIntrinsicWidth();
    float origH = getDrawable().getIntrinsicHeight();
    float px = bx / origW;
    float py = by / origH;
    float finalX = m[Matrix.MTRANS_X] + getImageWidth() * px;
    float finalY = m[Matrix.MTRANS_Y] + getImageHeight() * py;
    return new PointF(finalX, finalY);
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:18,代码来源:ZoomImageView.java


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