当前位置: 首页>>代码示例>>Java>>正文


Java MPPointF.recycleInstance方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.utils.MPPointF.recycleInstance方法的典型用法代码示例。如果您正苦于以下问题:Java MPPointF.recycleInstance方法的具体用法?Java MPPointF.recycleInstance怎么用?Java MPPointF.recycleInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.utils.MPPointF的用法示例。


在下文中一共展示了MPPointF.recycleInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateOffsets

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void calculateOffsets() {
    super.calculateOffsets();

    // prevent nullpointer when no data set
    if (mData == null)
        return;

    float diameter = getDiameter();
    float radius = diameter / 2f;

    MPPointF c = getCenterOffsets();

    float shift = mData.getDataSet().getSelectionShift();

    // 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);

    MPPointF.recycleInstance(c);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:PieChart.java

示例2: zoomIn

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * Zooms in by 1.4f, into the charts center.
 */
public void zoomIn() {

    MPPointF center = mViewPortHandler.getContentCenter();

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

    MPPointF.recycleInstance(center);

    // Range might have changed, which means that Y-axis labels
    // could have changed in size, affecting Y-axis size.
    // So we need to recalculate offsets.
    calculateOffsets();
    postInvalidate();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BarLineChartBase.java

示例3: zoomOut

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * Zooms out by 0.7f, from the charts center.
 */
public void zoomOut() {

    MPPointF center = mViewPortHandler.getContentCenter();

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

    MPPointF.recycleInstance(center);

    // Range might have changed, which means that Y-axis labels
    // could have changed in size, affecting Y-axis size.
    // So we need to recalculate offsets.
    calculateOffsets();
    postInvalidate();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BarLineChartBase.java

示例4: onValueSelected

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {

    if (e == null)
        return;

    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);
    MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);

    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());

    Log.i("x-index",
            "low: " + mChart.getLowestVisibleX() + ", high: "
                    + mChart.getHighestVisibleX());

    MPPointF.recycleInstance(position);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BarChartActivity.java

示例5: onValueSelected

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {

    if (e == null)
        return;

    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);

    MPPointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
            .getAxisDependency());

    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());

    MPPointF.recycleInstance(position);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:HorizontalBarChartActivity.java

示例6: zoomIn

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * Zooms in by 1.4f, into the charts center. center.
 */
public void zoomIn() {

    MPPointF center = mViewPortHandler.getContentCenter();

    mViewPortHandler.zoomIn(center.x, -center.y, mZoomInMatrixBuffer);
    mViewPortHandler.refresh(mZoomInMatrixBuffer, this, false);

    MPPointF.recycleInstance(center);

    // Range might have changed, which means that Y-axis labels
    // could have changed in size, affecting Y-axis size.
    // So we need to recalculate offsets.
    calculateOffsets();
    postInvalidate();
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:19,代码来源:BarLineChartBase.java

示例7: zoomOut

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * Zooms out by 0.7f, from the charts center. center.
 */
public void zoomOut() {

    MPPointF center = mViewPortHandler.getContentCenter();

    mViewPortHandler.zoomOut(center.x, -center.y, mZoomOutMatrixBuffer);
    mViewPortHandler.refresh(mZoomOutMatrixBuffer, this, false);

    MPPointF.recycleInstance(center);

    // Range might have changed, which means that Y-axis labels
    // could have changed in size, affecting Y-axis size.
    // So we need to recalculate offsets.
    calculateOffsets();
    postInvalidate();
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:19,代码来源:BarLineChartBase.java

示例8: onValueSelected

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {

    if (e == null)
        return;

    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);
    MPPointF position = mChart.getPosition(e, YAxis.AxisDependency.LEFT);

    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());

    Log.i("x-index",
            "low: " + mChart.getLowestVisibleX() + ", high: "
                    + mChart.getHighestVisibleX());

    MPPointF.recycleInstance(position);
}
 
开发者ID:bounswe,项目名称:bounswe2016group2,代码行数:21,代码来源:MicroPieChartFragment.java

示例9: distanceToCenter

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * Returns the distance of a certain point on the chart to the center of the
 * chart.
 *
 * @param x
 * @param y
 * @return
 */
