Dependency Matrix tool allows templates to access data from a Dependency Matrix, use diagrams to get data, row elements, column names, or relations between row and column elements from the matrix.
You can use the following Dependency Matrix tool API in the template.
Class DependencyMatrixTool
Use the following methods to use diagrams to get data.
Class Matrix
Use the following methods to use diagrams to get row elements, column elements, and relations between row and column elements.
Class Relation
Use the following methods for class relations.
A Dependency Matrix is a special diagram. You can retrieve it using the $Diagram variable. Thus, every method must accept a diagram instance or a diagram’s name. Use the following methods to return a Dependency Matrix instance. You can retrieve rows and columns from the Dependency Matrix instances.
getMatrix(diagram : Diagram) : Matrix
To get a Dependency Matrix instance from a specified diagram element, use the following code.
#set($matrix = $depmatrix.getMatrix($diagram)) |
Where the parameter is:
Return an instance of Dependency Matrix.
For example:
#foreach($diagram in $project.getDiagrams("Dependency Matrix")) #set($matrix = $depmatrix.getMatrix($diagram)) #end |
getMatrix(diagramName : String) : Matrix
To get a Dependency Matrix instance from a specified diagram’s name.
#set($matrix = $depmatrix.getMatrix($diagram)) |
Where the parameter is:
Return a Dependency Matrix instance.
Example code:
#set($diagram = "diagram name") #set($matrix = $depmatrix.getMatrix($diagram)) |
The Matrix consists of rows and columns.
getRows() : List<Element>
Use this method to retrieve a list of row elements.
$matrix.getRows() |
The returned value is a list of Elements.
To print all row elements' names, for example, type the following code:
#foreach($row in $matrix.rows) $row.name #end |
The matrix consists of rows and columns.
getColumns() : List<Element>
Use this method to retrieve a list of column elements.
$matrix.getColumns() |
The returned value is a list of Elements.
To print all column elements' names, for example, type the following code:
#foreach($col in $matrix.columns) $col.name #end |
getRelation(row : Element, column : Element) : List<Relation>
Use this method to retrieve the relations between row and column elements.
$matrix.getRelation($row, $column) |
Where the parameter is:
The returned value is a list of Relations.
The Relation class contains the following methods:
To print the row, column, and its relationship name, for example, type the following code:
#foreach($row in $matrix.rows) #foreach($col in $matrix.columns) #foreach($rel in $matrix.getRelation($row, $col)) $row.name has $rel.name with $col.name #end #end #end |
To print rows, columns, and relations in a spreadsheet file format, for example, type the following code:
#import('depmatrix','com.nomagic.reportwizard.tools.DependencyMatrixTool') #forpage ($diagram in $report.filterDiagram($Diagram,["Dependency Matrix"])) #set($matrix=$depmatrix.getMatrix($diagram)) $bookmark.create($diagram.name) | ||
#forcol ($col in $matrix.columns)$col.name#endcol | ||
#forrow($row in $matrix.rows)$row.name | #forcol ($col in $matrix.columns)#if(!$report.isEmpty($matrix.getRelation ($row,$col)))-> #end#endcol | #endrow |
#endpage |
|