docs: public void addAndSimplify(double x, double y) {
      // simplify curve when possible:
      final int len = data.size();
      if (len >= 4) {
        // Look at the previous 2 points
        final double l1x = data.get(len - 4);
        final double l1y = data.get(len - 3);
        final double l2x = data.get(len - 2);
        final double l2y = data.get(len - 1);
        // Differences:
        final double ldx = l2x - l1x;
        final double ldy = l2y - l1y;
        final double cdx = x - l2x;
        final double cdy = y - l2y;
        // X simplification
        if ((ldx == 0) && (cdx == 0)) {
          data.remove(len - 2, 2);
        }
        // horizontal simplification
        else if ((ldy == 0) && (cdy == 0)) {
          data.remove(len - 2, 2);
        }
        // diagonal simplification
        else if (ldy > 0 && cdy > 0) {
          if (Math.abs((ldx / ldy) - (cdx / cdy)) < THRESHOLD) {
            data.remove(len - 2, 2);
          }
        }
      }
      add(x, y);
    }