1 package net.sf.openrocket.gui.dialogs.preset;
3 import javax.swing.RowFilter;
4 import javax.swing.table.TableModel;
6 import net.sf.openrocket.unit.Value;
8 public class ComponentPresetRowFilter extends RowFilter<TableModel, Object> {
10 private final double value;
11 private final int column;
12 // I chose epsilon to be 0.001 units. Since this is mostly used with lengths, it represents
14 private final double epsilon = .001;
16 ComponentPresetRowFilter( double value, int column ) {
22 public boolean include( RowFilter.Entry<? extends TableModel, ? extends Object> entry) {
23 Object o = entry.getValue(column);
24 if ( o instanceof Value ) {
26 return Math.abs( value - v.getValue() ) < epsilon;
28 if ( o instanceof Double ) {
29 Double d = (Double) o;
30 return Math.abs( value - d ) < epsilon;