drawText method

void drawText(
  1. Canvas canvas
)

Implementation

void drawText(Canvas canvas) {
  double value;
  String str;
  for (int j = 0; j < mLineCount; j++) {
    value = mMaxVolume! - mMultiple! * j;
    str = value.toStringAsFixed(fixedLength!);
    var tp = getTextPainter(str);
    tp.layout();
    tp.paint(
        canvas,
        Offset(
            mWidth - tp.width, mDrawHeight / mLineCount * j + tp.height / 2));
  }

  var startText = mBuyData!.first.price.toStringAsFixed(fixedLength!);
  TextPainter startTP = getTextPainter(startText);
  startTP.layout();
  startTP.paint(canvas, Offset(0, getBottomTextY(startTP.height)));

  double centerPrice = (mBuyData!.last.price + mSellData!.first.price) / 2;

  var center = centerPrice.toStringAsFixed(fixedLength!);
  TextPainter centerTP = getTextPainter(center);
  centerTP.layout();
  centerTP.paint(
      canvas,
      Offset(
          mDrawWidth - centerTP.width / 2, getBottomTextY(centerTP.height)));

  var endText = mSellData!.last.price.toStringAsFixed(fixedLength!);
  TextPainter endTP = getTextPainter(endText);
  endTP.layout();
  endTP.paint(
      canvas, Offset(mWidth - endTP.width, getBottomTextY(endTP.height)));

  var leftHalfText = ((mBuyData!.first.price + centerPrice) / 2)
      .toStringAsFixed(fixedLength!);
  TextPainter leftHalfTP = getTextPainter(leftHalfText);
  leftHalfTP.layout();
  leftHalfTP.paint(
      canvas,
      Offset((mDrawWidth - leftHalfTP.width) / 2,
          getBottomTextY(leftHalfTP.height)));

  var rightHalfText = ((mSellData!.last.price + centerPrice) / 2)
      .toStringAsFixed(fixedLength!);
  TextPainter rightHalfTP = getTextPainter(rightHalfText);
  rightHalfTP.layout();
  rightHalfTP.paint(
      canvas,
      Offset((mDrawWidth + mWidth - rightHalfTP.width) / 2,
          getBottomTextY(rightHalfTP.height)));

  if (isLongPress == true) {
    if (pressOffset!.dx <= mDrawWidth) {
      int index = _indexOfTranslateX(
          pressOffset!.dx, 0, mBuyData!.length - 1, getBuyX);
      drawSelectView(canvas, index, true);
    } else {
      int index = _indexOfTranslateX(
          pressOffset!.dx, 0, mSellData!.length - 1, getSellX);
      drawSelectView(canvas, index, false);
    }
  }
}