MATLAB Object-Oriented Programming

(Joyce) #1

CustomDisplay Class


The matlab.mixin.CustomDisplay class provides an interface that you can use to
customize object display for your class. To use this interface, derive your class from
CustomDisplay:


classdef MyClass < matlab.mixin.CustomDisplay


The CustomDisplay class is HandleCompatible, so you can use it in combination with
both value and handle superclasses.


NoteYou cannot use matlab.mixin.CustomDisplay to derive a custom display for
enumeration classes.


disp, display, and details


The CustomDisplay interface does not allow you to override disp, display, and
details. Instead, override any combination of the customization methods defined for
this purpose.


Methods for Customizing Object Display


There are two groups of methods that you use to customize object display for your class:



  • Part builder methods build the strings used for the standard display. Override any of
    these methods to change the respective parts of the display.

  • State handler methods are called for objects in specific states, like scalar, nonscalar,
    and so on. Override any of these methods to handle objects in a specific state.


All of these methods have protected access and must be defined as protected in your
subclass of CustomDisplay (that is, Access = protected).


Parts of an Object Display


There are three parts that makeup the standard object display — header, property list,
and footer


For example, here is the standard object display for a containers.Map object:


Custom Display Interface
Free download pdf