Search in sources :

Example 1 with MetricSpinner

use of wekapar.MetricSpinner in project wekapar by gems-uff.

the class PostprocessAssociationsPanel method buildMetricsFilter.

/**
 * Builds a {@link RowFilter} according to selected metrics minimum values.
 *
 * @return the row filter object
 */
private static RowFilter<? super TableModel, ? super Integer> buildMetricsFilter() {
    RowFilter<Object, Object> rowFilter = RowFilter.regexFilter(".*");
    List<RowFilter<Object, Object>> metricFilters = new ArrayList<RowFilter<Object, Object>>();
    List<RowFilter<Object, Object>> metricFilter;
    RowFilter<Object, Object> filterEqual;
    RowFilter<Object, Object> filterAfter;
    RulesTableColumnModel columnModel = (RulesTableColumnModel) table.getColumnModel();
    MetricSpinner spinner;
    String key;
    double value;
    int columnIndex;
    for (Map.Entry<String, JSpinner> entry : metricSpinnerMap.entrySet()) {
        metricFilter = new ArrayList<RowFilter<Object, Object>>();
        key = entry.getKey();
        spinner = (MetricSpinner) entry.getValue();
        value = (Double) spinner.getValue();
        if (columnModel.hasColumn(key)) {
            if (!spinner.isMinimumSelected()) {
                columnIndex = table.getColumnModel().getColumnIndex(key);
                filterEqual = RowFilter.numberFilter(ComparisonType.EQUAL, value, table.convertColumnIndexToModel(columnIndex));
                filterAfter = RowFilter.numberFilter(ComparisonType.AFTER, value, table.convertColumnIndexToModel(columnIndex));
                metricFilter.add(filterEqual);
                metricFilter.add(filterAfter);
                metricFilters.add(RowFilter.orFilter(metricFilter));
            }
        }
    }
    rowFilter = RowFilter.andFilter(metricFilters);
    return rowFilter;
}
Also used : ArrayList(java.util.ArrayList) Point(java.awt.Point) MetricSpinner(wekapar.MetricSpinner) RowFilter(javax.swing.RowFilter) JSpinner(javax.swing.JSpinner) RulesTableColumnModel(wekapar.table.RulesTableColumnModel) Map(java.util.Map) FilterMap(wekapar.FilterMap) HashMap(java.util.HashMap)

Example 2 with MetricSpinner

use of wekapar.MetricSpinner in project wekapar by gems-uff.

the class PostprocessAssociationsPanel method onMetricPropertyChange.

/**
 * This method must be called when a {@link JCheckBox} component changes its
 * "selected" property to enable or disable respective {@link JSpinner}
 * component.
 *
 * @param e the property change event object
 */
private static void onMetricPropertyChange(PropertyChangeEvent e) {
    JCheckBox chkbx = (JCheckBox) e.getSource();
    MetricSpinner spinner = (MetricSpinner) metricSpinnerMap.get(chkbx.getText());
    if (chkbx.isSelected()) {
        spinner.setEnabled(chkbx.isEnabled());
    } else {
        spinner.setEnabled(false);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) MetricSpinner(wekapar.MetricSpinner)

Aggregations

MetricSpinner (wekapar.MetricSpinner)2 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JCheckBox (javax.swing.JCheckBox)1 JSpinner (javax.swing.JSpinner)1 RowFilter (javax.swing.RowFilter)1 FilterMap (wekapar.FilterMap)1 RulesTableColumnModel (wekapar.table.RulesTableColumnModel)1