classdef (HandleCompatible, Abstract) CustomCompactDisplayProvider < matlab.display.internal.CompactDisplayProvider
    % CustomCompactDisplayProvider Customize compact display of an object
    %   This class provides an interface for customizing object display under 
    %   limited space and/or shape constraints, such as when held within a 
    %   struct, cell array, or another container object.
    %
    %   Derive your class from CustomCompactDisplayProvider to add a custom 
    %   compact display for your class. 
    %
    %   "Compact display" refers to the way objects are displayed under space 
    %   constraints, for example when an object is displayed within a MATLAB 
    %   container such as a struct or table. When the object is displayed in 
    %   one of these situations, MATLAB calls the methods of this mixin 
    %   class to determine how to display the object.
    %
    %   Override methods as needed to provide a customized compact display 
    %   representation. Default implementations are provided that use the  
    %   default compact display format, which is dimensions and class name. 
    %
    %   Compact display can be categorized based on the shape constraints
    %   that are imposed on the object to be displayed. Cell arrays and 
    %   structs require that the object be displayed on a single line. MATLAB
    %   tables require the object be displayed in a columnar format. The 
    %   following shape constraints (or layouts) are supported:
    %     - single line layout: The object must be displayed within a single 
    %                            line. This is the case for struct, cell and
    %                            object display.
    %     - columnar layout: The object must be displayed across multiple rows, 
    %                            based on the number of rows in the table.
    %                            The width is constrained by the width 
    %                            allocated to the table variable.
    %
    %   CustomCompactDisplayProvider methods:
    %       compactRepresentationForSingleLine - Single-line display
    %                                            representation of an object
    %       compactRepresentationForColumn     - Columnar display
    %                                            representation of an object
    %
    %   These methods must return a matlab.display.CompactDisplayRepresentation 
    %   object specifying the compact representation that the class supports.
    %   Clients of the CustomCompactDisplayProvider interface use the 
    %   information returned by these methods to determine the final display 
    %   format.
    % 
    %   See also matlab.display.CompactDisplayRepresentation,
    %   matlab.display.DisplayConfiguration
    %
    
    %   Copyright 2020-2021 The MathWorks, Inc.   
    
    methods  
        function rep = compactRepresentationForSingleLine(obj, displayConfiguration, width)
        % compactRepresentationForSingleLine Single-line display representation 
        % of an object
        %
        %   rep = compactRepresentationForSingleLine(obj, displayConfiguration, 
        %   width) returns a scalar matlab.display.CompactDisplayRepresentation
        %   object describing the compact display representation for input
        %   object obj. This method is called by a consumer (e.g. struct, 
        %   table) to obtain the compact display representation for MATLAB 
        %   object obj, when the shape constraints require that a single line 
        %   be used. displayConfiguration is a matlab.display.DisplayConfiguration 
        %   object that describes the current display environment, such as 
        %   the current numeric display format and whether hyperlinks are 
        %   enabled. Input argument width is the available width to display 
        %   the object.
        % 
        %   The default single-line display representation for an object is  
        %   dimensions plus class name.  Override 
        %   compactRepresentationForSingleLine to provide a custom single-line 
        %   compact display. This function is primarily used when your object 
        %   is displayed within a MATLAB struct, cell array, or another object.
        %
        %   See also
        %   matlab.mixin.CustomCompactDisplayProvider/compactRepresentationForColumn
        arguments
            obj matlab.mixin.CustomCompactDisplayProvider
            displayConfiguration (1,1) matlab.display.DisplayConfiguration
            width (1,1) double
        end
            import matlab.display.DimensionsAndClassNameRepresentation;

            rep = DimensionsAndClassNameRepresentation(obj, displayConfiguration, 'UseSimpleName', true);
        end
        
        function rep = compactRepresentationForColumn(obj, displayConfiguration, width)
        % compactRepresentationForColumn Columnar display representation of 
        % an object
        %
        %   rep = compactRepresentationForColumn(obj, displayConfiguration, 
        %   width) returns a scalar matlab.display.CompactDisplayRepresentation 
        %   object describing the compact display representation for the input 
        %   object obj. This method is called by table to obtain the compact 
        %   display representation for MATLAB object obj, when the shape 
        %   constraints require that a column be used. displayConfiguration 
        %   is a matlab.display.DisplayConfiguration object that describes 
        %   the current display environment, such as the current numeric display 
        %   format and whether hyperlinks are enabled. Input argument width 
        %   is the available width to display the object.
        % 
        %   The default columnar display representation for an object is  
        %   dimensions plus class name.  Override 
        %   compactRepresentationForColumn to provide a custom columnar 
        %   compact display.  This function is primarily used when your 
        %   object is displayed within a MATLAB table.
        %
        %   See also
        %   matlab.mixin.CustomCompactDisplayProvider/compactRepresentationForSingleLine
        arguments
            obj matlab.mixin.CustomCompactDisplayProvider
            displayConfiguration (1,1) matlab.display.DisplayConfiguration
            width (1,1) double
        end
            import matlab.display.DimensionsAndClassNameRepresentation;

            rep = DimensionsAndClassNameRepresentation(obj, displayConfiguration, 'UseSimpleName', true);
        end
    end
end