From 6d21817c8aed43dae6deb1bf7bb835518ecbe2f6 Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Sat, 2 Jul 2016 12:36:16 +0200 Subject: [PATCH] Rename PointD to MPPointD --- .../charting/charts/BarLineChartBase.java | 34 +++++++++---------- .../charting/highlight/BarHighlighter.java | 10 +++--- .../charting/highlight/ChartHighlighter.java | 14 ++++---- .../highlight/HorizontalBarHighlighter.java | 8 ++--- .../charting/renderer/AxisRenderer.java | 10 +++--- .../renderer/CandleStickChartRenderer.java | 4 +-- .../charting/renderer/LineChartRenderer.java | 4 +-- .../renderer/ScatterChartRenderer.java | 4 +-- .../charting/renderer/XAxisRenderer.java | 10 +++--- .../XAxisRendererHorizontalBarChart.java | 10 +++--- .../charting/renderer/YAxisRenderer.java | 4 +-- .../YAxisRendererHorizontalBarChart.java | 12 +++---- .../utils/{PointD.java => MPPointD.java} | 20 +++++------ .../mikephil/charting/utils/MPPointF.java | 1 + .../mikephil/charting/utils/Transformer.java | 16 ++++----- 15 files changed, 81 insertions(+), 80 deletions(-) rename MPChartLib/src/main/java/com/github/mikephil/charting/utils/{PointD.java => MPPointD.java} (55%) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java index 33de770eb3..a794c6a5ef 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java @@ -31,8 +31,8 @@ import com.github.mikephil.charting.listener.OnDrawListener; import com.github.mikephil.charting.renderer.XAxisRenderer; import com.github.mikephil.charting.renderer.YAxisRenderer; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.PointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; @@ -683,14 +683,14 @@ public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, floa if (android.os.Build.VERSION.SDK_INT >= 11) { - PointD origin = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); + 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); - PointD.recycleInstance(origin); + MPPointD.recycleInstance(origin); } else { Log.e(LOG_TAG, "Unable to execute zoomAndCenterAnimated(...) on API level < 11"); @@ -848,7 +848,7 @@ public void moveViewToAnimated(float xValue, float yValue, AxisDependency axis, if (android.os.Build.VERSION.SDK_INT >= 11) { - PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); + MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); @@ -857,7 +857,7 @@ public void moveViewToAnimated(float xValue, float yValue, AxisDependency axis, addViewportJob(job); - PointD.recycleInstance(bounds); + MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11"); } @@ -915,7 +915,7 @@ public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis if (android.os.Build.VERSION.SDK_INT >= 11) { - PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); + MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); @@ -926,7 +926,7 @@ public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis addViewportJob(job); - PointD.recycleInstance(bounds); + MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } @@ -1202,9 +1202,9 @@ public void setKeepPositionOnRotation(boolean keepPositionOnRotation) { } /** - * Returns a recyclable PointD instance + * Returns a recyclable MPPointD instance * Returns the x and y values in the chart at the given touch point - * (encapsulated in a PointD). This method transforms pixel coordinates to + * (encapsulated in a MPPointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * @@ -1212,18 +1212,18 @@ public void setKeepPositionOnRotation(boolean keepPositionOnRotation) { * @param y * @return */ - public PointD getValuesByTouchPoint(float x, float y, AxisDependency axis) { - PointD result = PointD.getInstance(0,0); + public MPPointD getValuesByTouchPoint(float x, float y, AxisDependency axis) { + MPPointD result = MPPointD.getInstance(0,0); getValuesByTouchPoint(x,y,axis,result); return result; } - public void getValuesByTouchPoint(float x, float y, AxisDependency axis, PointD outputPoint){ + public void getValuesByTouchPoint(float x, float y, AxisDependency axis, MPPointD outputPoint){ getTransformer(axis).getValuesByTouchPoint(x, y, outputPoint); } /** - * Returns a recyclable PointD instance + * Returns a recyclable MPPointD instance * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * @@ -1231,11 +1231,11 @@ public void getValuesByTouchPoint(float x, float y, AxisDependency axis, PointD * @param y * @return */ - public PointD getPixelsForValues(float x, float y, AxisDependency axis) { + public MPPointD getPixelsForValues(float x, float y, AxisDependency axis) { return getTransformer(axis).getPixelsForValues(x, y); } - PointD pointForGetYValueByTouchPoint = PointD.getInstance(0,0); + MPPointD pointForGetYValueByTouchPoint = MPPointD.getInstance(0,0); /** * Returns y value at the given touch position (must not necessarily be * a value contained in one of the datasets) @@ -1281,7 +1281,7 @@ public IBarLineScatterCandleBubbleDataSet getDataSetByTouchPoint(float x, float } /** buffer for storing lowest visible x point */ - protected PointD posForGetLowestVisibleX = PointD.getInstance(0,0); + protected MPPointD posForGetLowestVisibleX = MPPointD.getInstance(0,0); /** * Returns the lowest x-index (value on the x-axis) that is still visible on @@ -1298,7 +1298,7 @@ public float getLowestVisibleX() { } /** buffer for storing highest visible x point */ - protected PointD posForGetHighestVisibleX = PointD.getInstance(0,0); + protected MPPointD posForGetHighestVisibleX = MPPointD.getInstance(0,0); /** * Returns the highest x-index (value on the x-axis) that is still visible diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/BarHighlighter.java b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/BarHighlighter.java index c0b58947e1..1adad89de1 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/BarHighlighter.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/BarHighlighter.java @@ -5,7 +5,7 @@ import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData; import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider; import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; /** * Created by Philipp Jahoda on 22/07/15. @@ -24,7 +24,7 @@ public Highlight getHighlight(float x, float y) { return null; } - PointD pos = getValsForTouch(x, y); + MPPointD pos = getValsForTouch(x, y); BarData barData = mChart.getBarData(); @@ -37,7 +37,7 @@ public Highlight getHighlight(float x, float y) { (float) pos.y); } - PointD.recycleInstance(pos); + MPPointD.recycleInstance(pos); return high; } @@ -68,7 +68,7 @@ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal if (ranges.length > 0) { int stackIndex = getClosestStackIndex(ranges, yVal); - PointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(high.getX(), ranges[stackIndex].to); + MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(high.getX(), ranges[stackIndex].to); Highlight stackedHigh = new Highlight( entry.getX(), @@ -80,7 +80,7 @@ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal high.getAxis() ); - PointD.recycleInstance(pixels); + MPPointD.recycleInstance(pixels); return stackedHigh; } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/ChartHighlighter.java b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/ChartHighlighter.java index 529ba8894a..c3aa4560d8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/ChartHighlighter.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/ChartHighlighter.java @@ -6,7 +6,7 @@ import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.interfaces.dataprovider.BarLineScatterCandleBubbleDataProvider; import com.github.mikephil.charting.interfaces.datasets.IDataSet; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import java.util.ArrayList; import java.util.List; @@ -33,26 +33,26 @@ public ChartHighlighter(T chart) { @Override public Highlight getHighlight(float x, float y) { - PointD pos = getValsForTouch(x, y); + MPPointD pos = getValsForTouch(x, y); float xVal = (float) pos.x; - PointD.recycleInstance(pos); + MPPointD.recycleInstance(pos); Highlight high = getHighlightForX(xVal, x, y); return high; } /** - * Returns a recyclable PointD instance. + * Returns a recyclable MPPointD instance. * Returns the corresponding xPos for a given touch-position in pixels. * * @param x * @param y * @return */ - protected PointD getValsForTouch(float x, float y) { + protected MPPointD getValsForTouch(float x, float y) { // take any transformer to determine the x-axis value - PointD pos = mChart.getTransformer(YAxis.AxisDependency.LEFT).getValuesByTouchPoint(x, y); + MPPointD pos = mChart.getTransformer(YAxis.AxisDependency.LEFT).getValuesByTouchPoint(x, y); return pos; } @@ -167,7 +167,7 @@ protected Highlight buildHighlight(IDataSet set, int dataSetIndex, float xVal, D if (e == null) return null; - PointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY()); + MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY()); return new Highlight(e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency()); } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/HorizontalBarHighlighter.java b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/HorizontalBarHighlighter.java index ce1220027e..626868c3de 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/HorizontalBarHighlighter.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/HorizontalBarHighlighter.java @@ -6,7 +6,7 @@ import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider; import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; import com.github.mikephil.charting.interfaces.datasets.IDataSet; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; /** * Created by Philipp Jahoda on 22/07/15. @@ -22,7 +22,7 @@ public Highlight getHighlight(float x, float y) { BarData barData = mChart.getBarData(); - PointD pos = getValsForTouch(y, x); + MPPointD pos = getValsForTouch(y, x); Highlight high = getHighlightForX((float) pos.y, y, x); if (high == null) @@ -37,7 +37,7 @@ public Highlight getHighlight(float x, float y) { (float) pos.x); } - PointD.recycleInstance(pos); + MPPointD.recycleInstance(pos); return high; } @@ -47,7 +47,7 @@ protected Highlight buildHighlight(IDataSet set, int dataSetIndex, float xVal, D final Entry e = set.getEntryForXPos(xVal, rounding); - PointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getY(), e.getX()); + MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getY(), e.getX()); return new Highlight(e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency()); } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java index f1d4ff0981..1b9c82364a 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java @@ -7,7 +7,7 @@ import android.graphics.Paint.Style; import com.github.mikephil.charting.components.AxisBase; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -121,8 +121,8 @@ public void computeAxis(float min, float max, boolean inverted) { // zoom / contentrect bounds) if (mViewPortHandler != null && mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { - PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); - PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); + MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); + MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!inverted) { @@ -134,8 +134,8 @@ public void computeAxis(float min, float max, boolean inverted) { max = (float) p2.y; } - PointD.recycleInstance(p1); - PointD.recycleInstance(p2); + MPPointD.recycleInstance(p1); + MPPointD.recycleInstance(p2); } computeAxisValues(min, max); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java index 3b99a074f5..2aa11482f0 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java @@ -11,7 +11,7 @@ import com.github.mikephil.charting.interfaces.dataprovider.CandleDataProvider; import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet; import com.github.mikephil.charting.utils.ColorTemplate; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -326,7 +326,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) { float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; - PointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), y); + MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), y); high.setDraw((float) pix.x, (float) pix.y); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java index 87f273ff0a..d478024808 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java @@ -17,7 +17,7 @@ import com.github.mikephil.charting.interfaces.datasets.IDataSet; import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import com.github.mikephil.charting.utils.ColorTemplate; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -750,7 +750,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) { if (!isInBoundsX(e, set)) continue; - PointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator + MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator .getPhaseY()); high.setDraw((float) pix.x, (float) pix.y); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java index 9439cbfd6f..1d45c4974d 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java @@ -11,7 +11,7 @@ import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider; import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; import com.github.mikephil.charting.renderer.scatter.ShapeRenderer; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -148,7 +148,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) { if (!isInBoundsX(e, set)) continue; - PointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator + MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator .getPhaseY()); high.setDraw((float) pix.x, (float) pix.y); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.java index d112cf92de..1973aa3a47 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.java @@ -11,8 +11,8 @@ import com.github.mikephil.charting.components.XAxis; import com.github.mikephil.charting.components.XAxis.XAxisPosition; import com.github.mikephil.charting.utils.FSize; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.PointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -46,8 +46,8 @@ public void computeAxis(float min, float max, boolean inverted) { // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { - PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); - PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); + MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); + MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (inverted) { @@ -59,8 +59,8 @@ public void computeAxis(float min, float max, boolean inverted) { max = (float) p2.x; } - PointD.recycleInstance(p1); - PointD.recycleInstance(p2); + MPPointD.recycleInstance(p1); + MPPointD.recycleInstance(p2); } computeAxisValues(min, max); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.java index 68b280df2d..02192f5a47 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.java @@ -12,7 +12,7 @@ import com.github.mikephil.charting.components.XAxis.XAxisPosition; import com.github.mikephil.charting.utils.FSize; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -37,8 +37,8 @@ public void computeAxis(float min, float max, boolean inverted) { // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { - PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); - PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); + MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); + MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); if (inverted) { @@ -50,8 +50,8 @@ public void computeAxis(float min, float max, boolean inverted) { max = (float) p2.y; } - PointD.recycleInstance(p1); - PointD.recycleInstance(p2); + MPPointD.recycleInstance(p1); + MPPointD.recycleInstance(p2); } computeAxisValues(min, max); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRenderer.java index b550579d29..71cfbf324e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRenderer.java @@ -10,7 +10,7 @@ import com.github.mikephil.charting.components.YAxis; import com.github.mikephil.charting.components.YAxis.AxisDependency; import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -203,7 +203,7 @@ protected float[] getTransformedPositions() { protected void drawZeroLine(Canvas c) { // draw zero line - PointD pos = mTrans.getPixelsForValues(0f, 0f); + MPPointD pos = mTrans.getPixelsForValues(0f, 0f); mZeroLinePaint.setColor(mYAxis.getZeroLineColor()); mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth()); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererHorizontalBarChart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererHorizontalBarChart.java index 21e16ba325..3f9f36a965 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererHorizontalBarChart.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererHorizontalBarChart.java @@ -10,7 +10,7 @@ import com.github.mikephil.charting.components.YAxis; import com.github.mikephil.charting.components.YAxis.AxisDependency; import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; -import com.github.mikephil.charting.utils.PointD; +import com.github.mikephil.charting.utils.MPPointD; import com.github.mikephil.charting.utils.Transformer; import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.ViewPortHandler; @@ -39,9 +39,9 @@ public void computeAxis(float yMin, float yMax, boolean inverted) { // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { - PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), + MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); - PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), + MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!inverted) { @@ -52,8 +52,8 @@ public void computeAxis(float yMin, float yMax, boolean inverted) { yMax = (float) p1.x; } - PointD.recycleInstance(p1); - PointD.recycleInstance(p2); + MPPointD.recycleInstance(p1); + MPPointD.recycleInstance(p2); } computeAxisValues(yMin, yMax); @@ -179,7 +179,7 @@ protected Path linePath(Path p, int i, float[] positions) { protected void drawZeroLine(Canvas c) { // draw zero line - PointD pos = mTrans.getPixelsForValues(0f, 0f); + MPPointD pos = mTrans.getPixelsForValues(0f, 0f); mZeroLinePaint.setColor(mYAxis.getZeroLineColor()); mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth()); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/PointD.java b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointD.java similarity index 55% rename from MPChartLib/src/main/java/com/github/mikephil/charting/utils/PointD.java rename to MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointD.java index c69c4da7d3..f6220a72e9 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/PointD.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointD.java @@ -8,27 +8,27 @@ * * @author Philipp Jahoda */ -public class PointD extends ObjectPool.Poolable { +public class MPPointD extends ObjectPool.Poolable { - private static ObjectPool pool; + private static ObjectPool pool; static { - pool = ObjectPool.create(64, new PointD(0,0)); + pool = ObjectPool.create(64, new MPPointD(0,0)); pool.setReplenishPercentage(0.5f); } - public static PointD getInstance(double x, double y){ - PointD result = pool.get(); + public static MPPointD getInstance(double x, double y){ + MPPointD result = pool.get(); result.x = x; result.y = y; return result; } - public static void recycleInstance(PointD instance){ + public static void recycleInstance(MPPointD instance){ pool.recycle(instance); } - public static void recycleInstances(List instances){ + public static void recycleInstances(List instances){ pool.recycle(instances); } @@ -36,10 +36,10 @@ public static void recycleInstances(List instances){ public double y; protected ObjectPool.Poolable instantiate(){ - return new PointD(0,0); + return new MPPointD(0,0); } - private PointD(double x, double y) { + private MPPointD(double x, double y) { this.x = x; this.y = y; } @@ -48,6 +48,6 @@ private PointD(double x, double y) { * returns a string representation of the object */ public String toString() { - return "PointD, x: " + x + ", y: " + y; + return "MPPointD, x: " + x + ", y: " + y; } } \ No newline at end of file diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointF.java b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointF.java index f2e6c71fea..2e3fc58934 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointF.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointF.java @@ -9,6 +9,7 @@ * Created by Tony Patino on 6/24/16. */ public class MPPointF extends ObjectPool.Poolable { + private static ObjectPool pool; public float x; diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/Transformer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/Transformer.java index e842084936..be6d4cefe8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/Transformer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/Transformer.java @@ -385,9 +385,9 @@ public void pixelsToValue(float[] pixels) { float[] ptsBuffer = new float[2]; /** - * Returns a recyclable PointD instance. + * Returns a recyclable MPPointD instance. * returns the x and y values in the chart at the given touch point - * (encapsulated in a PointD). This method transforms pixel coordinates to + * (encapsulated in a MPPointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * @@ -395,14 +395,14 @@ public void pixelsToValue(float[] pixels) { * @param y * @return */ - public PointD getValuesByTouchPoint(float x, float y) { + public MPPointD getValuesByTouchPoint(float x, float y) { - PointD result = PointD.getInstance(0,0); + MPPointD result = MPPointD.getInstance(0,0); getValuesByTouchPoint(x,y,result); return result; } - public void getValuesByTouchPoint(float x, float y, PointD outputPoint){ + public void getValuesByTouchPoint(float x, float y, MPPointD outputPoint){ ptsBuffer[0] = x; ptsBuffer[1] = y; @@ -414,14 +414,14 @@ public void getValuesByTouchPoint(float x, float y, PointD outputPoint){ } /** - * Returns a recyclable PointD instance. + * Returns a recyclable MPPointD instance. * Returns the x and y coordinates (pixels) for a given x and y value in the chart. * * @param x * @param y * @return */ - public PointD getPixelsForValues(float x, float y) { + public MPPointD getPixelsForValues(float x, float y) { ptsBuffer[0] = x; ptsBuffer[1] = y; @@ -431,7 +431,7 @@ public PointD getPixelsForValues(float x, float y) { double xPx = ptsBuffer[0]; double yPx = ptsBuffer[1]; - return PointD.getInstance(xPx, yPx); + return MPPointD.getInstance(xPx, yPx); } public Matrix getValueMatrix() {