nelson.mixin.CustomDisplay
Customize how an object is displayed.
📝Syntax
classdef MyClass < nelson.mixin.CustomDisplay
📥Input Arguments
Parameter Description
obj an object of a class deriving from nelson.mixin.CustomDisplay.
📤Output Arguments
Parameter Description
txt custom display text produced by the derived class methods.
📄Description

Derive from nelson.mixin.CustomDisplay to customize how instances of a class are displayed. A subclass may override any of these protected methods and let the default composition render the rest:

getHeader(obj) - the header text (a char vector or a string scalar). Default: the class name followed by with properties:.

getFooter(obj) - the footer text (char or string). Default: empty.

getPropertyGroups(obj) - an array of nelson.mixin.util.PropertyGroup objects describing which properties are shown and how they are grouped. Default: one group with all public properties.

displayScalarObject(obj), displayNonScalarObject(obj) and displayEmptyObject(obj) - take full control of the display of a scalar object, an object array, or an empty object array respectively.

When none of the display methods is overridden, the object is shown as getHeader, then the property groups, then getFooter.

💡Examples
Override only the header and footer.
classdef Point < nelson.mixin.CustomDisplay
  properties
    X = 0
    Y = 0
  end
  methods (Access = protected)
    function h = getHeader(obj)
      h = "A 2-D point:";
    end
    function f = getFooter(obj)
      f = '(cartesian)';
    end
  end
end
🔗See Also
nelson.mixin.util.PropertyGroupclassdef
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub