Java Code Examples for android.graphics.Matrix#isIdentity()
The following examples show how to use
android.graphics.Matrix#isIdentity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationMatrix.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
static @NonNull AnimationMatrix animate(@NonNull Matrix from, @NonNull Matrix to, @Nullable Runnable invalidate) { if (invalidate == null) { return NULL; } Matrix undo = new Matrix(); boolean inverted = to.invert(undo); if (inverted) { undo.preConcat(from); } if (inverted && !undo.isIdentity()) { AnimationMatrix animationMatrix = new AnimationMatrix(undo, invalidate); animationMatrix.start(interpolator); return animationMatrix; } else { return NULL; } }
Example 2
Source File: BaseZoomableImageView.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public void setImageMatrix(Matrix m){ if (m != null && m.isIdentity()) { m = null; } // don't invalidate unless we're actually changing our matrix if (m == null && !this.mMatrix.isIdentity() || m != null && !this.mMatrix.equals(m)) { this.mMatrix.set(m); invalidate(); } }
Example 3
Source File: GridLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 4
Source File: RelativeLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 5
Source File: TextView.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 6
Source File: CollapsingToolbarLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 7
Source File: AppBarLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 8
Source File: View.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 9
Source File: RecyclerView.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 10
Source File: BaseZoomableImageView.java From NIM_Android_UIKit with MIT License | 5 votes |
public void setImageMatrix(Matrix m) { if (m != null && m.isIdentity()) { m = null; } // don't invalidate unless we're actually changing our matrix if (m == null && !this.mMatrix.isIdentity() || m != null && !this.mMatrix.equals(m)) { this.mMatrix.set(m); invalidate(); } }
Example 11
Source File: Toolbar.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 12
Source File: SplitImageView.java From SplitImageView with Apache License 2.0 | 5 votes |
public void setImageMatrix(Matrix matrix) { // collaps null and identity to just null if (matrix != null && matrix.isIdentity()) { matrix = null; } // don't invalidate unless we're actually changing our matrix if (matrix == null && !mMatrix.isIdentity() || matrix != null && !mMatrix.equals(matrix)) { mMatrix.set(matrix); configureBounds(); invalidate(); } }
Example 13
Source File: FlowLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 14
Source File: CoordinatorLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 15
Source File: ImageViewTouchBase.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void setImageMatrix( Matrix matrix ) { Matrix current = getImageMatrix(); boolean needUpdate = false; if ( matrix == null && !current.isIdentity() || matrix != null && !current.equals( matrix ) ) { needUpdate = true; } super.setImageMatrix( matrix ); if ( needUpdate ) onImageMatrixChanged(); }
Example 16
Source File: ClipPathLayoutDelegate.java From ClipPathLayout with Apache License 2.0 | 5 votes |
private void transformPointToViewLocal(float[] point, View child) { point[0] += mParent.getScrollX() - child.getLeft(); point[1] += mParent.getScrollY() - child.getTop(); Matrix matrix = child.getMatrix(); if (!matrix.isIdentity()) { Matrix invert = getTempMatrix(); boolean result = matrix.invert(invert); if (result) { invert.mapPoints(point); } } }
Example 17
Source File: MotionLayout.java From Carbon with Apache License 2.0 | 5 votes |
public void getHitRect(@NonNull Rect outRect) { Matrix matrix = getMatrix(); if (matrix.isIdentity()) { outRect.set(getLeft(), getTop(), getRight(), getBottom()); } else { tmpHitRect.set(0, 0, getWidth(), getHeight()); matrix.mapRect(tmpHitRect); outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(), (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop()); } outRect.left -= touchMargin.left; outRect.top -= touchMargin.top; outRect.right += touchMargin.right; outRect.bottom += touchMargin.bottom; }
Example 18
Source File: TransformationUtils.java From giffun with Apache License 2.0 | 5 votes |
/** * Rotate and/or flip the image to match the given exif orientation. * * @param toOrient The bitmap to rotate/flip. * @param pool A pool that may or may not contain an image of the necessary dimensions. * @param exifOrientation the exif orientation [1-8]. * @return The rotated and/or flipped image or toOrient if no rotation or flip was necessary. */ public static Bitmap rotateImageExif(Bitmap toOrient, BitmapPool pool, int exifOrientation) { final Matrix matrix = new Matrix(); initializeMatrixForRotation(exifOrientation, matrix); if (matrix.isIdentity()) { return toOrient; } // From Bitmap.createBitmap. final RectF newRect = new RectF(0, 0, toOrient.getWidth(), toOrient.getHeight()); matrix.mapRect(newRect); final int newWidth = Math.round(newRect.width()); final int newHeight = Math.round(newRect.height()); Bitmap.Config config = getSafeConfig(toOrient); Bitmap result = pool.get(newWidth, newHeight, config); if (result == null) { result = Bitmap.createBitmap(newWidth, newHeight, config); } matrix.postTranslate(-newRect.left, -newRect.top); final Canvas canvas = new Canvas(result); final Paint paint = new Paint(PAINT_FLAGS); canvas.drawBitmap(toOrient, matrix, paint); return result; }
Example 19
Source File: EditorModel.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onReady(@NonNull Renderer renderer, @Nullable Matrix cropMatrix, @Nullable Point size) { if (cropMatrix != null && size != null && isRendererOfMainImage(renderer)) { boolean changedBefore = isChanged(); Matrix imageCropMatrix = editorElementHierarchy.getImageCrop().getLocalMatrix(); this.size.set(size.x, size.y); if (imageCropMatrix.isIdentity()) { imageCropMatrix.set(cropMatrix); if (circleEditing) { Matrix userCropMatrix = editorElementHierarchy.getCropEditorElement().getLocalMatrix(); if (size.x > size.y) { userCropMatrix.setScale(size.y / (float) size.x, 1f); } else { userCropMatrix.setScale(1f, size.x / (float) size.y); } } editorElementHierarchy.doneCrop(visibleViewPort, null); if (!changedBefore) { undoRedoStacks.clear(editorElementHierarchy.getRoot()); } if (circleEditing) { startCrop(); } } } }
Example 20
Source File: BitmapLoadShowTask.java From Matisse-Kotlin with Apache License 2.0 | 4 votes |
@Override @NonNull protected BitmapWorkerResult doInBackground(Void... params) { if (mInputUri == null) { return new BitmapWorkerResult(new NullPointerException("Input Uri cannot be null")); } final ParcelFileDescriptor parcelFileDescriptor; try { parcelFileDescriptor = mContext.getContentResolver().openFileDescriptor(mInputUri, "r"); } catch (FileNotFoundException e) { return new BitmapWorkerResult(e); } final FileDescriptor fileDescriptor; if (parcelFileDescriptor != null) { fileDescriptor = parcelFileDescriptor.getFileDescriptor(); } else { return new BitmapWorkerResult(new NullPointerException("ParcelFileDescriptor was null for given Uri: [" + mInputUri + "]")); } final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); if (options.outWidth == -1 || options.outHeight == -1) { return new BitmapWorkerResult(new IllegalArgumentException("Bounds for bitmap could not be retrieved from the Uri: [" + mInputUri + "]")); } options.inSampleSize = BitmapLoadUtils.calculateInSampleSize(options, mRequiredWidth, mRequiredHeight); options.inJustDecodeBounds = false; Bitmap decodeSampledBitmap = null; boolean decodeAttemptSuccess = false; while (!decodeAttemptSuccess) { try { decodeSampledBitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); decodeAttemptSuccess = true; } catch (OutOfMemoryError error) { Log.e(TAG, "doInBackground: BitmapFactory.decodeFileDescriptor: ", error); options.inSampleSize *= 2; } } if (decodeSampledBitmap == null) { return new BitmapWorkerResult(new IllegalArgumentException("Bitmap could not be decoded from the Uri: [" + mInputUri + "]")); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { BitmapLoadUtils.close(parcelFileDescriptor); } int exifOrientation = BitmapLoadUtils.getExifOrientation(mContext, mInputUri); int exifDegrees = BitmapLoadUtils.exifToDegrees(exifOrientation); int exifTranslation = BitmapLoadUtils.exifToTranslation(exifOrientation); ExifInfo exifInfo = new ExifInfo(exifOrientation, exifDegrees, exifTranslation); Matrix matrix = new Matrix(); if (exifDegrees != 0) { matrix.preRotate(exifDegrees); } if (exifTranslation != 1) { matrix.postScale(exifTranslation, 1); } if (!matrix.isIdentity()) { return new BitmapWorkerResult(BitmapLoadUtils.transformBitmap(decodeSampledBitmap, matrix), exifInfo); } return new BitmapWorkerResult(decodeSampledBitmap, exifInfo); }