Skip to Main Content Skip to Search
Product Documentation

Defining Component Tasks

About Component Customization

Building a component creates MATLAB files in your MATLAB workspace. You can specify tasks you want your component to perform by editing these MATLAB files.

For more information, see the following sections:

Required Customization: Specifying Format and Content of Report Output

After you build the component, specify the format and content of your report output by editing the execute.m file.

The execute command has the following syntax:

out = execute(thisComp, parentDoc)

Where:

One or more default lines of code within the execute.m file show each property for the component. Here is an example of a component property line within an execute.m file:

pstring = thisComp.NewStringProperty;  % New string property;

The following sections describe how to edit execute.m to create additional report elements.

Creating Tables

To create a table, replace the Source property value with the name of a cell array or structure:

out = execute(rptgen.cfr_table(...
'Source', tableSrc,...
'numHeaderRows',1,...
'TableTitle','Example Title'),...
 parentDoc);

For more information, enter help(rptgen.cfr_table) at the MATLAB command line.

Creating Lists

To create a list, replace the Source property value with the name of a cell vector:

out = execute(rptgen.cfr_list(...
'Source', listSrc,...
'ListStyle','orderedlist',...
'ListTitle','Example List'),...
 parentDoc);

For more information, enter help(rptgen.cfr_list) at the MATLAB command line.

Creating Text

To create text, replace the ParaText property value with a text string:

out = execute(rptgen.cfr_paragraph(...
'ParaText', paraSrc,...
 parentDoc);

For more information, enter help(rptgen.cfr_paragraph) at the command line.

Creating Figures

To create figures, specify a figure in the FigureHandle property value.

figSrc = gcf;
out = execute(rptgen_hg.chg_fig_snap(...
'FigureHandle', figSrc,...
'Title', '',...
'isResizeFigure', 'manual',...
'PrintSize', [6 4],...
'PrintUnits', 'inches'),...
 parentDoc);

For more information, enter help(rptgen_hg.chg_fig_snap) at the MATLAB command line.

Running Child Components

The following code runs child components. The first line calls execute.m for child components. The second line appends the results of running the child components to the report:

childOut = thisComp.runChildren(parentDoc);
out = parentDoc.createDocumentFragment(out, childOut);

Changing a Component's Outline String in the Report Explorer Hierarchy

To change the string used to describe the component in the Report Explorer hierarchy, edit the getOutlineString MATLAB file. By default, getoutlinestring returns the display name of the component. The getOutlineString command has the following syntax:

olstring = getOutlineString(thisComp) 

Where:

Customize the string to include additional information about the component, such as information about its properties. In the following example, the truncatestring function converts input data into a single-line string. If the data is empty, the second argument is the return value, The third argument is the maximum allowed size of the resulting string.

cInfo = '';
pstring = rptgen.truncateString(thisComp.string,'<empty>',16);

Use a dash (-) as a separator between the name and additional component information, as follows:

if ~isempty(cInfo)
   olstring = [olstring, '-', cInfo];
end

Modifying the Appearance of Properties Dialog Boxes

You can edit the getdialog boxeschema file to control most aspects of dialog box layout, including:

The syntax of the getdialog boxeschema command is:

dlgstruct = getdialog boxeschema(thisComp, name)

Where:

Specifying Additional Component Properties

You can edit additional MATLAB files to customize your component further. To access these files, right-click the component in the Outline pane on the left in the Report Explorer and select Edit files from its context menu.

For more information, see the following sections:

Specifying Whether Components Can Have Children Components

To specify whether a component can have children, edit getParentable.m. This command returns the value true or false. For example, if you no longer want your component to have child components, modify the value within the code as follows:

p = false;

Modifying a Component's Description

The description n getDescription.m is the same value as the Description field in the Report Explorer. The following example shows how to edit the compDesc string in this file to change a component's description to A demonstration component:

compDesc = 'A demonstration component';

Changing a Component's Display Name

The display name in getName.m is the same value as the Display name field in the Report Explorer. The following example shows how to edit the compName string in this file to change a component's display name to Demo Component:

compName = 'Demo Component';

Changing a Component's Category Name

The category name in getType.m is the same value as the Category name field in the Report Explorer. The following example shows how to edit the compCategory string in this file to change a component's category name to Custom Components:

compCategory = 'Custom Components';

Registering Components

You can register components in the Report Explorer using rptcomps2.xml. This file also helps build the list of available components.

The content of this file must be consistent with the values in the getName.m and getType.m files. If you have changed values in either of these files, you must also change their values in rptcomps2.xml. You must restart the MATLAB software session for the Report Explorer to display new information.

Displaying Component Help in the MATLAB Help Browser

The viewHelp.m file displays a help file for the component within the MATLAB Help browser. To display the help file, highlight the name of the component in the Report Explorer and click Help.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS