Esempio n. 1
0
    /** draw graph without animation */
    private void drawGraphRegionWithoutAnimation(GraphCanvasWrapper graphCanvas) {

      boolean isDrawRegion = mLineGraphVO.isDrawRegion();

      for (int i = 0; i < mLineGraphVO.getArrGraph().size(); i++) {
        GraphPath regionPath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        boolean firstSet = false;
        float x = 0;
        float y = 0;
        p.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        pCircle.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        float xGap = xLength / (mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length - 1);

        for (int j = 0; j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length; j++) {
          if (j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length) {

            if (!firstSet) {

              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              regionPath.moveTo(x, 0);
              regionPath.lineTo(x, y);

              firstSet = true;
            } else {
              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              regionPath.lineTo(x, y);
            }
          }
        }

        if (isDrawRegion) {
          regionPath.lineTo(x, 0);
          regionPath.lineTo(0, 0);

          Paint pBg = new Paint();
          pBg.setFlags(Paint.ANTI_ALIAS_FLAG);
          pBg.setAntiAlias(true); // text anti alias
          pBg.setFilterBitmap(true); // bitmap anti alias
          pBg.setStyle(Style.FILL);
          pBg.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
          graphCanvas.getCanvas().drawPath(regionPath, pBg);
        }
      }
    }
Esempio n. 2
0
    /** draw graph without animation */
    private void drawGraphWithoutAnimation(GraphCanvasWrapper graphCanvas) {

      for (int i = 0; i < mLineGraphVO.getArrGraph().size(); i++) {
        GraphPath linePath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        GraphPath regionPath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        boolean firstSet = false;
        float x = 0;
        float y = 0;
        p.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        pCircle.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        float xGap = xLength / (mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length - 1);

        Bitmap icon = arrIcon.get(i);

        for (int j = 0; j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length; j++) {
          if (j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length) {

            if (!firstSet) {

              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              linePath.moveTo(x, y);

              firstSet = true;
            } else {
              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              linePath.lineTo(x, y);
            }

            if (icon == null) {
              graphCanvas.drawCircle(x, y, 4, pCircle);
            } else {
              graphCanvas.drawBitmapIcon(icon, x, y, null);
            }
          }
        }

        graphCanvas.getCanvas().drawPath(linePath, p);
      }
    }
Esempio n. 3
0
    /** draw graph with animation */
    private void drawGraphWithAnimation(GraphCanvasWrapper graphCanvas) {
      // for draw animation
      float prev_x = 0;
      float prev_y = 0;

      float next_x = 0;
      float next_y = 0;

      float value = 0;
      float mode = 0;

      for (int i = 0; i < mLineGraphVO.getArrGraph().size(); i++) {
        GraphPath linePath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        GraphPath regionPath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        boolean firstSet = false;
        float x = 0;
        float y = 0;
        p.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        pCircle.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        float xGap = xLength / (mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length - 1);

        Bitmap icon = arrIcon.get(i);
        value = anim / 1;
        mode = anim % 1;

        for (int j = 0; j < value + 1; j++) {
          if (j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length) {

            if (!firstSet) {

              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              linePath.moveTo(x, y);

              firstSet = true;
            } else {
              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              if (j > value && mode != 0) {
                next_x = x - prev_x;
                next_y = y - prev_y;

                linePath.lineTo(prev_x + next_x * mode, prev_y + next_y * mode);
              } else {
                linePath.lineTo(x, y);
              }
            }

            if (icon == null) {
              graphCanvas.drawCircle(x, y, 4, pCircle);
            } else {
              graphCanvas.drawBitmapIcon(icon, x, y, null);
            }
            prev_x = x;
            prev_y = y;
          }
        }

        graphCanvas.getCanvas().drawPath(linePath, p);
      }
    }
Esempio n. 4
0
    /** draw graph with animation */
    private void drawGraphRegionWithAnimation(GraphCanvasWrapper graphCanvas) {
      // for draw animation
      float prev_x = 0;
      float prev_y = 0;

      float next_x = 0;
      float next_y = 0;

      int value = 0;
      float mode = 0;

      boolean isDrawRegion = mLineGraphVO.isDrawRegion();

      for (int i = 0; i < mLineGraphVO.getArrGraph().size(); i++) {
        GraphPath regionPath =
            new GraphPath(
                width, height, mLineGraphVO.getPaddingLeft(), mLineGraphVO.getPaddingBottom());
        boolean firstSet = false;
        float x = 0;
        float y = 0;
        p.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        pCircle.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
        float xGap = xLength / (mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length - 1);

        value = (int) (anim / 1);
        mode = anim % 1;

        boolean isFinish = false;
        for (int j = 0; j <= value + 1; j++) {
          if (j < mLineGraphVO.getArrGraph().get(i).getCoordinateArr().length) {

            if (!firstSet) {

              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              regionPath.moveTo(x, 0);
              regionPath.lineTo(x, y);

              firstSet = true;
            } else {
              x = xGap * j;
              y =
                  yLength
                      * mLineGraphVO.getArrGraph().get(i).getCoordinateArr()[j]
                      / mLineGraphVO.getMaxValue();

              if (j > value) {
                next_x = x - prev_x;
                next_y = y - prev_y;
                regionPath.lineTo(prev_x + next_x * mode, prev_y + next_y * mode);
              } else {
                regionPath.lineTo(x, y);
              }
            }

            prev_x = x;
            prev_y = y;
          }
        }
        isFinish = true;

        if (isDrawRegion) {
          float x_bg = prev_x + next_x * mode;
          if (x_bg >= xLength) {
            x_bg = xLength;
          }
          regionPath.lineTo(x_bg, 0);
          regionPath.lineTo(0, 0);

          Paint pBg = new Paint();
          pBg.setFlags(Paint.ANTI_ALIAS_FLAG);
          pBg.setAntiAlias(true); // text anti alias
          pBg.setFilterBitmap(true); // bitmap anti alias
          pBg.setStyle(Style.FILL);
          pBg.setColor(mLineGraphVO.getArrGraph().get(i).getColor());
          graphCanvas.getCanvas().drawPath(regionPath, pBg);
        }
      }
    }