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


Java MPPointF类代码示例

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


MPPointF类属于com.github.mikephil.charting.utils包,在下文中一共展示了MPPointF类的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: onDraw

import com.github.mikephil.charting.utils.MPPointF; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    // super.onDraw(canvas);

    if (mData == null) {

        boolean hasText = !TextUtils.isEmpty(mNoDataText);

        if (hasText) {
            MPPointF c = getCenter();
            canvas.drawText(mNoDataText, c.x, c.y, mInfoPaint);
        }

        return;
    }

    if (!mOffsetsCalculated) {

        calculateOffsets();
        mOffsetsCalculated = true;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Chart.java

示例5: getTrans

import com.github.mikephil.charting.utils.MPPointF; //导入依赖的package包/类
/**
 * Returns a recyclable MPPointF instance.
 * returns the correct translation depending on the provided x and y touch
 * points
 *
 * @param x
 * @param y
 * @return
 */
public MPPointF getTrans(float x, float y) {

    ViewPortHandler vph = mChart.getViewPortHandler();

    float xTrans = x - vph.offsetLeft();
    float yTrans = 0f;

    // check if axis is inverted
    if (inverted()) {
        yTrans = -(y - vph.offsetTop());
    } else {
        yTrans = -(mChart.getMeasuredHeight() - y - vph.offsetBottom());
    }

    return MPPointF.getInstance(xTrans, yTrans);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:BarLineChartTouchListener.java

示例6: getOffsetForDrawingAtPoint

import com.github.mikephil.charting.utils.MPPointF; //导入依赖的package包/类
@Override
public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) {

    MPPointF offset = getOffset();
    mOffset2.x = offset.x;
    mOffset2.y = offset.y;

    Chart chart = getChartView();

    float width = getWidth();
    float height = getHeight();

    if (posX + mOffset2.x < 0) {
        mOffset2.x = - posX;
    } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) {
        mOffset2.x = chart.getWidth() - posX - width;
    }

    if (posY + mOffset2.y < 0) {
        mOffset2.y = - posY;
    } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) {
        mOffset2.y = chart.getHeight() - posY - height;
    }

    return mOffset2;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:MarkerView.java

示例7: 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

示例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, 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

示例9: setPieChartData

import com.github.mikephil.charting.utils.MPPointF; //导入依赖的package包/类
private void setPieChartData(int count, float range) {

        ArrayList<PieEntry> entries = ChartData.getPieData(count, range);
        PieDataSet dataSet = new PieDataSet(entries, "Weekly spend distribution");

        dataSet.setDrawIcons(false);
        dataSet.setSliceSpace(3f);
        dataSet.setIconsOffset(new MPPointF(0, 40));
        dataSet.setSelectionShift(5f);

        ArrayList<Integer> colors = new ArrayList<>();
        for (int c : ColorTemplate.LIBERTY_COLORS)
            colors.add(c);
        dataSet.setColors(colors);

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(11f);
        data.setValueTextColor(Color.GRAY);
        pieChart.setData(data);
        pieChart.highlightValues(null);
        pieChart.invalidate();
    }
 
开发者ID:VidyaSastry,项目名称:Opal-Chat-AnalyticsDashboard,代码行数:24,代码来源:DashboardFragment.java

示例10: 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:xsingHu,项目名称:xs-android-architecture,代码行数:19,代码来源:BarLineChartBase.java

示例11: 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:xsingHu,项目名称:xs-android-architecture,代码行数:19,代码来源:BarLineChartBase.java

示例12: 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

示例13: 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

示例14: 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

示例15: zoomToCenter

import com.github.mikephil.charting.utils.MPPointF; //导入依赖的package包/类
/**
 * Zooms to the center of the chart with the given scale factor.
 *
 * @param scaleX
 * @param scaleY
 */
public void zoomToCenter(float scaleX, float scaleY) {

    MPPointF center = getCenterOffsets();

    Matrix save = mZoomMatrixBuffer;
    mViewPortHandler.zoom(scaleX, scaleY, center.x, -center.y, save);
    mViewPortHandler.refresh(save, this, false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:BarLineChartBase.java


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