MATLAB Object-Oriented Programming

(Joyce) #1

Choose a Technique for Display Customization


In this section...
“Ways to Implement a Custom Display” on page 18-19
“Sample Approaches Using the Interface” on page 18-20

Ways to Implement a Custom Display


The way you customize object display using the matlab.mixin.CustomDisplay class
depends on:


  • What parts of the display you want to customize

  • What object states you want to use the custom display


If you are making small changes to the default layout, then override the relevant part
builder methods (“Part Builder Methods” on page 18-4). For example, suppose you want
to:


  • Change the order or value of properties, display a subset of properties, or create
    property groups

  • Modify the header text

  • Add a footer


If you are defining a nonstandard display for a particular object state (scalar, for
example), then the best approach is to override the appropriate state handler method
(“State Handler Methods” on page 18-5).

In some cases, a combination of method overrides might be the best approach. For
example, your implementation of displayScalarObject might


  • Use some of the utility methods (“Utility Methods” on page 18-5) to build your own
    display strings using parts from the default display

  • Call a part builder method to get the default text for that particular part of the display

  • Implement a completely different display for scalar objects.


Once you override any CustomDisplay method, MATLAB calls your override in all cases
where the superclass method would have been called. For example, if you override the

Choose a Technique for Display Customization
Free download pdf