Esempio n. 1
0
  /**
   * 绘制图网络线
   *
   * @param canvas 画布
   * @param lineData 数据集类
   * @param arrayDataX x坐标
   * @param arrayDataY y坐标
   */
  private void drawDataPath(
      Canvas canvas, RadarData lineData, Float[] arrayDataX, Float[] arrayDataY) {
    float startX = 0.0f, startY = 0.0f;
    float initX = 0.0f, initY = 0.0f;

    Path pathArea = new Path();

    for (int p = 0; p < arrayDataX.length; p++) {
      if (0 == p) {
        initX = startX = arrayDataX[p];
        initY = startY = arrayDataY[p];

        pathArea.moveTo(initX, initY);
      } else {
        pathArea.lineTo(arrayDataX[p], arrayDataY[p]);
        startX = arrayDataX[p];
        startY = arrayDataY[p];
      }
      // 绘制点及对应的标签
      renderDotAndLabel(canvas, lineData, arrayDataX[p], arrayDataY[p], p);
    }
    // 收尾
    pathArea.lineTo(initX, initY);
    pathArea.close();

    lineData.getPlotLine().getLinePaint().setAlpha(mAreaAlpha);
    // lineData.getPlotLine().getLinePaint().setStyle(Style.STROKE);
    canvas.drawPath(pathArea, lineData.getPlotLine().getLinePaint());
  }
Esempio n. 2
0
  /**
   * 绘制数据连接线
   *
   * @param canvas 画布
   * @param lineData 数据集类
   * @param arrayDataX x坐标
   * @param arrayDataY y坐标
   */
  private void renderDataLine(
      Canvas canvas, RadarData lineData, Float[] arrayDataX, Float[] arrayDataY) {
    float startX = 0.0f, startY = 0.0f;
    float initX = 0.0f, initY = 0.0f;

    for (int p = 0; p < arrayDataX.length; p++) {
      if (0 == p) {
        initX = startX = arrayDataX[p];
        initY = startY = arrayDataY[p];
      } else {
        DrawHelper.getInstance()
            .drawLine(
                lineData.getLineStyle(),
                startX,
                startY,
                arrayDataX[p],
                arrayDataY[p],
                canvas,
                lineData.getPlotLine().getLinePaint());

        startX = arrayDataX[p];
        startY = arrayDataY[p];
      }
      // 绘制点及对应的标签
      renderDotAndLabel(canvas, lineData, arrayDataX[p], arrayDataY[p], p);
    }
    // 收尾
    DrawHelper.getInstance()
        .drawLine(
            lineData.getLineStyle(),
            startX,
            startY,
            initX,
            initY,
            canvas,
            lineData.getPlotLine().getLinePaint());
  }