List of usage examples for android.graphics Matrix preConcat
public boolean preConcat(Matrix other)
From source file:Main.java
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()); }/*from w w w .ja v a 2 s . c o m*/ m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } }
From source file:com.jiahuan.svgmapview.core.helper.map.SVGParser.java
private static Matrix parseTransformItem(String s, Matrix matrix) { if (s.startsWith("matrix(")) { NumberParse np = parseNumbers(s.substring("matrix(".length())); if (np.numbers.size() == 6) { Matrix mat = new Matrix(); mat.setValues(new float[] { // Row 1 np.numbers.get(0), np.numbers.get(2), np.numbers.get(4), // Row 2 np.numbers.get(1), np.numbers.get(3), np.numbers.get(5), // Row 3 0, 0, 1, });//from w w w .j a v a2s . c o m matrix.preConcat(mat); } } else if (s.startsWith("translate(")) { NumberParse np = parseNumbers(s.substring("translate(".length())); if (np.numbers.size() > 0) { float tx = np.numbers.get(0); float ty = 0; if (np.numbers.size() > 1) { ty = np.numbers.get(1); } matrix.preTranslate(tx, ty); } } else if (s.startsWith("scale(")) { NumberParse np = parseNumbers(s.substring("scale(".length())); if (np.numbers.size() > 0) { float sx = np.numbers.get(0); float sy = sx; if (np.numbers.size() > 1) { sy = np.numbers.get(1); } matrix.preScale(sx, sy); } } else if (s.startsWith("skewX(")) { NumberParse np = parseNumbers(s.substring("skewX(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); matrix.preSkew((float) Math.tan(angle), 0); } } else if (s.startsWith("skewY(")) { NumberParse np = parseNumbers(s.substring("skewY(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); matrix.preSkew(0, (float) Math.tan(angle)); } } else if (s.startsWith("rotate(")) { NumberParse np = parseNumbers(s.substring("rotate(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); float cx = 0; float cy = 0; if (np.numbers.size() > 2) { cx = np.numbers.get(1); cy = np.numbers.get(2); } matrix.preTranslate(-cx, -cy); matrix.preRotate(angle); matrix.preTranslate(cx, cy); } } else { Log.w(TAG, "Invalid transform (" + s + ")"); } return matrix; }
From source file:com.larvalabs.svgandroid.SVGParser.java
private static Matrix parseTransformItem(String s, Matrix matrix) { if (s.startsWith("matrix(")) { NumberParse np = parseNumbers(s.substring("matrix(".length())); if (np.numbers.size() == 6) { Matrix mat = new Matrix(); mat.setValues(new float[] { // Row 1 np.numbers.get(0), np.numbers.get(2), np.numbers.get(4), // Row 2 np.numbers.get(1), np.numbers.get(3), np.numbers.get(5), // Row 3 0, 0, 1, });/*ww w. java2 s . co m*/ matrix.preConcat(mat); } } else if (s.startsWith("translate(")) { NumberParse np = parseNumbers(s.substring("translate(".length())); if (np.numbers.size() > 0) { float tx = np.numbers.get(0); float ty = 0; if (np.numbers.size() > 1) { ty = np.numbers.get(1); } matrix.preTranslate(tx, ty); } } else if (s.startsWith("scale(")) { NumberParse np = parseNumbers(s.substring("scale(".length())); if (np.numbers.size() > 0) { float sx = np.numbers.get(0); float sy = sx; if (np.numbers.size() > 1) { sy = np.numbers.get(1); } matrix.preScale(sx, sy); } } else if (s.startsWith("skewX(")) { NumberParse np = parseNumbers(s.substring("skewX(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); matrix.preSkew((float) Math.tan(angle), 0); } } else if (s.startsWith("skewY(")) { NumberParse np = parseNumbers(s.substring("skewY(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); matrix.preSkew(0, (float) Math.tan(angle)); } } else if (s.startsWith("rotate(")) { NumberParse np = parseNumbers(s.substring("rotate(".length())); if (np.numbers.size() > 0) { float angle = np.numbers.get(0); float cx = 0; float cy = 0; if (np.numbers.size() > 2) { cx = np.numbers.get(1); cy = np.numbers.get(2); } matrix.preTranslate(cx, cy); matrix.preRotate(angle); matrix.preTranslate(-cx, -cy); } } else { Log.i(TAG, "Invalid transform (" + s + ")"); } return matrix; }