@Override
    public <T> T processLine2D(int x0, int y0, int x1, int y1, PointHandler2D<T> handler) {
        int x = x0;
        int y = y0;

        T result = handler.handlePoint(x, y);
        if (result != null) return result;

        final int dx = x1 - x0;
        final int dy = y1 - y0;

        final int sign_dx = sign(dx);
        final int sign_dy = sign(dy);

        final int abs_dx = Math.abs(dx);
        final int abs_dy = Math.abs(dy);

        final int px, py, d0, d1;
        if (abs_dx > abs_dy) {
            px = sign_dx;
            py = 0;
            d0 = abs_dx;
            d1 = abs_dy;
        }
        else {
            px = 0;
            py = sign_dy;
            d0 = abs_dy;
            d1 = abs_dx;
        }

        int delta = d0/2;

        for (int p = 0; p < d0; p++) {
            delta -= d1;
            if (delta < 0) {
                delta += d0;
                x += sign_dx;
                y += sign_dy;
            }
            else {
                x += px;
                y += py;
            }

            result = handler.handlePoint(x, y);
            if (result != null) return result;
        }

        return null;
    }