"weighted avg",
new WeightedAvgCalculator(leafElements, builder
.getCacheManager()));
}
for (Entry<String, AbstractCalculator> entry : calculators.entrySet()) {
final AbstractCalculator calculator = entry.getValue();
String caption = entry.getKey();
final TableViewerColumn viewerColumn = new TableViewerColumn(
tableViewer, SWT.NONE);
TableColumn tableColumn = viewerColumn.getColumn();
calculatorsColumnMap.put(tableColumn, calculator);
tableColumn.setText(caption + decoratorString);
tableColumn.setToolTipText(caption + " " +tooltipDecoratorString);
tableColumn.setWidth(100);
tableColumn.setMoveable(true);
tableColumn.setResizable(true);
viewerColumn.setLabelProvider(new CellLabelProvider() {
public void update(ViewerCell cell) {
Float weight = calculator
.calcAggregation((ConstrainedElement) cell
.getElement());
setCellTooltip(cell, weight);
if (symbolsCheckbox.getSelection()) {
setSymbol(cell, weight);
} else if (grlSymbolsCheckbox.getSelection()) {
setGRLSymbol(cell, weight);
} else {
String texString = calculator
.calcAggregationAsString((ConstrainedElement) cell
.getElement());
cell.setFont(Display.getDefault().getSystemFont());
cell.setText(texString);
}
Color backgroundColor = null;
Color foregroundColor = null;
if (filterEnabledCheckbox.getSelection()) {
if (weight >= thresholdSpinner.getSelection()) {
backgroundColor = new Color(null, 255, 255, 0);
foregroundColor = new Color(null, 0, 0, 0);
} else {
backgroundColor = new Color(null, 255, 255, 255);
foregroundColor = new Color(null, 0, 0, 0);
}
} else if (heatmapCheckbox.getSelection()) {
backgroundColor = DefaultColors
.getBackgroundColor(weight);
foregroundColor = DefaultColors
.getForegroundColor(weight);
} else {
backgroundColor = new Color(null, 255, 255, 255);
foregroundColor = new Color(null, 0, 0, 0);
}
cell.setBackground(backgroundColor);
cell.setForeground(foregroundColor);
}
});
new ColumnViewerSorter(tableViewer, viewerColumn) {
protected int doCompare(Viewer viewer, Object e1, Object e2) {
AbstractCalculator calculator = calculatorsColumnMap
.get(tableViewer.getTable().getSortColumn());
Float v1 = calculator
.calcAggregation((ConstrainedElement) e1);
Float v2 = calculator
.calcAggregation((ConstrainedElement) e2);
return v1.compareTo(v2);
}
};