/** * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public MPPointD getPixelForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelForValues(x, y); }
public void getValuesByTouchPoint(float x, float y, AxisDependency axis, MPPointD outputPoint) { getTransformer(axis).getValuesByTouchPoint(x, y, outputPoint); }
/** * Moves the left side of the current viewport to the specified x-position. * This also refreshes the chart by calling invalidate(). * * @param xValue */ public void moveViewToX(float xValue) { Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue, 0f, getTransformer(AxisDependency.LEFT), this); addViewportJob(job); }
/** * Zooms in or out by the given scale factor. * x and y are the values (NOT PIXELS) of the zoom center.. * * @param scaleX * @param scaleY * @param xValue * @param yValue * @param axis the axis relative to which the zoom should take place */ public void zoom(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis) { Runnable job = ZoomJob.getInstance(mViewPortHandler, scaleX, scaleY, xValue, yValue, getTransformer(axis), axis, this); addViewportJob(job); }
/** * Returns the lowest x-index (value on the x-axis) that is still visible on * the chart. * * @return */ @Override public float getLowestVisibleX() { getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom(), posForGetLowestVisibleX); float result = (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.x); return result; }
/** * Returns the highest x-index (value on the x-axis) that is still visible * on the chart. * * @return */ @Override public float getHighestVisibleX() { getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentBottom(), posForGetHighestVisibleX); float result = (float) Math.min(mXAxis.mAxisMaximum, posForGetHighestVisibleX.x); return result; }
/** * Centers the viewport to the specified y value on the y-axis. * This also refreshes the chart by calling invalidate(). * * @param yValue * @param axis - which axis should be used as a reference for the y-axis */ public void centerViewToY(float yValue, AxisDependency axis) { float valsInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, 0f, yValue + valsInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the left side of the current viewport to the specified * x-value on the x-axis, and center the viewport to the specified y value on the y-axis. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y-axis */ public void moveViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * Returns a recyclable MPPointF instance. * Returns the position (in pixels) the provided Entry has inside the chart * view or null, if the provided Entry is null. * * @param e * @return */ public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) return null; mGetPositionBuffer[0] = e.getX(); mGetPositionBuffer[1] = e.getY(); getTransformer(axis).pointValuesToPixel(mGetPositionBuffer); return MPPointF.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { // Saving current position of chart. mOnSizeChangedBuffer[0] = mOnSizeChangedBuffer[1] = 0; if (mKeepPositionOnRotation) { mOnSizeChangedBuffer[0] = mViewPortHandler.contentLeft(); mOnSizeChangedBuffer[1] = mViewPortHandler.contentTop(); getTransformer(AxisDependency.LEFT).pixelsToValue(mOnSizeChangedBuffer); } //Superclass transforms chart. super.onSizeChanged(w, h, oldw, oldh); if (mKeepPositionOnRotation) { //Restoring old position of chart. getTransformer(AxisDependency.LEFT).pointValuesToPixel(mOnSizeChangedBuffer); mViewPortHandler.centerViewPort(mOnSizeChangedBuffer, this); } else { mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(), this, true); } } }
/** * This will move the left side of the current viewport to the specified x-value * and center the viewport to the y value animated. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void moveViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); }
/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * Zooms by the specified scale factor to the specified values on the specified axis. * * @param scaleX * @param scaleY * @param xValue * @param yValue * @param axis * @param duration */ @TargetApi(11) public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis, long duration) { MPPointD origin = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); Runnable job = AnimatedZoomJob.getInstance(mViewPortHandler, this, getTransformer(axis), getAxis(axis), mXAxis .mAxisRange, scaleX, scaleY, mViewPortHandler.getScaleX(), mViewPortHandler.getScaleY(), xValue, yValue, (float) origin.x, (float) origin.y, duration); addViewportJob(job); MPPointD.recycleInstance(origin); }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); }
/** * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public MPPointD getPixelForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelForValues(x, y); }
/** * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public MPPointD getPixelForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelForValues(x, y); }
/** * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public MPPointD getPixelForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelForValues(x, y); }
/** * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public MPPointD getPixelForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelForValues(x, y); }
/** * Moves the left side of the current viewport to the specified x-position. * This also refreshes the chart by calling invalidate(). * * @param xValue */ public void moveViewToX(float xValue) { Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue, 0f, getTransformer(AxisDependency.LEFT), this); addViewportJob(job); }
/** * Moves the left side of the current viewport to the specified x-position. * This also refreshes the chart by calling invalidate(). * * @param xValue */ public void moveViewToX(float xValue) { Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue, 0f, getTransformer(AxisDependency.LEFT), this); addViewportJob(job); }