ModelAdvisor.Text class

Package: ModelAdvisor
Superclasses:

Create Model Advisor text output

Description

Instances of ModelAdvisor.Text class create formatted text for the Model Advisor output.

Construction

ModelAdvisor.TextCreate Model Advisor text output

Methods

setBoldSpecify bold text
setColorSpecify text color
setHyperlinkSpecify hyperlinked text
setItalicItalicize text
setRetainSpaceReturnRetain spacing and returns in text
setSubscriptSpecify subscripted text
setSuperscriptSpecify superscripted text
setUnderlinedUnderline text

Copy Semantics

Handle. To learn how this affects your use of the class, see Copying Objects (MATLAB) in the MATLAB® Programming Fundamentals documentation.

Example

Text is the simplest form of output. You can format text in many different ways. To change default text formatting, use the ModelAdvisor.Text constructor.

The default text formatting is:

  • Empty

  • Default color (black)

  • Unformatted (not bold, italicized, underlined, linked, subscripted, or superscripted)

When you want one type of formatting for all text, use this syntax:

ModelAdvisor.Text(content, {attributes})
When you want multiple types of formatting, you must build the text.
t1 = ModelAdvisor.Text('It is ');
t2 = ModelAdvisor.Text('recommended', {'italic'});
t3 = ModelAdvisor.Text(' to use same font for ');
t4 = ModelAdvisor.Text('blocks', {'bold'});
t5 = ModelAdvisor.Text(' for a uniform appearance in the model.');

result = ([t1, t2, t3, t4, t5]); 
Add ASCII and Extended ASCII characters using the MATLAB char command. For more information, see the ModelAdvisor.Text class page.

Here is an example of a simple check callback function using the Model Advisor Formatting APIs:

function result = SampleStyleOneCallback(system)
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
if strcmp(get_param(bdroot(system), 'ScreenColor'),'white')
   result = ModelAdvisor.Text('Passed',{'pass'});
   mdladvObj.setCheckResultStatus(true); 
else
   msg1 = ModelAdvisor.Text(...
       ['It is recommended to select a Simulink window screen color'...
       ' of white for a readable and printable model. Click ']);
   msg2 = ModelAdvisor.Text('here');
   msg2.setHyperlink('matlab: set_param(bdroot,''ScreenColor'',''white'')');
   msg3 = ModelAdvisor.Text(' to change screen color to white.');
   result = [msg1, msg2, msg3];
   mdladvObj.setCheckResultStatus(false); 
end