Main Content

Customize Display for Heterogeneous Arrays

You can call only sealed methods on nonscalar heterogeneous arrays. If you want to customize classes that are part of a heterogeneous hierarchy, you must override and declare as Sealed all the methods that are part of the CustomDisplay interface.

The versions of disp and display that are inherited from matlab.mixin.CustomDisplay are sealed. However, these methods call all of the part builder (Part Builder Methods) and state handler methods (State Handler Methods).

To use the CustomDisplay interface, the root class of the heterogeneous hierarchy can declare these methods as Sealed and Access = protected.

If you do not need to override a particular method, then call the superclass method, as shown in the following code.

For example, the following code shows modifications to the getPropertyGroups and displayScalarObject methods, while using the superclass implementation of all others.

classdef RootClass < matlab.mixin.CustomDisplay & matlab.mixin.Heterogeneous
   %...
   methods (Sealed, Access = protected)
      function header = getHeader(obj)
         header = getHeader@matlab.mixin.CustomDisplay(obj);
      end
 
      function groups = getPropertyGroups(obj)
         % Override of this method
         % ...
      end
 
      function footer = getFooter(obj)
         footer = getFooter@matlab.mixin.CustomDisplay(obj);
      end
 
      function displayNonScalarObject(obj)
         displayNonScalarObject@matlab.mixin.CustomDisplay(obj);
      end
 
      function displayScalarObject(obj)
         % Override of this method
         % ...
      end

      function displayEmptyObject(obj)
         displayEmptyObject@matlab.mixin.CustomDisplay(obj);
      end

      function displayScalarHandleToDeletedObject(obj)
         displayScalarHandleToDeletedObject@matlab.mixin.CustomDisplay(obj);
      end
   end
end

You do not need to declare the inherited static methods as Sealed.

Related Topics