matlab.diagram.ClassViewer class
Package: matlab.diagram
Description
The matlab.diagram.ClassViewer
class provides command line access to the
Class Diagram Viewer app. You can use the
properties and methods of this class to populate a class diagram without using the graphical
interface.
The matlab.diagram.ClassViewer
class is a handle
class.
Creation
Description
matlab.diagram.ClassViewer
opens a Class Diagram Viewer instance
with no classes loaded.
matlab.diagram.ClassViewer(
adds
the classes specified to both the Class Browser pane and the canvas.
Use Name,Value
)Name,Value
arguments to determine what content to add.
viewer = matlab.diagram.ClassViewer(___)
returns a
handle for the Class Viewer instance. You can use any of the previous input
syntaxes.
Input Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: matlab.diagram.ClassViewer('Classes','matlab.net.http.RequestMessage')
Classes
— Classes to add to viewer
character vector | string | string array | class instance
Classes to add to the Class Browser and viewer, specified as a character vector, string, or a vector of strings. You can also use class instances.
Example: matlab.diagram.ClassViewer('Classes','matlab.net.http.ResponseMessage')
Example: respMsg = matlab.net.http.RequestMessage;
matlab.diagram.ClassViewer('Classes',respMsg)
Folders
— Class folders to add to viewer
character vector | string | string array
Class folders to add to the Class Browser and viewer, specified as a character vector, string, or a vector of strings.
IncludeSubfolders
— Include classes from subfolders
true
or 1
(default) | false
or 0
Determines whether to include classes from subfolders, specified as a numeric or
logical 1
(true
) or 0
(false
). A value of 1
includes classes in
subfolders of the Folders
argument, and 0
omits them.
Packages
— Packages to add to viewer
character vector | string | string array
Packages to add to the Class Browser and viewer, specified as a character vector, string, or a vector of strings.
IncludeSubpackages
— Include classes from subpackages
true
or 1
(default) | false
or 0
Determines whether to include classes from subpackages, specified as a numeric
or logical 1
(true
) or 0
(false
). A value of 1
includes the classes
in subpackages of the Packages
argument, and
0
omits them.
Load
— Path of class diagram to load
character vector | string | string array
Path of class diagram to load, specified as a character vector, string, or a vector of strings.
Visible
— Display Class Viewer instance
true
or 1
(default) | false
or 0
Determines whether the Class Viewer window is visible after creation, specified
as a numeric or logical 0
(false
) or
1
(true
). A value of 1
makes the window visible, and 0
hides it.
Properties
ActiveFile
— Last file loaded or saved
string
The last file loaded or saved to the Class Viewer instance, specified as a string.
This property can only be set by the load
and save
methods.
Attributes:
Dependent | true |
ClassesInDiagram
— List of classes currently in diagram
string array
The list of classes currently displayed in the diagram, specified as a string array. The list includes classes displayed in the canvas, but it does not include classes that are only listed in the Class Browser.
Attributes:
Dependent | true |
ShowMixins
— Display mixin classes
false
or 0
(default) | true
or 1
Determines whether the Class Viewer displays mixin classes, specified as a numeric
or logical 0
(false
) or 1
(true
). A value of 0
excludes mixins and the
handle class for a simpler diagram. A value of 1
enables adding
mixins when adding superclasses, but it does not do so automatically.
ShowPackageNames
— Display package names
true
or 1
(default) | false
or 0
Determines whether the Class Viewer displays the package names on the class cards,
specified as a numeric or logical 1
(true
) or
0
(false
). A value of 1
displays the package names, and 0
hides them.
Visible
— Display Class Viewer instance
true
or 1
(default) | false
or 0
Determines whether the Class Viewer window is currently displayed, specified as a
numeric or logical 0
(false
) or
1
(true
). A value of 1
makes
the window visible, and 0
hides it.
Attributes:
Transient | true |
Methods
Public Methods
addClass |
Add classes to the Class Browser and canvas. Input Arguments
|
removeClass |
Remove classes from the canvas. Classes are not removed from the Class Browser. Input Arguments
|
removeAllClasses |
Remove all classes from the canvas. Classes are not removed from the Class Browser. Input Arguments
|
importClassesFrom |
Add classes to the Class Browser and canvas. Input Arguments
Name-Value Arguments
|
expandClass |
Expand all sections of a class card on the canvas. Input Arguments
|
expandAll |
Expand or collapse all sections of the class cards on the canvas. Input Arguments
|
expandSection |
Expand or collapse a specified section of a class card on the canvas. Input Arguments
Expanding one section in a class card that is currently collapsed expands all sections of that card. |
importCurrentProject |
Import classes from the current project.
|
export |
Export a class diagram as an image. Input Arguments
Name-Value Arguments
|
load |
Load a diagram saved as an MLDATX file. The loaded diagram replaces any content currently in the Class Viewer instance. Input Arguments
|
save |
Save a diagram as an MLDATX file. Input Arguments
|
getVisibleViewers |
Static method Returns an array of all current |
Examples
Create and Save Class Diagram
Construct a Class Viewer instance with one class preloaded. The class appears in both the Class Browser and the canvas.
httpViewer = matlab.diagram.ClassViewer('Classes','matlab.net.http.RequestMessage')
Use the addClass
method to add two additional classes to the
diagram. Because matlab.net.http.Message
is the superclass of the other
two classes, the Class Viewer automatically connects them.
addClass(httpViewer,["matlab.net.http.Message",... "matlab.net.http.ResponseMessage"])
Expand the class card for ResponseMessage
.
expandClass(httpViewer,"matlab.net.http.ResponseMessage",1)
Collapse the Properties section on the class card for
ResponseMessage
.
expandSection(httpViewer,"matlab.net.http.ResponseMessage","Properties",0)
Save the diagram as an MLDATX file.
save(httpViewer,"filepath/httpMessages.mldatx")
Version History
Introduced in R2021a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)