Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void zoomIn() {

MPPointF center = mViewPortHandler.getContentCenter();

mViewPortHandler.zoomIn(center.x, -center.y, mZoomMatrixBuffer);
mViewPortHandler.zoomIn(center.getX(), -center.getY(), mZoomMatrixBuffer);
mViewPortHandler.refresh(mZoomMatrixBuffer, this, false);

MPPointF.recycleInstance(center);
Expand All @@ -615,7 +615,7 @@ public void zoomOut() {

MPPointF center = mViewPortHandler.getContentCenter();

mViewPortHandler.zoomOut(center.x, -center.y, mZoomMatrixBuffer);
mViewPortHandler.zoomOut(center.getX(), -center.getY(), mZoomMatrixBuffer);
mViewPortHandler.refresh(mZoomMatrixBuffer, this, false);

MPPointF.recycleInstance(center);
Expand Down Expand Up @@ -669,7 +669,7 @@ public void zoom(float scaleX, float scaleY, float x, float y) {
*/
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);
Runnable job = ZoomJob.Companion.getInstance(mViewPortHandler, scaleX, scaleY, xValue, yValue, getTransformer(axis), axis, this);
addViewportJob(job);
}

Expand All @@ -681,7 +681,7 @@ public void zoomToCenter(float scaleX, float scaleY) {
MPPointF center = getCenterOffsets();

Matrix save = mZoomMatrixBuffer;
mViewPortHandler.zoom(scaleX, scaleY, center.x, -center.y, save);
mViewPortHandler.zoom(scaleX, scaleY, center.getX(), -center.getY(), save);
mViewPortHandler.refresh(save, this, false);
}

Expand All @@ -692,10 +692,10 @@ public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, floa

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);
Runnable job = AnimatedZoomJob.Companion.getInstance(mViewPortHandler, this, getTransformer(axis), getAxis(axis), mXAxis.mAxisRange, scaleX, scaleY, mViewPortHandler.getScaleX(), mViewPortHandler.getScaleY(), xValue, yValue, (float) origin.getX(), (float) origin.getY(), duration);
addViewportJob(job);

MPPointD.recycleInstance(origin);
MPPointD.Companion.recycleInstance(origin);
}

protected Matrix mFitScreenMatrixBuffer = new Matrix();
Expand Down Expand Up @@ -797,7 +797,7 @@ public void setVisibleYRange(float minYRange, float maxYRange, AxisDependency ax
*/
public void moveViewToX(float xValue) {

Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue, 0f, getTransformer(AxisDependency.LEFT), this);
Runnable job = MoveViewJob.Companion.getInstance(mViewPortHandler, xValue, 0f, getTransformer(AxisDependency.LEFT), this);

addViewportJob(job);
}
Expand All @@ -813,7 +813,7 @@ 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);
Runnable job = MoveViewJob.Companion.getInstance(mViewPortHandler, xValue, yValue + yInView / 2f, getTransformer(axis), this);

addViewportJob(job);
}
Expand All @@ -831,11 +831,11 @@ public void moveViewToAnimated(float xValue, float yValue, AxisDependency 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);
Runnable job = AnimatedMoveViewJob.Companion.getInstance(mViewPortHandler, xValue, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.getX(), (float) bounds.getY(), duration);

addViewportJob(job);

MPPointD.recycleInstance(bounds);
MPPointD.Companion.recycleInstance(bounds);
}

/**
Expand All @@ -848,7 +848,7 @@ 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);
Runnable job = MoveViewJob.Companion.getInstance(mViewPortHandler, 0f, yValue + valsInView / 2f, getTransformer(axis), this);

addViewportJob(job);
}
Expand All @@ -865,7 +865,7 @@ 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);
Runnable job = MoveViewJob.Companion.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this);

addViewportJob(job);
}
Expand All @@ -883,11 +883,11 @@ public void centerViewToAnimated(float xValue, float yValue, AxisDependency 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);
Runnable job = AnimatedMoveViewJob.Companion.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.getX(), (float) bounds.getY(), duration);

addViewportJob(job);

MPPointD.recycleInstance(bounds);
MPPointD.Companion.recycleInstance(bounds);
}

/**
Expand Down Expand Up @@ -969,7 +969,7 @@ public MPPointF getPosition(Entry e, AxisDependency axis) {

getTransformer(axis).pointValuesToPixel(mGetPositionBuffer);

return MPPointF.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]);
return MPPointF.Companion.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]);
}

/**
Expand Down Expand Up @@ -1209,7 +1209,7 @@ public void setKeepPositionOnRotation(boolean keepPositionOnRotation) {
* getPixelForValues(...).
*/
public MPPointD getValuesByTouchPoint(float x, float y, AxisDependency axis) {
MPPointD result = MPPointD.getInstance(0, 0);
MPPointD result = MPPointD.Companion.getInstance(0, 0);
getValuesByTouchPoint(x, y, axis, result);
return result;
}
Expand Down Expand Up @@ -1252,21 +1252,21 @@ public IBarLineScatterCandleBubbleDataSet getDataSetByTouchPoint(float x, float
/**
* buffer for storing lowest visible x point
*/
protected MPPointD posForGetLowestVisibleX = MPPointD.getInstance(0, 0);
protected MPPointD posForGetLowestVisibleX = MPPointD.Companion.getInstance(0, 0);

/**
* Returns the lowest x-index (value on the x-axis) that is still visible on the chart.
*/
@Override
public float getLowestVisibleX() {
getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom(), posForGetLowestVisibleX);
return (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.x);
return (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.getX());
}

