Java Code Examples for com.github.mikephil.charting.utils.MPPointD#recycleInstance()
The following examples show how to use
com.github.mikephil.charting.utils.MPPointD#recycleInstance() .
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: XAxisRenderer.java From android-kline with Apache License 2.0 | 6 votes |
@Override public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (inverted) { min = (float) p2.x; max = (float) p1.x; } else { min = (float) p1.x; max = (float) p2.x; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 2
Source File: BarLineChartBase.java From android-kline with Apache License 2.0 | 6 votes |
/** * 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) { if (android.os.Build.VERSION.SDK_INT >= 11) { 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); } else { Log.e(LOG_TAG, "Unable to execute zoomAndCenterAnimated(...) on API level < 11"); } }
Example 3
Source File: BarHighlighter.java From Ticket-Analysis with MIT License | 6 votes |
@Override public Highlight getHighlight(float x, float y) { Highlight high = super.getHighlight(x, y); if(high == null) { return null; } MPPointD pos = getValsForTouch(x, y); BarData barData = mChart.getBarData(); IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex()); if (set.isStacked()) { return getStackedHighlight(high, set, (float) pos.x, (float) pos.y); } MPPointD.recycleInstance(pos); return high; }
Example 4
Source File: BarHighlighter.java From android-kline with Apache License 2.0 | 6 votes |
@Override public Highlight getHighlight(float x, float y) { Highlight high = super.getHighlight(x, y); if(high == null) { return null; } MPPointD pos = getValsForTouch(x, y); BarData barData = mChart.getBarData(); IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex()); if (set.isStacked()) { return getStackedHighlight(high, set, (float) pos.x, (float) pos.y); } MPPointD.recycleInstance(pos); return high; }
Example 5
Source File: XAxisRenderer.java From Ticket-Analysis with MIT License | 6 votes |
@Override public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (inverted) { min = (float) p2.x; max = (float) p1.x; } else { min = (float) p1.x; max = (float) p2.x; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 6
Source File: BarLineChartBase.java From android-kline with Apache License 2.0 | 6 votes |
/** * 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) { if (android.os.Build.VERSION.SDK_INT >= 11) { 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); } else { Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11"); } }
Example 7
Source File: BarLineChartBase.java From Ticket-Analysis with MIT License | 6 votes |
/** * 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) { if (android.os.Build.VERSION.SDK_INT >= 11) { 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); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
Example 8
Source File: AxisRenderer.java From android-kline with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param min - the minimum value in the data object for this axis * @param max - the maximum value in the data object for this axis */ public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler != null && mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!inverted) { min = (float) p2.y; max = (float) p1.y; } else { min = (float) p1.y; max = (float) p2.y; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 9
Source File: XAxisRendererHorizontalBarChart.java From android-kline with Apache License 2.0 | 6 votes |
@Override public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); if (inverted) { min = (float) p2.y; max = (float) p1.y; } else { min = (float) p1.y; max = (float) p2.y; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 10
Source File: BarHighlighter.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public Highlight getHighlight(float x, float y) { Highlight high = super.getHighlight(x, y); if(high == null) { return null; } MPPointD pos = getValsForTouch(x, y); BarData barData = mChart.getBarData(); IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex()); if (set.isStacked()) { return getStackedHighlight(high, set, (float) pos.x, (float) pos.y); } MPPointD.recycleInstance(pos); return high; }
Example 11
Source File: AxisRenderer.java From StockChart-MPAndroidChart with MIT License | 6 votes |
/** * Computes the axis values. * * @param min - the minimum value in the data object for this axis * @param max - the maximum value in the data object for this axis */ public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler != null && mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!inverted) { min = (float) p2.y; max = (float) p1.y; } else { min = (float) p1.y; max = (float) p2.y; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 12
Source File: XAxisRenderer.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (inverted) { min = (float) p2.x; max = (float) p1.x; } else { min = (float) p1.x; max = (float) p2.x; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 13
Source File: XAxisRendererHorizontalBarChart.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public void computeAxis(float min, float max, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); if (inverted) { min = (float) p2.y; max = (float) p1.y; } else { min = (float) p1.y; max = (float) p2.y; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(min, max); }
Example 14
Source File: BarLineChartBase.java From StockChart-MPAndroidChart with MIT License | 6 votes |
/** * 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); }
Example 15
Source File: ChartHighlighter.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public Highlight getHighlight(float x, float y) { MPPointD pos = getValsForTouch(x, y); float xVal = (float) pos.x; MPPointD.recycleInstance(pos); Highlight high = getHighlightForX(xVal, x, y); return high; }
Example 16
Source File: YAxisRendererHorizontalBarChart.java From android-kline with Apache License 2.0 | 5 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ @Override public void computeAxis(float yMin, float yMax, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!inverted) { yMin = (float) p1.x; yMax = (float) p2.x; } else { yMin = (float) p2.x; yMax = (float) p1.x; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(yMin, yMax); }
Example 17
Source File: ChartHighlighter.java From Ticket-Analysis with MIT License | 5 votes |
@Override public Highlight getHighlight(float x, float y) { MPPointD pos = getValsForTouch(x, y); float xVal = (float) pos.x; MPPointD.recycleInstance(pos); Highlight high = getHighlightForX(xVal, x, y); return high; }
Example 18
Source File: YAxisRendererHorizontalBarChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ @Override public void computeAxis(float yMin, float yMax, boolean inverted) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!inverted) { yMin = (float) p1.x; yMax = (float) p2.x; } else { yMin = (float) p2.x; yMax = (float) p1.x; } MPPointD.recycleInstance(p1); MPPointD.recycleInstance(p2); } computeAxisValues(yMin, yMax); }
Example 19
Source File: BarHighlighter.java From android-kline with Apache License 2.0 | 5 votes |
/** * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been * selected. * * @param high the Highlight to work with looking for stacked values * @param set * @param xVal * @param yVal * @return */ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) { BarEntry entry = set.getEntryForXValue(xVal, yVal); if (entry == null) return null; // not stacked if (entry.getYVals() == null) { return high; } else { Range[] ranges = entry.getRanges(); if (ranges.length > 0) { int stackIndex = getClosestStackIndex(ranges, yVal); MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to); Highlight stackedHigh = new Highlight( entry.getX(), entry.getY(), (float) pixels.x, (float) pixels.y, high.getDataSetIndex(), stackIndex, high.getAxis() ); MPPointD.recycleInstance(pixels); return stackedHigh; } } return null; }
Example 20
Source File: BarLineChartBase.java From StockChart-MPAndroidChart with MIT License | 3 votes |
/** * 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); }