Search in sources :

Example 1 with ModuleMetricsWrapper

use of org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper in project titan.EclipsePlug-ins by eclipse.

the class MeasureableGraphHandler method calculateColour.

/**
 * This method calculates the colour of a given node according to a given
 * metric.
 *
 * @param node
 *            : The node that you want to colour
 * @param metric
 *            : The given metric type (currently it handles <font
 *            color="red">ONLY</font> one metric)
 * @return The calculated node colour
 */
public Color calculateColour(final NodeDescriptor node, final IMetricEnum metric) {
    chosenColouringMetric = metric;
    if (node.isMissing()) {
        node.setNodeColour(NodeColours.MISSING_COLOUR);
        return NodeColours.MISSING_COLOUR;
    }
    Color actColor;
    final ModuleMetricsWrapper actProvider = WrapperStore.getWrapper(node.getProject());
    final RiskLevel rColor = actProvider.getRisk(metric, node.getName());
    switch(rColor) {
        case NO:
            actColor = NodeColours.DARK_GREEN;
            break;
        case LOW:
            actColor = NodeColours.DARK_YELLOW;
            break;
        case HIGH:
            actColor = NodeColours.DARK_RED;
            break;
        default:
            actColor = NodeColours.NO_VALUE_COLOUR;
            break;
    }
    node.setNodeColour(actColor);
    return actColor;
}
Also used : Color(java.awt.Color) ModuleMetricsWrapper(org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper) RiskLevel(org.eclipse.titanium.metrics.utils.RiskLevel)

Example 2 with ModuleMetricsWrapper

use of org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper in project titan.EclipsePlug-ins by eclipse.

the class MetricLayoutAlgorithm method init.

private void init() {
    values = new HashMap<NodeDescriptor, Double>();
    levels = new HashMap<NodeDescriptor, Integer>();
    badNodes = new HashSet<NodeDescriptor>();
    minValue = Double.POSITIVE_INFINITY;
    maxValue = Double.NEGATIVE_INFINITY;
    filledLevels = 0;
    if (!PreferenceManager.isEnabledOnModuleGraph(chosenMetric)) {
        ErrorReporter.logError("Error during metric layout generating: The requested metric is not" + " enabled. Only enabled metrics can be chosen!");
        ErrorMessage.show("Error", "The chosen metric must be enabled for calculation in the properties." + "Have you enabled it?", MessageDialog.ERROR);
        return;
    }
    final Iterator<NodeDescriptor> it = nodes.iterator();
    while (it.hasNext()) {
        final NodeDescriptor node = it.next();
        final ModuleMetricsWrapper wrapper = WrapperStore.getWrapper(node.getProject());
        final Number val = wrapper.getValue(chosenMetric, node.getName());
        if (val == null) {
            it.remove();
            badNodes.add(node);
        } else {
            final Double tempVal = Double.valueOf(val.toString());
            if (tempVal != null) {
                values.put(node, tempVal);
                if (minValue > tempVal) {
                    minValue = tempVal;
                }
                if (maxValue < tempVal) {
                    maxValue = tempVal;
                }
            }
        }
    }
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) ModuleMetricsWrapper(org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper)

Aggregations

ModuleMetricsWrapper (org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper)2 Color (java.awt.Color)1 NodeDescriptor (org.eclipse.titanium.graph.components.NodeDescriptor)1 RiskLevel (org.eclipse.titanium.metrics.utils.RiskLevel)1