List of usage examples for android.graphics Matrix set
public void set(Matrix src)
From source file:Main.java
static void offsetDescendantRect(ViewGroup group, View child, Rect rect) { Matrix m = sMatrix.get(); if (m == null) { m = new Matrix(); sMatrix.set(m);// w ww . j av a2 s.co m } else { m.set(IDENTITY); } offsetDescendantMatrix(group, child, m); RectF rectF = sRectF.get(); if (rectF == null) { rectF = new RectF(); } rectF.set(rect); m.mapRect(rectF); rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f), (int) (rectF.bottom + 0.5f)); }
From source file:Main.java
public static void offsetDescendantRect(ViewGroup group, View child, Rect rect) { Matrix m = sMatrix.get(); if (m == null) { m = new Matrix(); sMatrix.set(m);//w ww .j av a2 s. c o m } else { m.set(IDENTITY); } offsetDescendantMatrix(group, child, m); RectF rectF = sRectF.get(); if (rectF == null) { rectF = new RectF(); } rectF.set(rect); m.mapRect(rectF); rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f), (int) (rectF.bottom + 0.5f)); }
From source file:Main.java
/** * Maps a coordinate in the root to a descendent. *///from www . j a va2 s . c o m public static float mapCoordInSelfToDescendent(View descendant, View root, float[] coord, Matrix tmpInverseMatrix) { ArrayList<View> ancestorChain = new ArrayList<View>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); tmpInverseMatrix.set(IDENTITY_MATRIX); for (int i = count - 1; i >= 0; i--) { View ancestor = ancestorChain.get(i); View next = i > 0 ? ancestorChain.get(i - 1) : null; pt[0] += ancestor.getScrollX(); pt[1] += ancestor.getScrollY(); if (next != null) { pt[0] -= next.getLeft(); pt[1] -= next.getTop(); next.getMatrix().invert(tmpInverseMatrix); tmpInverseMatrix.mapPoints(pt); scale *= next.getScaleX(); } } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:Main.java
/** * Maps a coordinate in the root to a descendent. *///from w w w. j a v a 2 s . co m public static float mapCoordInSelfToDescendent(View descendant, View root, float[] coord, Matrix tmpInverseMatrix) { ArrayList<View> ancestorChain = new ArrayList<>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); tmpInverseMatrix.set(IDENTITY_MATRIX); for (int i = count - 1; i >= 0; i--) { View ancestor = ancestorChain.get(i); View next = i > 0 ? ancestorChain.get(i - 1) : null; pt[0] += ancestor.getScrollX(); pt[1] += ancestor.getScrollY(); if (next != null) { pt[0] -= next.getLeft(); pt[1] -= next.getTop(); next.getMatrix().invert(tmpInverseMatrix); tmpInverseMatrix.mapPoints(pt); scale *= next.getScaleX(); } } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:com.iped.ipcam.bitmapfun.ImageDetailFragment.java
protected void center(boolean horizontal, boolean vertical) { Matrix m = new Matrix(); m.set(matrix); RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight()); m.mapRect(rect);/* ww w. j av a2 s .c om*/ float height = rect.height(); float width = rect.width(); float deltaX = 0, deltaY = 0; if (vertical) { int screenHeight = dm.heightPixels; if (height <= screenHeight) { deltaY = (screenHeight - height) / 2 - rect.top; } else if (rect.top > 0) { deltaY = -rect.top; } else if (rect.bottom < screenHeight) { deltaY = screenHeight - rect.bottom; } } if (horizontal) { int screenWidth = dm.widthPixels; if (width <= screenWidth) { deltaX = (screenWidth - width) / 2 - rect.left; } else if (rect.left > 0) { deltaX = -rect.left; } else if (rect.right < screenWidth) { deltaX = screenWidth - rect.right; } } matrix.postTranslate(deltaX, deltaY); }
From source file:com.frank.protean.photoview.PhotoViewAttacher.java
/** * Get the display matrix//ww w . j a v a 2 s . com * * @param matrix target matrix to copy to */ public void getDisplayMatrix(Matrix matrix) { matrix.set(getDrawMatrix()); }
From source file:com.example.photoviewlib.PhotoViewAttacher.java
@Override public void getDisplayMatrix(Matrix matrix) { matrix.set(getDrawMatrix()); }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
/** * Get the current support matrix */ public void getSuppMatrix(Matrix matrix) { matrix.set(mSuppMatrix); }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
/** * Like {@link #getDisplayMatrix()}, but allows the user to provide a matrix to copy the values into to reduce object allocation * @param matrix target matrix to copy to *///ww w. ja va 2s . c o m @Override public void getDisplayMatrix(Matrix matrix) { matrix.set(getDrawMatrix()); }