classdef (Abstract,Hidden) AbstractLogicAnalyzerDisplay
    % AbstractLogicAnalyzerDisplay Abstract Display object for
    %   dsp.LogicAnalyzer

    %   Copyright 2012-2014 The MathWorks, Inc.

    properties
        %Name Label for display in Logic Analyzer
        %   The default value for this property is '' to use the input name.
        Name = '';
        
        %Height Display height
        %   Specify Height to be a non-negative integer. When the value
        %   specified is 0, the Display height is the default
        %   height chosen in the Logic Analyzer.
        %   The default value for this property is 0.
        Height = 0;
    end   
    
    properties (Access = protected)
        %Tag Tag for Display
        %   The tag provided allows the user to identify the display easily
        %   even if it moves around in the order/index.
        Tag;
    end
    
    methods
        function obj = set.Name(obj, value)
            % Name can be empty or a character string; must be scalar
            % check for character string
            validateattributes(value, {'char', 'string'}, {}, 'LogicAnalyzer', 'Name');
            obj.Name = char(value);
        end % set.Name

        function obj = set.Height(obj, value)
            % Height should be a nonnegative integer
            validateattributes(value, {'numeric'}, ...
                {'nonnegative', 'integer', 'scalar'}, 'LogicAnalyzer', 'Height');
            if value < 8 && value ~= 0 || value > 200
                error(message('Spcuilib:logicanalyzer:invalidDisplayChannelHeight'));
            end
            
            obj.Height = value;
        end % set.Height
    end % methods
    
    methods(Hidden)
        function gs = toGraphicalSettings(this, varargin)
            gs = struct;
            if nargin < 2 || any(strcmp(varargin, 'Name'))
                gs.name   = this.Name;
            end
            if nargin < 2 || any(strcmp(varargin, 'Height'))
                gs.height = this.Height;
            end
        end
        
        function tag = getTag(obj)
            tag = obj.Tag;
        end
        
        function obj = setTag(obj, tag)
            obj.Tag = tag;
        end
        
        function tags = getAllTags(obj)
            tags = {obj.Tag};
        end
        
        function found = findByTag(obj, tag)
            if strcmpi(obj.getTag, tag)
                found = obj;
            else
                found = [];
            end
        end
    end % Hidden methods
end % classdef

