use of org.eclipse.titanium.metrics.AltstepMetric in project titan.EclipsePlug-ins by eclipse.
the class ProjectStatNode method getColumnText.
@Override
public String getColumnText(final MetricData data, final int i) {
if (i == 0) {
return metric.getName();
} else {
StatColumn c = null;
switch(i) {
case 1:
c = StatColumn.TOTAL;
break;
case 2:
c = StatColumn.MAX;
break;
case 3:
c = StatColumn.MEAN;
break;
case 4:
c = StatColumn.DEV;
break;
default:
return null;
}
Statistics s;
if (metric instanceof AltstepMetric) {
s = data.getStatistics((AltstepMetric) metric);
} else if (metric instanceof FunctionMetric) {
s = data.getStatistics((FunctionMetric) metric);
} else if (metric instanceof TestcaseMetric) {
s = data.getStatistics((TestcaseMetric) metric);
} else if (metric instanceof ModuleMetric) {
s = data.getStatistics((ModuleMetric) metric);
} else {
throw new IllegalArgumentException(metric.getName() + " is not a subproject metric");
}
final Number n = s.get(c);
return n == null ? null : n.toString();
}
}
use of org.eclipse.titanium.metrics.AltstepMetric in project titan.EclipsePlug-ins by eclipse.
the class ProjectStatNode method getChildren.
@Override
public Object[] getChildren(final MetricData data) {
if (initialized) {
return children;
}
final List<? super IContentNode> c = new ArrayList<IContentNode>();
if (metric instanceof FunctionMetric || metric instanceof AltstepMetric || metric instanceof TestcaseMetric) {
for (final Module m : data.getModules()) {
final IContentNode n = new ModuleStatNode(metric, m);
if (n.hasChildren(data)) {
c.add(n);
}
}
} else if (metric instanceof ModuleMetric) {
for (final Module m : data.getModules()) {
c.add(new ModuleNode((ModuleMetric) metric, m));
}
} else {
throw new AssertionError("ProjectStatNode should have a subProject-metric");
}
children = c.toArray();
initialized = true;
return children;
}
use of org.eclipse.titanium.metrics.AltstepMetric in project titan.EclipsePlug-ins by eclipse.
the class ModuleGraphEditor method initWindow.
@Override
protected void initWindow() {
super.initWindow();
isom.addActionListener(layoutListener);
layoutGroup.add(isom);
layoutMenu.add(isom);
kk.addActionListener(layoutListener);
layoutGroup.add(kk);
layoutMenu.add(kk);
fr.addActionListener(layoutListener);
layoutGroup.add(fr);
layoutMenu.add(fr);
spring.addActionListener(layoutListener);
layoutMenu.add(spring);
layoutGroup.add(spring);
circle.addActionListener(layoutListener);
layoutMenu.add(circle);
layoutGroup.add(circle);
final JMenu dagMenu = new JMenu("Directed layouts");
layoutMenu.add(dagMenu);
tdag.setSelected(true);
tdag.addActionListener(layoutListener);
dagMenu.add(tdag);
layoutGroup.add(tdag);
rtdag.addActionListener(layoutListener);
dagMenu.add(rtdag);
layoutGroup.add(rtdag);
layoutMenu.add(metricLayoutMenu);
final ActionListener changeMetrics = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
MetricsEntry metric = (MetricsEntry) e.getSource();
chosenMetric = metric;
for (NodeDescriptor node : graph.getVertices()) {
((MeasureableGraphHandler) handler).calculateColour(node, chosenMetric.getMetric());
}
drawArea.repaint();
if (satView != null) {
satView.repaint();
}
}
};
boolean isFirst = true;
// Creating the metric-selection menu:
JMenu actMenu = new JMenu(ModuleMetric.GROUP_NAME);
JMenu actLayoutMenu = new JMenu(ModuleMetric.GROUP_NAME);
metricsMenu.add(actMenu);
metricLayoutMenu.add(actLayoutMenu);
for (final ModuleMetric metric : ModuleMetric.values()) {
if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
continue;
}
final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
if (isFirst) {
item.setSelected(true);
chosenMetric = item;
isFirst = false;
}
item.addActionListener(changeMetrics);
metricsGroup.add(item);
actMenu.add(item);
final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
layoutItem.addActionListener(layoutListener);
layoutGroup.add(layoutItem);
actLayoutMenu.add(layoutItem);
}
actMenu = new JMenu(AltstepMetric.GROUP_NAME);
actLayoutMenu = new JMenu(AltstepMetric.GROUP_NAME);
metricsMenu.add(actMenu);
metricLayoutMenu.add(actLayoutMenu);
for (final AltstepMetric metric : AltstepMetric.values()) {
if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
continue;
}
final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
item.addActionListener(changeMetrics);
metricsGroup.add(item);
actMenu.add(item);
final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
layoutItem.addActionListener(layoutListener);
layoutGroup.add(layoutItem);
actLayoutMenu.add(layoutItem);
}
actMenu = new JMenu(FunctionMetric.GROUP_NAME);
actLayoutMenu = new JMenu(FunctionMetric.GROUP_NAME);
metricLayoutMenu.add(actLayoutMenu);
metricsMenu.add(actMenu);
for (final FunctionMetric metric : FunctionMetric.values()) {
if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
continue;
}
final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
item.addActionListener(changeMetrics);
metricsGroup.add(item);
actMenu.add(item);
final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
layoutItem.addActionListener(layoutListener);
layoutGroup.add(layoutItem);
actLayoutMenu.add(layoutItem);
}
actMenu = new JMenu(TestcaseMetric.GROUP_NAME);
actLayoutMenu = new JMenu(TestcaseMetric.GROUP_NAME);
metricLayoutMenu.add(actLayoutMenu);
metricsMenu.add(actMenu);
for (final TestcaseMetric metric : TestcaseMetric.values()) {
if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
continue;
}
final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
item.addActionListener(changeMetrics);
metricsGroup.add(item);
actMenu.add(item);
final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
layoutItem.addActionListener(layoutListener);
layoutGroup.add(layoutItem);
actLayoutMenu.add(layoutItem);
}
final JMenuItem recalcItem = new JMenuItem("Recalculate metrics");
recalcItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
WrapperStore.clearStore();
GlobalParser.reAnalyzeSemantically();
recolour(graph.getVertices());
if (chosenLayout instanceof MetricsLayoutEntry) {
chosenLayout.doClick();
}
}
});
metricsMenu.add(recalcItem);
folderKnotCluster.addActionListener(new ClusteringAction("foldername", true));
knotClusteringMenu.add(folderKnotCluster);
folderGraphCluster.addActionListener(new ClusteringAction("foldername", false));
graphClusteringMenu.add(folderGraphCluster);
linkedKnotCluster.addActionListener(new ClusteringAction("linkedlocation", true));
knotClusteringMenu.add(linkedKnotCluster);
linkedGraphCluster.addActionListener(new ClusteringAction("linkedlocation", false));
graphClusteringMenu.add(linkedGraphCluster);
locationKnotCluster.addActionListener(new ClusteringAction("modulelocation", true));
knotClusteringMenu.add(locationKnotCluster);
locationGraphCluster.addActionListener(new ClusteringAction("modulelocation", false));
graphClusteringMenu.add(locationGraphCluster);
regKnotCluster.addActionListener(new ClusteringAction("regularexpression", true));
knotClusteringMenu.add(regKnotCluster);
regGraphCluster.addActionListener(new ClusteringAction("regularexpression", false));
graphClusteringMenu.add(regGraphCluster);
nameKnotCluster.addActionListener(new ClusteringAction("modulename", true));
knotClusteringMenu.add(nameKnotCluster);
nameGraphCluster.addActionListener(new ClusteringAction("modulename", false));
nameClusteringMenu.add(nameGraphCluster);
fullNameGraphCluster.addActionListener(new ClusteringAction("fullmodulenametree", false, (LayoutEntry) tdag));
nameClusteringMenu.add(fullNameGraphCluster);
sparseNameGraphCluster.addActionListener(new ClusteringAction("sparsemodulenametree", false, (LayoutEntry) tdag));
nameClusteringMenu.add(sparseNameGraphCluster);
autoKnotCluster.addActionListener(new ClusteringAction("automatic", true));
knotClusteringMenu.add(autoKnotCluster);
closeGraphClusters.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
chosenLayout.setSelected(false);
tdag.setSelected(true);
chosenLayout = (LayoutEntry) tdag;
enableModuleMenus(true);
setGraph(originalGraph);
}
});
closeGraphClusters.setEnabled(false);
menuBar.add(metricsMenu);
clusteringMenu.add(knotClusteringMenu);
graphClusteringMenu.add(nameClusteringMenu);
clusteringMenu.add(graphClusteringMenu);
clusteringMenu.add(closeGraphClusters);
menuBar.add(clusteringMenu);
}
use of org.eclipse.titanium.metrics.AltstepMetric in project titan.EclipsePlug-ins by eclipse.
the class ModuleStatNode method getColumnText.
@Override
public String getColumnText(final MetricData data, final int i) {
if (i == 0) {
return module.getName();
} else {
StatColumn c = null;
switch(i) {
case 1:
c = StatColumn.TOTAL;
break;
case 2:
c = StatColumn.MAX;
break;
case 3:
c = StatColumn.MEAN;
break;
case 4:
c = StatColumn.DEV;
break;
default:
return null;
}
Statistics stat;
if (metric instanceof AltstepMetric) {
stat = data.getStatistics((AltstepMetric) metric, module);
} else if (metric instanceof FunctionMetric) {
stat = data.getStatistics((FunctionMetric) metric, module);
} else if (metric instanceof TestcaseMetric) {
stat = data.getStatistics((TestcaseMetric) metric, module);
} else {
throw new AssertionError("ModuleStatNode should have a subModule-metric");
}
final Number n = stat.get(c);
return n == null ? null : n.toString();
}
}
use of org.eclipse.titanium.metrics.AltstepMetric in project titan.EclipsePlug-ins by eclipse.
the class ModuleStatNode method getChildren.
@Override
public Object[] getChildren(final MetricData data) {
if (initialized) {
return children;
}
final List<? super IContentNode> c = new ArrayList<IContentNode>();
if (metric instanceof FunctionMetric) {
for (final Def_Function f : data.getFunctions().get(module)) {
c.add(new FunctionNode((FunctionMetric) metric, f));
}
} else if (metric instanceof TestcaseMetric) {
for (final Def_Testcase t : data.getTestcases().get(module)) {
c.add(new TestcaseNode((TestcaseMetric) metric, t));
}
} else if (metric instanceof AltstepMetric) {
for (final Def_Altstep a : data.getAltsteps().get(module)) {
c.add(new AltstepNode((AltstepMetric) metric, a));
}
} else {
throw new AssertionError("ModuleStatNode should have a subModule-metric");
}
children = c.toArray();
initialized = true;
return children;
}
Aggregations