Matrix mapPoints - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Matrix mapPoints method.

This code example shows how to use the following methods:mapPoints, postTranslate, preTranslate, reset
	private Matrix mMatrix = new Matrix();
	private Camera mCamera = new Camera();
	private float[] mTempFloat2 = new float[2];
 
	protected float getOffsetXForRotation(float degrees, int width, int height) {
		mMatrix.reset();
		mCamera.save();
		mCamera.rotateY(Math.abs(degrees));
		mCamera.getMatrix(mMatrix);
		mCamera.restore();
 
		mMatrix.preTranslate(-width * 0.5f, -height * 0.5f);
		mMatrix.postTranslate(width * 0.5f, height * 0.5f);
		mTempFloat2[0] = width;
		mTempFloat2[1] = height;
		mMatrix.mapPoints(mTempFloat2);
		return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
	} 
 
	protected void animateFade(View left, View right, float positionOffset) {
		if (left != null) {
7
CodeRank
This code example shows how to use the following methods:mapPoints, postRotate, postScale, postTranslate
 
		this.testTransformationVsMatrix(points);
	} 
 
	public void testPostComplex() { 
		this.mMatrix.postTranslate(10, 2);
		this.mTransformation.postTranslate(10, 2);
 
		this.mMatrix.postScale(3, 2);
		this.mTransformation.postScale(3, 2);
 
		this.mMatrix.postRotate(3);
		this.mTransformation.postRotate(3);
 
		this.mMatrix.postScale(2, 2);
		this.mTransformation.postScale(2, 2);
 
		this.mMatrix.postTranslate(-10, 10);
		this.mTransformation.postTranslate(-10, 10);
 

7
CodeRank
This code example shows how to use the following methods:mapPoints, setTranslate
	} 
	 
	private void ensureVisibility(int screen_width, int screen_height)
	{ 
		float []curPos = new float[2];
		translationMatrix.mapPoints(curPos);
		 
	    if (curPos[0] > (screen_width - pointerRect.width()))
	    	curPos[0] = screen_width - pointerRect.width();
	    if (curPos[0] < 0)
	    	curPos[0] = 0;
	    if (curPos[1] > (screen_height - pointerRect.height()))
	    	curPos[1] = screen_height - pointerRect.height();
	    if (curPos[1] < 0)
	    	curPos[1] = 0;
 
	    translationMatrix.setTranslate(curPos[0], curPos[1]);
	    setImageMatrix(translationMatrix);	
	} 
	 

7
CodeRank
This code example shows how to use the following methods:mapPoints, postRotate, postTranslate
		final RectF rect = new RectF( mDrawRect );
		rect.inset( -mPadding, -mPadding );
 
		final float pts[] = new float[] { x, y };
 
		final Matrix rotateMatrix = new Matrix();
		rotateMatrix.postTranslate( -rect.centerX(), -rect.centerY() );
		rotateMatrix.postRotate( -mRotation );
		rotateMatrix.postTranslate( rect.centerX(), rect.centerY() );
		rotateMatrix.mapPoints( pts );
 
		x = pts[0];
		y = pts[1];
 
		mContext.invalidate();
 
		int retval = DrawableHighlightView.GROW_NONE;
		final boolean verticalCheck = ( y >= ( rect.top - DrawableHighlightView.HIT_TOLERANCE ) )
				&& ( y < ( rect.bottom + DrawableHighlightView.HIT_TOLERANCE ) );
		final boolean horizCheck = ( x >= ( rect.left - DrawableHighlightView.HIT_TOLERANCE ) )
6
CodeRank
This code example shows how to use the following methods:mapPoints, postConcat, set
        return true; 
    } 
 
    // Translate a given point through a given matrix. 
    static private void translatePoint(Matrix matrix, float [] xy) {
        matrix.mapPoints(xy);
    } 
 
    // Return the mapped x coordinate through the matrix. 
    static int mapXPoint(Matrix matrix, int point) {
        // Matrix's mapPoints takes an array of x/y coordinates. 
        // That's why we have to allocte an array of length two 
        // even though we don't use the y coordinate. 
        float [] xy = new float[2];
        xy[0] = point;
        xy[1] = 0F;
        matrix.mapPoints(xy);
        return (int) xy[0];
    } 
     

