MATLAB Object-Oriented Programming

(Joyce) #1
getHeader method, your override must handle all cases where a state handler method
calls getHeader. (See “Methods Called for a Given Object State” on page 18-8)

Sample Approaches Using the Interface


Here are some simple cases that show what methods to use for the particular customized
display.

Change the Display of Scalar Objects

Use a nonstandard layout for scalar object display that is fully defined in the
displayScalarObject method:

classdef MyClass < matlab.mixin.CustomDisplay
...
methods (Access = protected)
function displayScalarObject(obj)
% Implement the custom display for scalar obj
end
end
end

Custom Property List with Standard Layout

Use standard display layout, but create a custom property list for scalar and nonscalar
display:

classdef MyClass < matlab.mixin.CustomDisplay
...
methods(Access = protected)
function groups = getPropertyGroups(obj)
% Return PropertyGroup instances
end
end
end

Custom Property List for Scalar Only

Use standard display layout, but create a custom property list for scalar only. Call the
superclass getPropertyGroups for the nonscalar case.
classdef MyClass < matlab.mixin.CustomDisplay
properties
Prop1

18 Customizing Object Display

Free download pdf