/**
   * draw lines
   *
   * <p>ラインを書く
   *
   * <p>绘制线条
   *
   * @param canvas
   */
  protected void drawAreas(Canvas canvas) {
    // distance between two points
    float lineLength = ((super.getWidth() - super.getAxisMarginLeft()) / displayNumber) - 1;
    // start point‘s X
    float startX;
    float lastY = 0;
    float lastX = 0;

    LineEntity<DateValueEntity> line1 = (LineEntity<DateValueEntity>) bandData.get(0);
    LineEntity<DateValueEntity> line2 = (LineEntity<DateValueEntity>) bandData.get(1);

    if (line1.isDisplay() && line2.isDisplay()) {
      Paint mPaint = new Paint();
      mPaint.setColor(line1.getLineColor());
      mPaint.setAlpha(70);
      mPaint.setAntiAlias(true);
      List<DateValueEntity> line1Data = line1.getLineData();
      List<DateValueEntity> line2Data = line2.getLineData();
      // set start point’s X
      startX = super.getAxisMarginLeft() + lineLength / 2f;
      Path areaPath = new Path();
      if (line1Data != null && line2Data != null) {
        for (int j = displayFrom; j < displayFrom + displayNumber; j++) {
          float value1 = line1Data.get(j).getValue();
          float value2 = line2Data.get(j).getValue();

          // calculate Y
          float valueY1 =
              (float)
                  ((1f - (value1 - this.getMinValue()) / (this.getMaxValue() - this.getMinValue()))
                      * (super.getHeight() - super.getAxisMarginBottom()));
          float valueY2 =
              (float)
                  ((1f - (value2 - this.getMinValue()) / (this.getMaxValue() - this.getMinValue()))
                      * (super.getHeight() - super.getAxisMarginBottom()));

          // 绘制线条路径
          if (j == displayFrom) {
            areaPath.moveTo(startX, valueY1);
            areaPath.lineTo(startX, valueY2);
            areaPath.moveTo(startX, valueY1);
          } else {
            areaPath.lineTo(startX, valueY1);
            areaPath.lineTo(startX, valueY2);
            areaPath.lineTo(lastX, lastY);

            areaPath.close();
            areaPath.moveTo(startX, valueY1);
          }

          lastX = startX;
          lastY = valueY2;
          startX = startX + 1 + lineLength;
        }
        areaPath.close();
        canvas.drawPath(areaPath, mPaint);
      }
    }
  }
  /**
   * draw lines
   *
   * <p>ラインを書く
   *
   * <p>绘制线条
   *
   * @param canvas
   */
  protected void drawBandBorder(Canvas canvas) {
    // distance between two points
    float lineLength = ((super.getWidth() - super.getAxisMarginLeft()) / displayNumber) - 1;
    // start point‘s X
    float startX;

    // draw lines
    for (int i = 0; i < bandData.size(); i++) {
      LineEntity<DateValueEntity> line = (LineEntity<DateValueEntity>) bandData.get(i);
      if (line.isDisplay()) {
        Paint mPaint = new Paint();
        mPaint.setColor(line.getLineColor());
        mPaint.setAntiAlias(true);
        List<DateValueEntity> lineData = line.getLineData();
        // set start point’s X
        startX = super.getAxisMarginLeft() + lineLength / 2f;
        // start point
        PointF ptFirst = null;
        if (lineData != null) {
          for (int j = displayFrom; j < displayFrom + displayNumber; j++) {
            float value = lineData.get(j).getValue();
            // calculate Y
            float valueY =
                (float)
                    ((1f - (value - this.getMinValue()) / (this.getMaxValue() - this.getMinValue()))
                        * (super.getHeight() - super.getAxisMarginBottom()));

            // if is not last point connect to previous point
            if (j > displayFrom) {
              canvas.drawLine(ptFirst.x, ptFirst.y, startX, valueY, mPaint);
            }
            // reset
            ptFirst = new PointF(startX, valueY);
            startX = startX + 1 + lineLength;
          }
        }
      }
    }
  }
  public void notifyEvent(GridChart chart, int index) {

    MACandleStickChart machart = (MACandleStickChart) chart;

    List<OHLCEntity> OHLCData = machart.getOHLCData();
    List<LineEntity> lineData = machart.getLineData();

    if (null == OHLCData || null == lineData) {
      return;
    }

    LineEntity ma5 = lineData.get(0);
    LineEntity ma10 = lineData.get(1);
    LineEntity ma25 = lineData.get(2);

    if (index >= OHLCData.size() || index < 0) {
      return;
      // index = OHLCData.size() -1;
    }

    OHLCEntity e = OHLCData.get(index);
    OHLCEntity e1;

    if (index >= OHLCData.size()) {
      index = OHLCData.size() - 1;
    }

    if (index > 0) {
      e1 = OHLCData.get(index - 1);
    } else {
      e1 = e;
    }
    double close = e1.getClose();

    if (null != tvO) {
      tvO.setText(String.valueOf((int) (e.getOpen())));
      tvO.setTextColor(getColor(e.getOpen(), close));
    }
    if (null != tvH) {
      tvH.setText(String.valueOf((int) (e.getHigh())));
      tvH.setTextColor(getColor(e.getHigh(), close));
    }
    if (null != tvL) {
      tvL.setText(String.valueOf((int) (e.getLow())));
      tvL.setTextColor(getColor(e.getLow(), close));
    }
    if (null != tvC) {
      tvC.setText(String.valueOf((int) (e.getClose())));
      tvC.setTextColor(getColor(e.getClose(), close));
    }
    if (null != tvD) {
      String date = String.valueOf((int) (e.getDate())).substring(2);
      tvD.setText(
          new StringBuffer()
              .append(date.substring(0, 2))
              .append("/")
              .append(date.substring(2, 4))
              .append("/")
              .append(date.substring(4, 6))
              .toString());
    }

    int change = (int) (e.getClose() - close);
    float rate = ((int) (change / close * 10000)) / 100f;
    String strRate = String.valueOf(rate) + "%";

    if (null != tvValue) {
      tvValue.setText(String.valueOf((int) (e.getClose())));
      tvValue.setTextColor(getColor(e.getClose(), close));
    }
    if (null != tvChange) {
      tvChange.setText(
          new StringBuffer()
              .append(change > 0 ? "+" : "")
              .append(String.valueOf(change))
              .append("(")
              .append(strRate)
              .append(")")
              .toString());
      tvChange.setTextColor(getColor(e.getClose(), close));
    }

    tvMA5.setText(
        ma5.getTitle() + "=" + String.valueOf((int) ma5.getLineData().get(index).floatValue()));
    tvMA5.setTextColor(ma5.getLineColor());
    tvMA10.setText(
        ma10.getTitle() + "=" + String.valueOf((int) ma10.getLineData().get(index).floatValue()));
    tvMA10.setTextColor(ma10.getLineColor());
    tvMA25.setText(
        ma25.getTitle() + "=" + String.valueOf((int) ma25.getLineData().get(index).floatValue()));
    tvMA25.setTextColor(ma25.getLineColor());
  }