Skip to content

Commit

Permalink
Rename PointD to MPPointD
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Jul 2, 2016
1 parent 43fa1e6 commit 6d21817
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();

Expand All @@ -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");
}
Expand Down Expand Up @@ -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();
Expand All @@ -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");
}
Expand Down Expand Up @@ -1202,40 +1202,40 @@ 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(...).
*
* @param x
* @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(...).
*
* @param x
* @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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();

Expand All @@ -37,7 +37,7 @@ public Highlight getHighlight(float x, float y) {
(float) pos.y);
}

PointD.recycleInstance(pos);
MPPointD.recycleInstance(pos);

return high;
}
Expand Down Expand Up @@ -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(),
Expand All @@ -80,7 +80,7 @@ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal
high.getAxis()
);

PointD.recycleInstance(pixels);
MPPointD.recycleInstance(pixels);

return stackedHigh;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -37,7 +37,7 @@ public Highlight getHighlight(float x, float y) {
(float) pos.x);
}

PointD.recycleInstance(pos);
MPPointD.recycleInstance(pos);

return high;
}
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand All @@ -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);
Expand Down
Loading

0 comments on commit 6d21817

Please sign in to comment.