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


Java PieChartData.getCenterCircleScale方法代码示例

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


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

示例1: onChartDataChanged

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
@Override
public void onChartDataChanged() {
    super.onChartDataChanged();
    final PieChartData data = dataProvider.getPieChartData();
    hasLabelsOutside = data.hasLabelsOutside();
    hasLabels = data.hasLabels();
    hasLabelsOnlyForSelected = data.hasLabelsOnlyForSelected();
    valueFormatter = data.getFormatter();
    hasCenterCircle = data.hasCenterCircle();
    centerCircleScale = data.getCenterCircleScale();
    centerCirclePaint.setColor(data.getCenterCircleColor());
    if (null != data.getCenterText1Typeface()) {
        centerCircleText1Paint.setTypeface(data.getCenterText1Typeface());
    }
    centerCircleText1Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText1FontSize()));
    centerCircleText1Paint.setColor(data.getCenterText1Color());
    centerCircleText1Paint.getFontMetricsInt(centerCircleText1FontMetrics);
    if (null != data.getCenterText2Typeface()) {
        centerCircleText2Paint.setTypeface(data.getCenterText2Typeface());
    }
    centerCircleText2Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText2FontSize()));
    centerCircleText2Paint.setColor(data.getCenterText2Color());
    centerCircleText2Paint.getFontMetricsInt(centerCircleText2FontMetrics);

    onChartViewportChanged();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PieChartRenderer.java

示例2: drawCenterCircle

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
/**
 * Draw center circle with text if {@link PieChartData#hasCenterCircle()} is set true.
 */
