Java Code Examples for android.graphics.Matrix#preConcat()
The following examples show how to use
android.graphics.Matrix#preConcat() .
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 mollyim-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: SVGAndroidRenderer.java From XDroidAnimation with Apache License 2.0 | 6 votes |
private void addObjectToClip(SVG.Path obj, Path combinedPath, Matrix combinedPathMatrix) { updateStyleForElement(state, obj); if (!display()) return; if (!visible()) return; if (obj.transform != null) combinedPathMatrix.preConcat(obj.transform); Path path = (new PathConverter(obj.d)).getPath(); if (obj.boundingBox == null) { obj.boundingBox = calculatePathBounds(path); } checkForClipPath(obj); //path.setFillType(getClipRuleFromState()); combinedPath.setFillType(getClipRuleFromState()); combinedPath.addPath(path, combinedPathMatrix); }
Example 3
Source File: CropImageActivity.java From MyBlogDemo with Apache License 2.0 | 6 votes |
private Bitmap inMemoryCrop(RotateBitmap rotateBitmap, Bitmap croppedImage, Rect r, int width, int height, int outWidth, int outHeight) { // In-memory crop means potential OOM errors, // but we have no choice as we can't selectively decode a bitmap with this API level System.gc(); try { croppedImage = Bitmap.createBitmap(outWidth, outHeight, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(croppedImage); RectF dstRect = new RectF(0, 0, width, height); Matrix m = new Matrix(); m.setRectToRect(new RectF(r), dstRect, Matrix.ScaleToFit.FILL); m.preConcat(rotateBitmap.getRotateMatrix()); canvas.drawBitmap(rotateBitmap.getBitmap(), m, null); } catch (OutOfMemoryError e) { setResultException(e); System.gc(); } // Release bitmap memory as soon as possible clearImageView(); return croppedImage; }
Example 4
Source File: EditorElementHierarchy.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
/** * Returns a matrix that maps points from the crop on to the visible image. * <p> * i.e. if a mapped point is in bounds, then the point is on the visible image. */ @Nullable Matrix imageMatrixRelativeToCrop() { EditorElement mainImage = getMainImage(); if (mainImage == null) return null; Matrix matrix1 = new Matrix(imageCrop.getLocalMatrix()); matrix1.preConcat(cropEditorElement.getLocalMatrix()); matrix1.preConcat(cropEditorElement.getEditorMatrix()); Matrix matrix2 = new Matrix(mainImage.getLocalMatrix()); matrix2.preConcat(mainImage.getEditorMatrix()); matrix2.preConcat(imageCrop.getLocalMatrix()); Matrix inverse = new Matrix(); matrix2.invert(inverse); inverse.preConcat(matrix1); return inverse; }
Example 5
Source File: SVGParser.java From ZzBeeLayout with Apache License 2.0 | 6 votes |
public Gradient createChild(Gradient g) { Gradient child = new Gradient(); child.id = g.id; child.xlink = id; child.isLinear = g.isLinear; child.x1 = g.x1; child.x2 = g.x2; child.y1 = g.y1; child.y2 = g.y2; child.x = g.x; child.y = g.y; child.radius = g.radius; child.positions = positions; child.colors = colors; child.matrix = matrix; if (g.matrix != null) { if (matrix == null) { child.matrix = g.matrix; } else { Matrix m = new Matrix(matrix); m.preConcat(g.matrix); child.matrix = m; } } return child; }
Example 6
Source File: SVGParser.java From CustomShapeImageView with Apache License 2.0 | 6 votes |
public Gradient createChild(Gradient g) { Gradient child = new Gradient(); child.id = g.id; child.xlink = id; child.isLinear = g.isLinear; child.x1 = g.x1; child.x2 = g.x2; child.y1 = g.y1; child.y2 = g.y2; child.x = g.x; child.y = g.y; child.radius = g.radius; child.positions = positions; child.colors = colors; child.matrix = matrix; if (g.matrix != null) { if (matrix == null) { child.matrix = g.matrix; } else { Matrix m = new Matrix(matrix); m.preConcat(g.matrix); child.matrix = m; } } return child; }
Example 7
Source File: EditorElementHierarchy.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
/** * Calculates the exact output size based upon the crops/rotates and zooms in the hierarchy. * * @param inputSize Main image size * @return Size after applying all zooms/rotates and crops */ PointF getOutputSize(@NonNull Point inputSize) { Matrix matrix = new Matrix(); matrix.preConcat(flipRotate.getLocalMatrix()); matrix.preConcat(cropEditorElement.getLocalMatrix()); matrix.preConcat(cropEditorElement.getEditorMatrix()); EditorElement mainImage = getMainImage(); if (mainImage != null) { float xScale = 1f / (xScale(mainImage.getLocalMatrix()) * xScale(mainImage.getEditorMatrix())); matrix.preScale(xScale, xScale); } float[] dst = new float[4]; matrix.mapPoints(dst, new float[]{ 0, 0, inputSize.x, inputSize.y }); float widthF = Math.abs(dst[0] - dst[2]); float heightF = Math.abs(dst[1] - dst[3]); return new PointF(widthF, heightF); }
Example 8
Source File: EditorElementHierarchy.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
/** * Returns a matrix that maps points from the crop on to the visible image. * <p> * i.e. if a mapped point is in bounds, then the point is on the visible image. */ @Nullable Matrix imageMatrixRelativeToCrop() { EditorElement mainImage = getMainImage(); if (mainImage == null) return null; Matrix matrix1 = new Matrix(imageCrop.getLocalMatrix()); matrix1.preConcat(cropEditorElement.getLocalMatrix()); matrix1.preConcat(cropEditorElement.getEditorMatrix()); Matrix matrix2 = new Matrix(mainImage.getLocalMatrix()); matrix2.preConcat(mainImage.getEditorMatrix()); matrix2.preConcat(imageCrop.getLocalMatrix()); Matrix inverse = new Matrix(); matrix2.invert(inverse); inverse.preConcat(matrix1); return inverse; }
Example 9
Source File: SVGAndroidRenderer.java From microMathematics with GNU General Public License v3.0 | 6 votes |
private void addObjectToClip(SVG.Path obj, Path combinedPath, Matrix combinedPathMatrix) { updateStyleForElement(state, obj); if (!display()) return; if (!visible()) return; if (obj.transform != null) combinedPathMatrix.preConcat(obj.transform); Path path = (new PathConverter(obj.d)).getPath(); if (obj.boundingBox == null) { obj.boundingBox = calculatePathBounds(path); } checkForClipPath(obj); //path.setFillType(getClipRuleFromState()); combinedPath.setFillType(getClipRuleFromState()); combinedPath.addPath(path, combinedPathMatrix); }
Example 10
Source File: Gradient.java From PdDroidPublisher with GNU General Public License v3.0 | 5 votes |
public Gradient createChild(Gradient g) { Gradient child = new Gradient(); child.id = g.id; child.xlink = id; child.isLinear = g.isLinear; child.x1 = g.x1; child.x2 = g.x2; child.y1 = g.y1; child.y2 = g.y2; child.x = g.x; child.y = g.y; child.radius = g.radius; child.positions = positions; child.spread = g.spread; child.colors = colors; child.matrix = matrix; if (g.matrix != null) { if (matrix == null) { child.matrix = g.matrix; } else { Matrix m = new Matrix(matrix); m.preConcat(g.matrix); child.matrix = m; } } return child; }
Example 11
Source File: SVGAndroidRenderer.java From starcor.xul with GNU Lesser General Public License v3.0 | 5 votes |
private void addObjectToClip(SVG.Text obj, Path combinedPath, Matrix combinedPathMatrix) { updateStyleForElement(state, obj); if (!display()) return; if (obj.transform != null) combinedPathMatrix.preConcat(obj.transform); // Get the first coordinate pair from the lists in the x and y properties. float x = (obj.x == null || obj.x.size() == 0) ? 0f : obj.x.get(0).floatValueX(this); float y = (obj.y == null || obj.y.size() == 0) ? 0f : obj.y.get(0).floatValueY(this); float dx = (obj.dx == null || obj.dx.size() == 0) ? 0f : obj.dx.get(0).floatValueX(this); float dy = (obj.dy == null || obj.dy.size() == 0) ? 0f : obj.dy.get(0).floatValueY(this); // Handle text alignment if (state.style.textAnchor != Style.TextAnchor.Start) { float textWidth = calculateTextWidth(obj); if (state.style.textAnchor == Style.TextAnchor.Middle) { x -= (textWidth / 2); } else { x -= textWidth; // 'End' (right justify) } } if (obj.boundingBox == null) { TextBoundsCalculator proc = new TextBoundsCalculator(x, y); enumerateTextSpans(obj, proc); obj.boundingBox = new Box(proc.bbox.left, proc.bbox.top, proc.bbox.width(), proc.bbox.height()); } checkForClipPath(obj); Path textAsPath = new Path(); enumerateTextSpans(obj, new PlainTextToPath(x + dx, y + dy, textAsPath)); combinedPath.setFillType(getClipRuleFromState()); combinedPath.addPath(textAsPath, combinedPathMatrix); }
Example 12
Source File: ViewHelper.java From DMusic with Apache License 2.0 | 5 votes |
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }
Example 13
Source File: SVGAndroidRenderer.java From microMathematics with GNU General Public License v3.0 | 5 votes |
private void addObjectToClip(SVG.Text obj, Path combinedPath, Matrix combinedPathMatrix) { updateStyleForElement(state, obj); if (!display()) return; if (obj.transform != null) combinedPathMatrix.preConcat(obj.transform); // Get the first coordinate pair from the lists in the x and y properties. float x = (obj.x == null || obj.x.size() == 0) ? 0f : obj.x.get(0).floatValueX(this); float y = (obj.y == null || obj.y.size() == 0) ? 0f : obj.y.get(0).floatValueY(this); float dx = (obj.dx == null || obj.dx.size() == 0) ? 0f : obj.dx.get(0).floatValueX(this); float dy = (obj.dy == null || obj.dy.size() == 0) ? 0f : obj.dy.get(0).floatValueY(this); // Handle text alignment if (state.style.textAnchor != Style.TextAnchor.Start) { float textWidth = calculateTextWidth(obj); if (state.style.textAnchor == Style.TextAnchor.Middle) { x -= (textWidth / 2); } else { x -= textWidth; // 'End' (right justify) } } if (obj.boundingBox == null) { TextBoundsCalculator proc = new TextBoundsCalculator(x, y); enumerateTextSpans(obj, proc); obj.boundingBox = new Box(proc.bbox.left, proc.bbox.top, proc.bbox.width(), proc.bbox.height()); } checkForClipPath(obj); Path textAsPath = new Path(); enumerateTextSpans(obj, new PlainTextToPath(x + dx, y + dy, textAsPath)); combinedPath.setFillType(getClipRuleFromState()); combinedPath.addPath(textAsPath, combinedPathMatrix); }
Example 14
Source File: ViewGroupUtilsHoneycomb.java From GpCollapsingToolbar with Apache License 2.0 | 5 votes |
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }
Example 15
Source File: EditorModel.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
/** * Changes the temporary view so that the text element is centered in it. * * @param entity Entity to center on. * @param textRenderer The text renderer, which can make additional adjustments to the zoom matrix * to leave space for the keyboard for example. */ public void zoomToTextElement(@NonNull EditorElement entity, @NonNull MultiLineTextRenderer textRenderer) { Matrix elementInverseMatrix = findElementInverseMatrix(entity, new Matrix()); if (elementInverseMatrix != null) { EditorElement root = editorElementHierarchy.getRoot(); elementInverseMatrix.preConcat(root.getEditorMatrix()); textRenderer.applyRecommendedEditorMatrix(elementInverseMatrix); root.animateEditorTo(elementInverseMatrix, invalidate); } }
Example 16
Source File: EditorModel.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
/** * Returns a matrix that maps points in the {@param from} element in to points in the {@param to} element. * * @param from * @param to * @return */ @Nullable Matrix findRelativeMatrix(@NonNull EditorElement from, @NonNull EditorElement to) { Matrix matrix = findElementInverseMatrix(to, new Matrix()); Matrix outOf = findElementMatrix(from, new Matrix()); if (outOf != null && matrix != null) { matrix.preConcat(outOf); return matrix; } return null; }
Example 17
Source File: EditorElementHierarchy.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
/** * The full matrix for the {@link #getMainImage()} from {@link #root} down. */ Matrix getMainImageFullMatrix() { Matrix matrix = new Matrix(); matrix.preConcat(view.getLocalMatrix()); matrix.preConcat(getMainImageFullMatrixFromFlipRotate()); return matrix; }
Example 18
Source File: DescendantOffsetUtils.java From material-components-android with Apache License 2.0 | 5 votes |
private static void offsetDescendantMatrix( ViewParent target, @NonNull View view, @NonNull Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }
Example 19
Source File: ViewGroupUtilsHoneycomb.java From FireFiles with Apache License 2.0 | 5 votes |
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }
Example 20
Source File: ViewGroupUtilsHoneycomb.java From ticdesign with Apache License 2.0 | 5 votes |
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }