adjustLabels method

Quality? adjustLabels(
  1. Point<num> mouse,
  2. bool click
)

Implementation

Quality? adjustLabels(Point mouse, bool click) {
  if (!click) return null;
  if (_labels == null) return null;

  //print('--- adjustLabels ---');

  var point = _getMousePointInCanvas(mouse);

  var labels = _labels.value ?? [];

  var target = nearestRectangle(labels, point) as Label?;

  if (target == null) {
    //rectangles.add(point);
    hideHint();
  } else {
    if (target.containsPoint(point)) {
      if (click) {
        labels.remove(target);
        hideHint();
      } else {
        showHintAtRectangle(
            target.label, _getElementRectangleInCanvas(target));
      }
    } else {
      hideHint();
    }
  }

  _labels.value = labels;

  return Quality.high;
}