1 package baseCode.dataFilter;
2
3 import baseCode.math.Stats;
4
5 /***
6 * Abstract class representing a filter that removes things from matrices based on the values themselves. Copyright (c)
7 * 2004 Columbia University
8 *
9 * @author Owner
10 * @version $Id: AbstractLevelFilter.java,v 1.3 2004/07/27 03:18:58 pavlidis Exp $
11 */
12 public abstract class AbstractLevelFilter extends AbstractFilter {
13
14 protected double lowCut = -Double.MAX_VALUE;
15 protected double highCut = Double.MAX_VALUE;
16 protected boolean useLowAsFraction = false;
17 protected boolean useHighAsFraction = false;
18
19 /***
20 * Set the low threshold for removal.
21 *
22 * @param lowCut the threshold
23 */
24 public void setLowCut( double lowCut ) {
25 this.lowCut = lowCut;
26 }
27
28 /***
29 * @param lowCut
30 * @param isFraction
31 */
32 public void setLowCut( double lowCut, boolean isFraction ) {
33 setLowCut( lowCut );
34 setUseLowCutAsFraction( isFraction );
35 useLowAsFraction = isFraction;
36 }
37
38 /***
39 * Set the high threshold for removal. If not set, no filtering will occur.
40 *
41 * @param h the threshold
42 */
43 public void setHighCut( double h ) {
44 highCut = h;
45 }
46
47 /***
48 * @param highCut
49 * @param isFraction
50 */
51 public void setHighCut( double highCut, boolean isFraction ) {
52 setHighCut( highCut );
53 setUseHighCutAsFraction( isFraction );
54 useHighAsFraction = isFraction;
55 }
56
57 /***
58 * @param setting
59 */
60 public void setUseHighCutAsFraction( boolean setting ) {
61 if ( setting == true && !Stats.isValidFraction( highCut ) ) {
62 throw new IllegalArgumentException(
63 "Value for cut(s) are invalid for using "
64 + "as fractions, must be >0.0 and <1.0," );
65 }
66 useHighAsFraction = setting;
67 }
68
69 /***
70 * @param setting
71 */
72 public void setUseLowCutAsFraction( boolean setting ) {
73 if ( setting == true && !Stats.isValidFraction( lowCut ) ) {
74 throw new IllegalArgumentException(
75 "Value for cut(s) are invalid for using "
76 + "as fractions, must be >0.0 and <1.0," );
77 }
78 useLowAsFraction = setting;
79 }
80
81 /***
82 * Set the filter to interpret the low and high cuts as fractions; that is, if true, lowcut 0.1 means remove 0.1 of
83 * the rows with the lowest values. Otherwise the cuts are interpeted as actual values. Default = false.
84 *
85 * @param setting boolean
86 */
87 public void setUseAsFraction( boolean setting ) {
88 setUseHighCutAsFraction( setting );
89 setUseLowCutAsFraction( setting );
90 }
91
92 }