6
CodeRank
This code example shows how to use the following methods:mapPoints, postTranslate, setRotate
    if (screenView == null || imageWidth <= 0 || imageHeight <= 0) {
      imageToScreenMatrix = null;
      return; 
    } 
    // First rotate image keeping upper left at (0, 0) 
    imageToScreenMatrix = new Matrix();
    if (imageOrientation != 0) {
      imageToScreenMatrix.setRotate(imageOrientation);
      int translateX = 0;
      int translateY = 0;
      if (imageOrientation == 90) {
        translateX = imageHeight;
      } else if (imageOrientation == 180) {
        translateX = imageWidth;
        translateY = imageHeight;
      } else if (imageOrientation == 270) {
        translateY = imageWidth;
      } 
      imageToScreenMatrix.postTranslate(translateX, translateY);
    } 

6
CodeRank
This code example shows how to use the following methods:mapPoints, mapRect, postRotate, postTranslate
       dstPs = srcPs.clone();  
       srcRect = new RectF(0, 0, mainBmpWidth, mainBmpHeight);  
       dstRect = new RectF();  
       txtBackgroundRect = new RectF(0 - 5, mainBmpHeight - 5, mainBmpWidth + 5, mainBmpHeight + 10);
          
       matrix = new Matrix();  
          
       paint = new Paint();
        
       paintRect = new Paint();  
       paintRect.setColor(Color.RED);  
       paintRect.setAlpha(100);  
       paintRect.setAntiAlias(true);  
           
       paintFrame = new Paint();  
       paintFrame.setColor(Color.WHITE);  
       paintFrame.setAntiAlias(true);  
       paintFrame.setStyle(Paint.Style.STROKE);
       paintFrame.setStrokeWidth(10); 
           

6
CodeRank
This code example shows how to use the following methods:mapPoints, postTranslate, setRotate
    public Path toPath() {
        Path path = new Path();
        float[] point = new float[2];
        point[0] = -width / 2;
        point[1] = height / 2;
        Matrix matrix = new Matrix();
        matrix.setRotate(orientation);
        matrix.postTranslate(centerX, centerY);
        matrix.mapPoints(point);
        path.moveTo(point[0], point[1]);
 
        point[0] = -width / 2;
        point[1] = -height / 2;
        matrix.mapPoints(point);
        path.lineTo(point[0], point[1]);
 
        point[0] = width / 2;
        point[1] = -height / 2;
        matrix.mapPoints(point);
        path.lineTo(point[0], point[1]);

6
CodeRank
This code example shows how to use the following methods:mapPoints, postRotate, setPolyToPoly
    if (geoToMetric == null) {
      initializeGeoToMetricMatrix(); 
    } 
    // Map the given location to image space and check if it fits within the image area 
    float[] location = { longitude, latitude };
    geoToMetric.mapPoints(location);
    return (0 < location[0] && location[0] < metricSize[0] &&
            0 < location[1] && location[1] < metricSize[1]);
  } 
 
  /** 
   * Finds the shortest distance from the given point to the map area. If the 
   * given point is within the map boundaries, returns 0. The returned distance 
   * is in meters. 
   * 
   * @param longitude of the location to check 
   * @param latitude of the location to check 
   * @return distance in meters from the point to the edge of the map, or 0 if 
   *         the point is within the map boundaries 
   */ 

6
CodeRank
This code example shows how to use the following methods:mapPoints, postTranslate, preTranslate, reset
	private Matrix	mMatrix		= new Matrix();
	private Camera	mCamera		= new Camera();
	private float[]	mTempFloat2	= new float[2];
 
	protected float getOffsetXForRotation(float degrees, int width, int height) {
		mMatrix.reset();
		mCamera.save();
		mCamera.rotateY(Math.abs(degrees));
		mCamera.getMatrix(mMatrix);
		mCamera.restore();
 
		mMatrix.preTranslate(-width * 0.5f, -height * 0.5f);
		mMatrix.postTranslate(width * 0.5f, height * 0.5f);
		mTempFloat2[0] = width;
		mTempFloat2[1] = height;
		mMatrix.mapPoints(mTempFloat2);
		return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
	} 
 
	protected void animateFade(View left, View right, float positionOffset) {
		if (left != null) {
5
CodeRank
mapPoints Method Overview
Apply this matrix to the array of 2D points, and write the transformed points back into the array
See Code Examples for other Android Matrix Methods: