draw method

  1. @override
void draw(
  1. Canvas canvas,
  2. double posX,
  3. double posY
)
override

Draws the IMarker on the given position on the screen with the given Canvas object.

@param canvas @param posX @param posY

Implementation

@override
void draw(Canvas canvas, double posX, double posY) {
  TextPainter painter = PainterUtils.create(
      null,
      "${_formatter.getFormattedValue1(_entry.x)},${_formatter.getFormattedValue1(_entry.y)}",
      _textColor,
      _fontSize);
  Paint paint = Paint()
    ..color = _backColor
    ..strokeWidth = 2
    ..isAntiAlias = true
    ..style = PaintingStyle.fill;

  MPPointF offset = getOffsetForDrawingAtPoint(posX, posY);

  canvas.save();
  // translate to the correct position and draw
//    canvas.translate(posX + offset.x, posY + offset.y);
  painter.layout();
  Offset pos = calculatePos(
      posX + offset.x, posY + offset.y, painter.width, painter.height);
  canvas.drawRRect(
      RRect.fromLTRBR(pos.dx - 5, pos.dy - 5, pos.dx + painter.width + 5,
          pos.dy + painter.height + 5, const Radius.circular(5)),
      paint);
  painter.paint(canvas, pos);
  canvas.restore();
}