function isValid = isValidROI(this, varargin)
% This internal helper function may change in a future release.

% IsValidROI checks if the height or width of the ROI is less than than delta (aprox. 0.05% of the default axes size) ,
% then select nothing and hide the ROI tool.

%  Copyright 2019 The MathWorks, Inc.

isValid = true;
if any(isempty(varargin))
    isValid = false;
    return
end
figDragEnd = varargin{1};
figDragStart = varargin{2};
maxX = varargin{3};
minX = varargin{4};
maxY = varargin{5};
minY = varargin{6};

if abs(figDragEnd(1)-figDragStart(1))<0.005*(maxX-minX) || ...
        abs(figDragEnd(2)-figDragStart(2))<0.005*(maxY-minY)
    if ~isempty(this.Graphics) && isvalid(this.Graphics) && strcmp(this.Graphics.Visible,'on')
        this.Graphics.Visible = 'off';
    end
    isValid = false;
end
end