matlab.mixin.util.PropertyGroup - Custom property list for object display - MATLAB (original) (raw)
Main Content
Namespace: matlab.mixin.util
Custom property list for object display
Description
Use the PropertyGroup
class to create custom property display lists for classes derived from matlab.mixin.CustomDisplay
. You can change the order of properties displayed, specify which properties to display, and add a title to the list.
Creation
Description
`P` = matlab.mixin.util.PropertyGroup(`propertyList`)
constructs a property group object with its PropertyList property set to propertyList
.
`P` = matlab.mixin.util.PropertyGroup(`propertyList`,`title`)
constructs a property group object with its Title property set to title
. The title is displayed above the list of properties.
Properties
The number of properties contained in the PropertyList
property, specified as a positive integer.
Attributes:
Dependent | true |
---|---|
Transient | true |
GetAccess | public |
SetAccess | private |
GetObservable | true |
List of properties to include in the group, specified as a cell array of character vectors, a string array, or a struct that includes the properties as field names.
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
GetObservable | true |
SetObservable | true |
Title for the custom property group. If not specified, the property group is displayed without a title. You can use a character vector or string to set this property, but the stored value of the property is always a character vector.
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
GetObservable | true |
SetObservable | true |
Examples
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