private void drawCenterCircle(Canvas canvas) {
    final PieChartData data = dataProvider.getPieChartData();
    final float circleRadius = originCircleOval.width() / 2f;
    final float centerRadius = circleRadius * data.getCenterCircleScale();
    final float centerX = originCircleOval.centerX();
    final float centerY = originCircleOval.centerY();

    canvas.drawCircle(centerX, centerY, centerRadius, centerCirclePaint);

    // Draw center text1 and text2 if not empty.
    if (!TextUtils.isEmpty(data.getCenterText1())) {

        final int text1Height = Math.abs(centerCircleText1FontMetrics.ascent);

        if (!TextUtils.isEmpty(data.getCenterText2())) {
            // Draw text 2 only if text 1 is not empty.
            final int text2Height = Math.abs(centerCircleText2FontMetrics.ascent);
            canvas.drawText(data.getCenterText1(), centerX, centerY - text1Height * 0.2f, centerCircleText1Paint);
            canvas.drawText(data.getCenterText2(), centerX, centerY + text2Height, centerCircleText2Paint);
        } else {
            canvas.drawText(data.getCenterText1(), centerX, centerY + text1Height / 4, centerCircleText1Paint);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:PieChartRenderer.java

示例3: onChartDataChanged

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
public void onChartDataChanged() {
    super.onChartDataChanged();
    PieChartData data = this.dataProvider.getPieChartData();
    this.hasLabelsOutside = data.hasLabelsOutside();
    this.hasLabels = data.hasLabels();
    this.hasLabelsOnlyForSelected = data.hasLabelsOnlyForSelected();
    this.valueFormatter = data.getFormatter();
    this.hasCenterCircle = data.hasCenterCircle();
    this.centerCircleScale = data.getCenterCircleScale();
    this.centerCirclePaint.setColor(data.getCenterCircleColor());
    if (data.getCenterText1Typeface() != null) {
        this.centerCircleText1Paint.setTypeface(data.getCenterText1Typeface());
    }
    this.centerCircleText1Paint.setTextSize((float) ChartUtils.sp2px(this.scaledDensity, data.getCenterText1FontSize()));
    this.centerCircleText1Paint.setColor(data.getCenterText1Color());
    this.centerCircleText1Paint.getFontMetricsInt(this.centerCircleText1FontMetrics);
    if (data.getCenterText2Typeface() != null) {
        this.centerCircleText2Paint.setTypeface(data.getCenterText2Typeface());
    }
    this.centerCircleText2Paint.setTextSize((float) ChartUtils.sp2px(this.scaledDensity, data.getCenterText2FontSize()));
    this.centerCircleText2Paint.setColor(data.getCenterText2Color());
    this.centerCircleText2Paint.getFontMetricsInt(this.centerCircleText2FontMetrics);
    onChartViewportChanged();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:PieChartRenderer.java

示例4: drawCenterCircle

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void drawCenterCircle(Canvas canvas) {
    PieChartData data = this.dataProvider.getPieChartData();
    float centerRadius = (this.originCircleOval.width() / 2.0f) * data.getCenterCircleScale();
    float centerX = this.originCircleOval.centerX();
    float centerY = this.originCircleOval.centerY();
    canvas.drawCircle(centerX, centerY, centerRadius, this.centerCirclePaint);
    if (!TextUtils.isEmpty(data.getCenterText1())) {
        int text1Height = Math.abs(this.centerCircleText1FontMetrics.ascent);
        if (TextUtils.isEmpty(data.getCenterText2())) {
            canvas.drawText(data.getCenterText1(), centerX, ((float) (text1Height / 4)) + centerY, this.centerCircleText1Paint);
            return;
        }
        int text2Height = Math.abs(this.centerCircleText2FontMetrics.ascent);
        canvas.drawText(data.getCenterText1(), centerX, centerY - (((float) text1Height) * 0.2f), this.centerCircleText1Paint);
        canvas.drawText(data.getCenterText2(), centerX, ((float) text2Height) + centerY, this.centerCircleText2Paint);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:PieChartRenderer.java

示例5: checkTouch

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
@Override
public boolean checkTouch(float touchX, float touchY) {
    selectedValue.clear();
    final PieChartData data = dataProvider.getPieChartData();
    final float centerX = originCircleOval.centerX();
    final float centerY = originCircleOval.centerY();
    final float circleRadius = originCircleOval.width() / 2f;

    sliceVector.set(touchX - centerX, touchY - centerY);
    // Check if touch is on circle area, if not return false;
    if (sliceVector.length() > circleRadius + touchAdditional) {
        return false;
    }
    // Check if touch is not in center circle, if yes return false;
    if (data.hasCenterCircle() && sliceVector.length() < circleRadius * data.getCenterCircleScale()) {
        return false;
    }

    // Get touchAngle and align touch 0 degrees with chart 0 degrees, that why I subtracting start angle,
    // adding 360
    // and modulo 360 translates i.e -20 degrees to 340 degrees.
    final float touchAngle = (pointToAngle(touchX, touchY, centerX, centerY) - rotation + 360f) % 360f;
    final float sliceScale = 360f / maxSum;
    float lastAngle = 0f; // No start angle here, see above
    int sliceIndex = 0;
    for (SliceValue sliceValue : data.getValues()) {
        final float angle = Math.abs(sliceValue.getValue()) * sliceScale;
        if (touchAngle >= lastAngle) {
            selectedValue.set(sliceIndex, sliceIndex, SelectedValueType.NONE);
        }
        lastAngle += angle;
        ++sliceIndex;
    }
    return isTouched();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:PieChartRenderer.java

示例6: checkTouch

import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
public boolean checkTouch(float touchX, float touchY) {
    this.selectedValue.clear();
    PieChartData data = this.dataProvider.getPieChartData();
    float centerX = this.originCircleOval.centerX();
    float centerY = this.originCircleOval.centerY();
    float circleRadius = this.originCircleOval.width() / 2.0f;
    this.sliceVector.set(touchX - centerX, touchY - centerY);
    if (this.sliceVector.length() > ((float) this.touchAdditional) + circleRadius) {
        return false;
    }
    if (data.hasCenterCircle() && this.sliceVector.length() < data.getCenterCircleScale() * circleRadius) {
        return false;
    }
    float touchAngle = ((pointToAngle(touchX, touchY, centerX, centerY) - ((float) this.rotation)) + 360.0f) % 360.0f;
    float sliceScale = 360.0f / this.maxSum;
    float lastAngle = 0.0f;
    int sliceIndex = 0;
    for (SliceValue sliceValue : data.getValues()) {
        float angle = Math.abs(sliceValue.getValue()) * sliceScale;
        if (touchAngle >= lastAngle) {
            this.selectedValue.set(sliceIndex, sliceIndex, SelectedValueType.NONE);
        }
        lastAngle += angle;
        sliceIndex++;
    }
    return isTouched();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:PieChartRenderer.java


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