public float distanceToCenter(float x, float y) {

    MPPointF c = getCenterOffsets();

    float dist = 0f;

    float xDist = 0f;
    float yDist = 0f;

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

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

    // pythagoras
    dist = (float) Math.sqrt(Math.pow(xDist, 2.0) + Math.pow(yDist, 2.0));

    MPPointF.recycleInstance(c);

    return dist;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:PieRadarChartBase.java

示例10: getMarkerPosition

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
protected float[] getMarkerPosition(Highlight highlight) {

    MPPointF center = getCenterCircleBox();
    float r = getRadius();

    float off = r / 10f * 3.6f;

    if (isDrawHoleEnabled()) {
        off = (r - (r / 100f * getHoleRadius())) / 2f;
    }

    r -= off; // offset to keep things inside the chart

    float rotationAngle = getRotationAngle();

    int entryIndex = (int) highlight.getX();

    // offset needed to center the drawn text in the slice
    float offset = mDrawAngles[entryIndex] / 2;

    // calculate the text position
    float x = (float) (r
            * Math.cos(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
            * mAnimator.getPhaseY())) + center.x);
    float y = (float) (r
            * Math.sin(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
            * mAnimator.getPhaseY())) + center.y);

    MPPointF.recycleInstance(center);
    return new float[]{x, y};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:PieChart.java

示例11: renderAxisLabels

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    float factor = mChart.getFactor();

    final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
    final int to = mYAxis.isDrawTopYLabelEntryEnabled()
            ? mYAxis.mEntryCount
            : (mYAxis.mEntryCount - 1);

    for (int j = from; j < to; j++) {

        float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;

        Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);

        String label = mYAxis.getFormattedLabel(j);

        c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:YAxisRendererRadarChart.java

示例12: renderAxisLabels

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
        return;

    final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
    final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);

    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
    mAxisLabelPaint.setColor(mXAxis.getTextColor());

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {

        String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);

        float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;

        Utils.getPosition(center, mChart.getYRange() * factor
                + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);

        drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
                drawLabelAnchor, labelRotationAngleDegrees);
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
    MPPointF.recycleInstance(drawLabelAnchor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:XAxisRendererRadarChart.java

示例13: renderAxisLabels

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    float factor = mChart.getFactor();

    int labelCount = mYAxis.mEntryCount;

    for (int j = 0; j < labelCount; j++) {

        if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false)
            break;

        float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;

        Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);

        String label = mYAxis.getFormattedLabel(j);

        c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:33,代码来源:YAxisRendererRadarChart.java

示例14: getAngleForPoint

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
 * returns the angle relative to the chart center for the given point on the
 * chart in degrees. The angle is always between 0 and 360°, 0° is NORTH,
 * 90° is EAST, ...
 *
 * @param x
 * @param y
 * @return
 */
public float getAngleForPoint(float x, float y) {

    MPPointF c = getCenterOffsets();

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

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

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

    // add 90° because chart starts EAST
    angle = angle + 90f;

    // neutralize overflow
    if (angle > 360f)
        angle = angle - 360f;

    MPPointF.recycleInstance(c);

    return angle;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:PieRadarChartBase.java

示例15: renderLimitLines

import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderLimitLines(Canvas c) {

    List<LimitLine> limitLines = mYAxis.getLimitLines();

    if (limitLines == null)
        return;

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    for (int i = 0; i < limitLines.size(); i++) {

        LimitLine l = limitLines.get(i);

        if (!l.isEnabled())
            continue;

        mLimitLinePaint.setColor(l.getLineColor());
        mLimitLinePaint.setPathEffect(l.getDashPathEffect());
        mLimitLinePaint.setStrokeWidth(l.getLineWidth());

        float r = (l.getLimit() - mChart.getYChartMin()) * factor;

        Path limitPath = mRenderLimitLinesPathBuffer;
        limitPath.reset();


        for (int j = 0; j < mChart.getData().getMaxEntryCountSet().getEntryCount(); j++) {

            Utils.getPosition(center, r, sliceangle * j + mChart.getRotationAngle(), pOut);

            if (j == 0)
                limitPath.moveTo(pOut.x, pOut.y);
            else
                limitPath.lineTo(pOut.x, pOut.y);
        }
        limitPath.close();

        c.drawPath(limitPath, mLimitLinePaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:50,代码来源:YAxisRendererRadarChart.java


注:本文中的com.github.mikephil.charting.utils.MPPointF.recycleInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。