www.sdmetrics.com

sdmetrics.app
Class Controller

java.lang.Object
  |
  +--sdmetrics.app.Controller
All Implemented Interfaces:
XMIReader.ProgressMessageHandler

public class Controller
extends java.lang.Object
implements XMIReader.ProgressMessageHandler

An instance of Controller is used to start the metrics calculation and retrieve the metric data.

Use the controller as follows:

The controller is optimized to be used with a GUI:


Constructor Summary
Controller(SDMessageHandler wm, sdmetrics.util.AppParameters ap)
           
 
Method Summary
 boolean doproject(ProjectSettings proj)
          Perform the metrics calculation: Read metamodel, XMI transformations, metric definitions, and XMI source file, calculate all metrics.
 TreeViewCC getConnCompView()
          Provide access to the connected component graph structures.
 TreeViewCycles getCycleTreeView()
          Provide access to the cycle graph structures.
 DescStats getDescStats()
          Provide access to the descriptive statistics.
 java.lang.String getLog()
          Get a copy of the messages sent to the message handler during the last calculation run.
 MeasurementCatalog getMetricCatalog()
          Provide access to the measurement catalog.
 TableView getMetricData()
          Provide access to the metric data.
 ElementPoolAdapter getModel()
          Provide access to the UML model (for the "Dump UML model" feature).
 RelMatrixAdapter getRelationMatrixAdapter()
          Provide access to the relation matrices.
 RuleCheckAdapter getRuleCheckAdapter()
          Provide access to the design rule checker.
 TreeView getTreeView()
          Provide access to the UML model elements in a Swing tree.
 void reportXMIProgress(java.lang.String msg)
          Callback function for the XMIReader to report its progress messages.
 void setMessageHandler(SDMessageHandler handler)
          Register a new message handler.
 void setXMIProgressHandler(SDMessageHandler handler)
          Register a message handler for progress messages of the XMI reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller(SDMessageHandler wm,
                  sdmetrics.util.AppParameters ap)
Parameters:
wm - Object to handle progress and error messages that are reported while metrics are calculated.
ap - Object that knows the default project files (metamodel, metric definition file, etc.)
Method Detail

doproject

public boolean doproject(ProjectSettings proj)
Perform the metrics calculation: Read metamodel, XMI transformations, metric definitions, and XMI source file, calculate all metrics.

Parameters:
proj - The project settings specifying the XMI and XML source files to analyze.
Returns:
false if an error occured, true if calculation was successful.

getRelationMatrixAdapter

public RelMatrixAdapter getRelationMatrixAdapter()
Provide access to the relation matrices. Depending on the project settings (ProjectSettings.requireRelMatrices()), the matrices may have already been calculated or not. In the latter case, you still need to call calculateMatrices() on the returned object.

Returns:
A RelMatrixAdapter object to calculate and access the relation matrices.

getRuleCheckAdapter

public RuleCheckAdapter getRuleCheckAdapter()
Provide access to the design rule checker. Depending on the project settings (ProjectSettings.requireDesignRules()), the design rules may have already been checked or not. In the latter case, you still need to call checkRules() on the returned object.

Returns:
A RuleCheckAdapter object to check design rules and access design rule violations.

getMetricCatalog

public MeasurementCatalog getMetricCatalog()
Provide access to the measurement catalog.

Returns:
A MeasurementCatalog object to access detailed descriptions of metrics, rules, etc.

getModel

public ElementPoolAdapter getModel()
Provide access to the UML model (for the "Dump UML model" feature).

Returns:
An ElementPoolAdapter object to access the UML Model.

getMetricData

public TableView getMetricData()
Provide access to the metric data. Depending on the project settings (ProjectSettings.requireDesignRules()), the metric data may have already been pre-calculated or not. In the latter case, metric data will be calculated on demand when querying metric values.

Returns:
A TableView object to access the metric data.

getDescStats

public DescStats getDescStats()
Provide access to the descriptive statistics.

Returns:
A DescStats object to access the descriptive statistics for the metric data.

getTreeView

public TreeView getTreeView()
Provide access to the UML model elements in a Swing tree.

Returns:
A TreeView object with nodes to build a JTree.

getConnCompView

public TreeViewCC getConnCompView()
Provide access to the connected component graph structures.

Returns:
A TreeViewCC object from which to pull the connected component trees.

getCycleTreeView

public TreeViewCycles getCycleTreeView()
Provide access to the cycle graph structures.

Returns:
A TreeViewCycles object from which to pull the cycle tree structures.

getLog

public java.lang.String getLog()
Get a copy of the messages sent to the message handler during the last calculation run.

Returns:
String with all progress and error messages generated by the controller.

reportXMIProgress

public void reportXMIProgress(java.lang.String msg)
Callback function for the XMIReader to report its progress messages.

Specified by:
reportXMIProgress in interface XMIReader.ProgressMessageHandler
Parameters:
msg - Message of the XMI reader to display.

setXMIProgressHandler

public void setXMIProgressHandler(SDMessageHandler handler)
Register a message handler for progress messages of the XMI reader. The XMI reader takes long and may report lots of progress messages. Depending on your application, you may want to provide a special treatment for these messages.

Parameters:
handler - The message handler object. Only the SDMessageHandler.message(java.lang.String, int) will be called, with negative progress values. The object can be the same one as specified in the constructor, a different object, or null if you don't want to display the messages of the XMI reader.

setMessageHandler

public void setMessageHandler(SDMessageHandler handler)
Register a new message handler. All messages, errors, notifications will be sent to this object from now on.

Parameters:
handler - The new message handler object.

www.sdmetrics.com