use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.
the class AggregationColumnTableModel method removeColumns.
/**
* @param colNames the names of the columns to remove
*/
@Deprecated
protected void removeColumns(final Collection<String> colNames) {
if (colNames == null || colNames.isEmpty()) {
return;
}
final Set<String> colNameSet = new HashSet<>(colNames);
final Collection<ColumnAggregator> colAggr2Remove = new LinkedList<>();
for (final ColumnAggregator colAggr : getRows()) {
if (colNameSet.contains(colAggr.getOriginalColName())) {
colAggr2Remove.add(colAggr);
}
}
remove(colAggr2Remove);
}
use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.
the class AggregationColumnTableModel method updateMethod.
/**
* @param row the row to update
* @param method the {@link AggregationMethod} to use
*/
private void updateMethod(final int row, final AggregationMethod method) {
final ColumnAggregator old = getRow(row);
if (old.getMethodTemplate().equals(method)) {
// check if the method has changed
return;
}
// create a new operator each time it is updated to guarantee that
// each column has its own operator instance
AggregationMethod methodClone = AggregationMethods.getMethod4Id(method.getId());
updateRow(row, new ColumnAggregator(old.getOriginalColSpec(), methodClone, old.inclMissingCells()));
}
use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.
the class AggregationColumnTableModel method addColumn.
/**
* @param specs the {@link DataColumnSpec}s of the columns to add
* @see #add(List)
*/
@Deprecated
protected void addColumn(final DataColumnSpec... specs) {
if (specs == null || specs.length < 1) {
return;
}
final List<ColumnAggregator> aggregators = new ArrayList<>(specs.length);
for (final DataColumnSpec spec : specs) {
final AggregationMethod defaultMethod = AggregationMethods.getDefaultMethod(spec);
aggregators.add(new ColumnAggregator(spec, defaultMethod));
}
add(aggregators);
}
use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.
the class AggregationColumnPanel method adaptTableColumnModel.
/**
* {@inheritDoc}
*/
@Override
protected void adaptTableColumnModel(final TableColumnModel columnModel) {
columnModel.getColumn(0).setCellRenderer(new AggregationFunctionRowTableCellRenderer<>(new ValueRenderer<ColumnAggregator>() {
@Override
public void renderComponent(final DefaultTableCellRenderer c, final ColumnAggregator row) {
final DataColumnSpec spec = row.getOriginalColSpec();
c.setText(spec.getName());
c.setIcon(spec.getType().getIcon());
}
}, true, "Double click to remove column. Right mouse click for context menu."));
columnModel.getColumn(1).setCellEditor(new ColumnAggregatorTableCellEditor());
columnModel.getColumn(1).setCellRenderer(new AggregationFunctionAndRowTableCellRenderer());
columnModel.getColumn(0).setPreferredWidth(170);
columnModel.getColumn(1).setPreferredWidth(150);
}
use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.
the class AggregationColumnPanel method getMethods4SelectedItems.
/**
* @return a label list of all supported methods for the currently
* selected rows
*/
protected List<Entry<String, List<AggregationMethod>>> getMethods4SelectedItems() {
final int[] selectedColumns = getSelectedRows();
final Set<DataType> types = new HashSet<>(selectedColumns.length);
for (final int row : selectedColumns) {
final ColumnAggregator aggregator = getTableModel().getRow(row);
types.add(aggregator.getOriginalDataType());
}
final DataType superType = CollectionCellFactory.getElementType(types.toArray(new DataType[0]));
final List<Entry<String, List<AggregationMethod>>> list = AggregationMethods.getCompatibleMethodGroupList(superType);
return list;
}
Aggregations