/** * Zooms out to original size. * @param outputMatrix */ public void resetZoom(Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.postScale(1.0f, 1.0f, 0.0f, 0.0f); }
public void zoom(float scaleX, float scaleY, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.postScale(scaleX, scaleY); }
public void zoomIn(float x, float y, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.postScale(1.4f, 1.4f, x, y); }
public void zoomOut(float x, float y, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.postScale(0.7f, 0.7f, x, y); }
public void zoom(float scaleX, float scaleY, float x, float y, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.postScale(scaleX, scaleY, x, y); }
public void setZoom(float scaleX, float scaleY, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); outputMatrix.setScale(scaleX, scaleY); }
Matrix getTransformationMatrix() { if (transformAnimation != null) { return transformAnimation.getMatrix(); } matrix.reset(); return matrix; }
/** * Post-translates to the specified points. Output matrix allows for caching objects. * * @param transformedPts * @return */ public void translate(final float[] transformedPts, Matrix outputMatrix) { outputMatrix.reset(); outputMatrix.set(mMatrixTouch); final float x = transformedPts[0] - offsetLeft(); final float y = transformedPts[1] - offsetTop(); outputMatrix.postTranslate(-x, -y); }
private void updateMatrix(){ if(mBitmap == null) return; Rect bounds = getBounds(); if(bounds.width() == 0 || bounds.height() == 0) return; mMatrix.reset(); float scale = bounds.height() / (float)Math.min(mBitmap.getWidth(), mBitmap.getHeight()); mMatrix.setScale(scale, scale, 0, 0); mMatrix.postTranslate((bounds.height() - mBitmap.getWidth() * scale) / 2, (bounds.height() - mBitmap.getHeight() * scale) / 2); mBitmapShader.setLocalMatrix(mMatrix); }
/** * Prepares the matrix that transforms values to pixels. Calculates the * scale factors from the charts size and offsets. * * @param xChartMin * @param deltaX * @param deltaY * @param yChartMin */ public void prepareMatrixValuePx(float xChartMin, float deltaX, float deltaY, float yChartMin) { float scaleX = (float) ((mViewPortHandler.contentWidth()) / deltaX); float scaleY = (float) ((mViewPortHandler.contentHeight()) / deltaY); if (Float.isInfinite(scaleX)) { scaleX = 0; } if (Float.isInfinite(scaleY)) { scaleY = 0; } // setup all matrices mMatrixValueToPx.reset(); mMatrixValueToPx.postTranslate(-xChartMin, -yChartMin); mMatrixValueToPx.postScale(scaleX, -scaleY); }
@Override public Path getPath() { // TODO: cache this somehow. matrix.reset(); if (transformAnimation != null) { matrix.set(transformAnimation.getMatrix()); } path.reset(); if (hidden) { return path; } for (int i = contents.size() - 1; i >= 0; i--) { Content content = contents.get(i); if (content instanceof PathContent) { path.addPath(((PathContent) content).getPath(), matrix); } } return path; }
private void updateMatrix(){ if(mBitmap == null) return; Rect bounds = getBounds(); if(bounds.width() == 0 || bounds.height() == 0) return; mMatrix.reset(); float scale = bounds.height() / (float)Math.min(mBitmap.getWidth(), mBitmap.getHeight()); mMatrix.setScale(scale, scale, 0, 0); mMatrix.postTranslate(bounds.exactCenterX() - mBitmap.getWidth() * scale / 2, bounds.exactCenterY() - mBitmap.getHeight() * scale / 2); mBitmapShader.setLocalMatrix(mMatrix); }
/** * Centers the viewport around the specified position (x-index and y-value) * in the chart. Centering the viewport outside the bounds of the chart is * not possible. Makes most sense in combination with the * setScaleMinima(...) method. * * @param transformedPts the position to center view viewport to * @param view * @return save */ public void centerViewPort(final float[] transformedPts, final View view) { Matrix save = mCenterViewPortMatrixBuffer; save.reset(); save.set(mMatrixTouch); final float x = transformedPts[0] - offsetLeft(); final float y = transformedPts[1] - offsetTop(); save.postTranslate(-x, -y); refresh(save, view, true); }
/** * Prepares the matrix that contains all offsets. * * @param inverted */ public void prepareMatrixOffset(boolean inverted) { mMatrixOffset.reset(); // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom); if (!inverted) mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(), mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom()); else { mMatrixOffset .setTranslate(mViewPortHandler.offsetLeft(), -mViewPortHandler.offsetTop()); mMatrixOffset.postScale(1.0f, -1.0f); } }
/** * Resets the Matrix back to FIT_CENTER, and then displays its contents */ private void resetMatrix() { mSuppMatrix.reset(); setRotationBy(mBaseRotation); setImageViewMatrix(getDrawMatrix()); checkMatrixBounds(); }
@Test public void testReset() { final Matrix matrix = new Matrix(); matrix.postScale(2.0f, 2.0f); matrix.postTranslate(1.0f, 2.0f); matrix.postRotate(45.0f); matrix.reset(); assertThat(matrix.isIdentity()) .isTrue(); }
/** * Prepares the matrix that contains all offsets. * * @param inverted */ public void prepareMatrixOffset(boolean inverted) { mMatrixOffset.reset(); // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom); if (!inverted) mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(), mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom()); else { mMatrixOffset .setTranslate( -(mViewPortHandler.getChartWidth() - mViewPortHandler.offsetRight()), mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom()); mMatrixOffset.postScale(-1.0f, 1.0f); } // mMatrixOffset.set(offset); // mMatrixOffset.reset(); // // mMatrixOffset.postTranslate(mOffsetLeft, getHeight() - // mOffsetBottom); } }
/** * TODO: see if we can use this for the main {@link #getMatrix()} method. */ public Matrix getMatrixForRepeater(float amount) { if (isIdentity) { return matrix; } PointF position = this.position.getValue(); PointF anchorPoint = this.anchorPoint.getValue(); ScaleXY scale = this.scale.getValue(); float rotation = this.rotation.getValue(); matrix.reset(); matrix.preTranslate(position.x * amount, position.y * amount); matrix.preScale( (float) Math.pow(scale.getScaleX(), amount), (float) Math.pow(scale.getScaleY(), amount)); matrix.preRotate(rotation * amount, anchorPoint.x, anchorPoint.y); return matrix; }
/** * Transforms the given array of touch positions (pixels) (x, y, x, y, ...) * into values on the chart. * * @param pixels */ public void pixelsToValue(float[] pixels) { Matrix tmp = mPixelToValueMatrixBuffer; tmp.reset(); // invert all matrixes to convert back to the original value mMatrixOffset.invert(tmp); tmp.mapPoints(pixels); mViewPortHandler.getMatrixTouch().invert(tmp); tmp.mapPoints(pixels); mMatrixValueToPx.invert(tmp); tmp.mapPoints(pixels); }
public Matrix getMatrix() { if (isIdentity) { return matrix; } matrix.reset(); PointF position = this.position.getValue(); if (position.x != 0 || position.y != 0) { matrix.preTranslate(position.x, position.y); } float rotation = ((FloatKeyframeAnimation) this.rotation).getFloatValue(); if (rotation != 0f) { matrix.preRotate(rotation); } ScaleXY scaleTransform = this.scale.getValue(); if (scaleTransform.getScaleX() != 1f || scaleTransform.getScaleY() != 1f) { matrix.preScale(scaleTransform.getScaleX(), scaleTransform.getScaleY()); } PointF anchorPoint = this.anchorPoint.getValue(); if (anchorPoint.x != 0 || anchorPoint.y != 0) { matrix.preTranslate(-anchorPoint.x, -anchorPoint.y); } return matrix; }