/**
* buffer for storing highest visible x point
*/
protected MPPointD posForGetHighestVisibleX = MPPointD.getInstance(0, 0);
protected MPPointD posForGetHighestVisibleX = MPPointD.Companion.getInstance(0, 0);

/**
* Returns the highest x-index (value on the x-axis) that is still visible
Expand All @@ -1275,7 +1275,7 @@ public float getLowestVisibleX() {
@Override
public float getHighestVisibleX() {
getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentBottom(), posForGetHighestVisibleX);
return (float) Math.min(mXAxis.mAxisMaximum, posForGetHighestVisibleX.x);
return (float) Math.min(mXAxis.mAxisMaximum, posForGetHighestVisibleX.getX());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,17 @@ protected void onDraw(@NonNull Canvas canvas) {

switch (mInfoPaint.getTextAlign()) {
case LEFT:
pt.x = 0;
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
pt.setX(0);
canvas.drawText(mNoDataText, pt.getX(), pt.getY(), mInfoPaint);
break;

case RIGHT:
pt.x *= 2.0F;
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
pt.setX(pt.getX() * 2.0F);
canvas.drawText(mNoDataText, pt.getX(), pt.getY(), mInfoPaint);
break;

default:
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
canvas.drawText(mNoDataText, pt.getX(), pt.getY(), mInfoPaint);
break;
}
}
Expand Down Expand Up @@ -437,8 +437,8 @@ protected void drawDescription(Canvas c) {
x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset();
y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset();
} else {
x = position.x;
y = position.y;
x = position.getX();
y = position.getY();
}

c.drawText(mDescription.text, x, y, mDescPaint);
Expand Down Expand Up @@ -1015,7 +1015,7 @@ public float getXRange() {
* Returns the center point of the chart (the whole View) in pixels.
*/
public MPPointF getCenter() {
return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f);
return MPPointF.Companion.getInstance(getWidth() / 2f, getHeight() / 2f);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public MPPointF getPosition(Entry e, AxisDependency axis) {

getTransformer(axis).pointValuesToPixel(vals);

return MPPointF.getInstance(vals[0], vals[1]);
return MPPointF.Companion.getInstance(vals[0], vals[1]);
}

/**
Expand All @@ -287,14 +287,14 @@ public Highlight getHighlightByTouchPoint(float x, float y) {
public float getLowestVisibleX() {
getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentLeft(),
mViewPortHandler.contentBottom(), posForGetLowestVisibleX);
return (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.y);
return (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.getY());
}

@Override
public float getHighestVisibleX() {
getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentLeft(),
mViewPortHandler.contentTop(), posForGetHighestVisibleX);
return (float) Math.min(mXAxis.mAxisMaximum, posForGetHighestVisibleX.y);
return (float) Math.min(mXAxis.mAxisMaximum, posForGetHighestVisibleX.getY());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class PieChart extends PieRadarChartBase<PieData> {
*/
private CharSequence mCenterText = "";

private final MPPointF mCenterTextOffset = MPPointF.getInstance(0, 0);
private final MPPointF mCenterTextOffset = MPPointF.Companion.getInstance(0, 0);

