MATLAB Object-Oriented Programming

(Joyce) #1

end
end


getPropertyGroups Override


MATLAB calls getPropertyGroups to get the PropertyGroup objects, which control
how properties are displayed. This method override defines two different property lists
depending on the object’s state:



  • For nonscalar inputs, including empty arrays and arrays containing handles to deleted
    objects, create a property list as a cell array to reorder properties.


By default, MATLAB does not display property values for nonscalar inputs.


  • For scalar inputs, create two property groups with titles. The scalar code branch lists
    properties in a different order than the nonscalar case and includes Salary and
    Password properties. MATLAB automatically assigns property values.

  • Scalar handles to deleted objects do not result in a call to getPropertyGroups.


Both branches return a matlab.mixin.util.PropertyGroup object, which determines
how to displays the object properties.


Here is the EmployeeInfo override of the getPropertyGroups method. The protected
access is inherited from the superclass.


methods (Access = protected)
function propgrp = getPropertyGroups(obj)
if ~isscalar(obj)
propList = {'Department','Name','JobTitle'};
propgrp = matlab.mixin.util.PropertyGroup(propList);
else
gTitle1 = 'Public Info';
gTitle2 = 'Personal Info';
propList1 = {'Name','JobTitle'};
propList2 = {'Salary','Password'};
propgrp(1) = matlab.mixin.util.PropertyGroup(propList1,gTitle1);
propgrp(2) = matlab.mixin.util.PropertyGroup(propList2,gTitle2);
end
end
end


getFooter Override


MATLAB calls getFooter to get the footer text. The EmployeeInfo getFooter method
defines a footer for the display, which is included only when the input is a valid scalar
object. In all other cases, getFooter returns an empty char vector.


Customize Header, Property List, and Footer
Free download pdf