matlab.mixin.CustomDisplay.getPropertyGroups - Construct array of customized property groups - MATLAB (original) (raw)

Main Content

Class: matlab.mixin.CustomDisplay
Namespace: matlab.mixin

Construct array of customized property groups

Syntax

groups = getPropertyGroups(obj)

Description

[groups](#mw%5Ff6fd267c-a595-4e1e-8ae8-e83db1fb1490) = getPropertyGroups([obj](#mw%5Fb9cce6a8-8db2-41a6-80b3-b057925f9353)) returns a 1-by-N array of matlab.mixin.util.PropertyGroup objects, where N is the number of groups. MATLAB® displays property groups separated by blank spaces. Each default display state handler method calls this method once. Override this method to construct one or more customized groups of properties to display.

The default implementation returns the properties in one group. These properties must have public GetAccess and must not be defined as Hidden. If the object is scalar, MATLAB includes dynamic properties.

Each group object array has these fields:

Use the struct if the object is scalar and you want to assign custom property values. Otherwise, use a cell array of property names. If the object is scalar, MATLAB adds the property values retrieved from the object.

Input Arguments

expand all

Object array to apply customized property group format to. The class ofobj must be derived frommatlab.mixin.CustomDisplay.

Output Arguments

expand all

Array of 1-by-N matlab.mixin.util.PropertyGroup objects, where N is the number of groups.

Examples

expand all

Create two property groups for class display.

The EmployeeInfo class has five properties describing an employee. Define a getPropertyGroups method that, for scalar objects, defines two PropertyGroup objects. The method returns two property groups with the titles Employee Bio and Contact Info.

classdef EmployeeInfo < matlab.mixin.CustomDisplay properties Name = "Alex Doe" Department = "Development" JobTitle = "Engineer" Email = "alexdoe@notacompany.org" Phone = "(555) 555-555" end

methods (Access = protected)
    function propgrp = getPropertyGroups(obj)
        if ~isscalar(obj)
            propgrp = getPropertyGroups@matlab.mixin.CustomDisplay(obj);
        else
            bioList = ["Name","Department","JobTitle"];
            bioTitle = "Employee Bio";
            bioGrp = matlab.mixin.util.PropertyGroup(bioList,bioTitle);
            contactList = ["Email","Phone"];
            contactTitle = "Contact Info";
            contactGrp = matlab.mixin.util.PropertyGroup(contactList,contactTitle);
            propgrp = [bioGrp,contactGrp];
        end
    end
end

end

Create a scalar instance to see how the properties are displayed.

a =

EmployeeInfo with properties:

Employee Bio Name: "Alex Doe" Department: "Development" JobTitle: "Engineer"

Contact Info Email: "alexdoe@notacompany.org" Phone: "(555) 555-555"

Version History

Introduced in R2013b