Search in sources :

Example 1 with AggregationMethod

use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.

the class NumericOutliersIntervalsCalculator method getAggretators.

/**
 * Creates column aggregators for each of the outlier columns.
 *
 * @param inSpec the input data table spec
 * @param gSettings the global settings
 * @return an array of column aggregators
 */
private ColumnAggregator[] getAggretators(final DataTableSpec inSpec, final GlobalSettings gSettings) {
    final ColumnAggregator[] aggregators = new ColumnAggregator[m_outlierColNames.length * 2];
    int pos = 0;
    // for each outlier column name create the aggregators
    for (final String outlierColName : m_outlierColNames) {
        // the operator column settings
        final OperatorColumnSettings cSettings = new OperatorColumnSettings(INCL_MISSING_CELLS, inSpec.getColumnSpec(outlierColName));
        // setting
        for (final double percentile : PERCENTILES) {
            final AggregationMethod method;
            if (m_useHeuristic) {
                method = new PSquarePercentileOperator(gSettings, cSettings, 100 * percentile);
            } else {
                method = new QuantileOperator(new OperatorData("Quantile", true, false, DoubleValue.class, INCL_MISSING_CELLS), gSettings, cSettings, percentile, m_estimationType.name());
            }
            aggregators[pos++] = new ColumnAggregator(cSettings.getOriginalColSpec(), method);
        }
    }
    // return the aggregators
    return aggregators;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) PSquarePercentileOperator(org.knime.base.data.aggregation.numerical.PSquarePercentileOperator) QuantileOperator(org.knime.base.data.aggregation.numerical.QuantileOperator) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) OperatorColumnSettings(org.knime.base.data.aggregation.OperatorColumnSettings) OperatorData(org.knime.base.data.aggregation.OperatorData)

Example 2 with AggregationMethod

use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.

the class AggregationColumnTableModel method setValue.

/**
 * {@inheritDoc}
 */
@Override
public void setValue(final Object aValue, final int row, final int columnIdx) {
    if (aValue == null) {
        return;
    }
    if (aValue instanceof AggregationMethod) {
        assert columnIdx == 1;
        final AggregationMethod newMethod = (AggregationMethod) aValue;
        updateMethod(row, newMethod);
    }
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod)

Example 3 with AggregationMethod

use of org.knime.base.data.aggregation.AggregationMethod 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()));
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator)

Example 4 with AggregationMethod

use of org.knime.base.data.aggregation.AggregationMethod 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);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) ArrayList(java.util.ArrayList)

Example 5 with AggregationMethod

use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.

the class AggregationMethodListCellRenderer method getListCellRendererComponent.

/**
 * {@inheritDoc}
 */
@Override
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
    final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    assert (c == this);
    if (value instanceof AggregationMethod) {
        final AggregationMethod aggregationMeth = (AggregationMethod) value;
        setText(aggregationMeth.getLabel());
        setToolTipText(aggregationMeth.getDescription());
    }
    return this;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) Component(java.awt.Component)

Aggregations

AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)27 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)8 ArrayList (java.util.ArrayList)6 Entry (java.util.Map.Entry)4 DataType (org.knime.core.data.DataType)4 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 Component (java.awt.Component)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 List (java.util.List)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 Container (java.awt.Container)1 Frame (java.awt.Frame)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JTable (javax.swing.JTable)1 AggregationOperator (org.knime.base.data.aggregation.AggregationOperator)1