/**
* indicates the size of the hole in the center of the piechart,
Expand Down Expand Up @@ -170,10 +170,10 @@ public void calculateOffsets() {

// create the circle box that will contain the pie-chart (the bounds of
// the pie-chart)
mCircleBox.set(c.x - radius + shift,
c.y - radius + shift,
c.x + radius - shift,
c.y + radius - shift);
mCircleBox.set(c.getX() - radius + shift,
c.getY() - radius + shift,
c.getX() + radius - shift,
c.getY() + radius - shift);

MPPointF.recycleInstance(c);
}
Expand Down Expand Up @@ -207,10 +207,10 @@ protected float[] getMarkerPosition(Highlight highlight) {
// calculate the text position
float x = (float) (r
* Math.cos(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
* mAnimator.getPhaseY())) + center.x);
* mAnimator.getPhaseY())) + center.getX());
float y = (float) (r
* Math.sin(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
* mAnimator.getPhaseY())) + center.y);
* mAnimator.getPhaseY())) + center.getY());

MPPointF.recycleInstance(center);
return new float[]{x, y};
Expand Down Expand Up @@ -496,7 +496,7 @@ public RectF getCircleBox() {
*
*/
public MPPointF getCenterCircleBox() {
return MPPointF.getInstance(mCircleBox.centerX(), mCircleBox.centerY());
return MPPointF.Companion.getInstance(mCircleBox.centerX(), mCircleBox.centerY());
}

/**
Expand Down Expand Up @@ -529,16 +529,16 @@ public void setCenterTextSizePixels(float sizePixels) {
*
*/
public void setCenterTextOffset(float x, float y) {
mCenterTextOffset.x = UtilsKtKt.convertDpToPixel(x);
mCenterTextOffset.y = UtilsKtKt.convertDpToPixel(y);
mCenterTextOffset.setX(UtilsKtKt.convertDpToPixel(x));
mCenterTextOffset.setY(UtilsKtKt.convertDpToPixel(y));
}

/**
* Returns the offset on the x- and y-axis the center text has in dp.
*
*/
public MPPointF getCenterTextOffset() {
return MPPointF.getInstance(mCenterTextOffset.x, mCenterTextOffset.y);
return MPPointF.Companion.getInstance(mCenterTextOffset.getX(), mCenterTextOffset.getY());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ public void calculateOffsets() {
MPPointF reference = getPosition(center, getRadius(),
getAngleForPoint(bottomX, bottomY));

float distReference = distanceToCenter(reference.x, reference.y);
float distReference = distanceToCenter(reference.getX(), reference.getY());
float minOffset = UtilsKtKt.convertDpToPixel(5f);

if (bottomY >= center.y && getHeight() - legendWidth > getWidth()) {
if (bottomY >= center.getY() && getHeight() - legendWidth > getWidth()) {
xLegendOffset = legendWidth;
} else if (distLegend < distReference) {

Expand Down Expand Up @@ -258,13 +258,13 @@ public float getAngleForPoint(float x, float y) {

MPPointF c = getCenterOffsets();

double tx = x - c.x, ty = y - c.y;
double tx = x - c.getX(), ty = y - c.getY();
double length = Math.sqrt(tx * tx + ty * ty);
double r = Math.acos(ty / length);

float angle = (float) Math.toDegrees(r);

if (x > c.x)
if (x > c.getX())
angle = 360f - angle;

// add 90° because chart starts EAST
Expand All @@ -287,14 +287,14 @@ public float getAngleForPoint(float x, float y) {
*/
public MPPointF getPosition(MPPointF center, float dist, float angle) {

MPPointF p = MPPointF.getInstance(0, 0);
MPPointF p = MPPointF.Companion.getInstance(0, 0);
getPosition(center, dist, angle, p);
return p;
}

public void getPosition(MPPointF center, float dist, float angle, MPPointF outputPoint) {
outputPoint.x = (float) (center.x + dist * Math.cos(Math.toRadians(angle)));
outputPoint.y = (float) (center.y + dist * Math.sin(Math.toRadians(angle)));
outputPoint.setX((float) (center.getX() + dist * Math.cos(Math.toRadians(angle))));
outputPoint.setY((float) (center.getY() + dist * Math.sin(Math.toRadians(angle))));
}

/**
Expand All @@ -309,16 +309,16 @@ public float distanceToCenter(float x, float y) {
float xDist;
float yDist;

if (x > c.x) {
xDist = x - c.x;
if (x > c.getX()) {
xDist = x - c.getX();
} else {
xDist = c.x - x;
xDist = c.getX() - x;
}

if (y > c.y) {
yDist = y - c.y;
if (y > c.getY()) {
yDist = y - c.getY();
} else {
yDist = c.y - y;
yDist = c.getY() - y;
}

// pythagoras
Expand Down
Loading
Loading