Revision 18138 trunk/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/IndexFilter.java
IndexFilter.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.animation.dateFilter; |
2 | 2 |
|
3 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
4 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
5 |
import com.hardcode.gdbms.engine.values.Value; |
|
6 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
7 |
import com.iver.cit.gvsig.fmap.layers.ICustomVectorialFilter; |
|
8 |
import com.iver.utiles.IPersistance; |
|
3 |
//import com.hardcode.gdbms.engine.values.NullValue; |
|
4 |
//import com.hardcode.gdbms.engine.values.NumericValue; |
|
5 |
//import com.hardcode.gdbms.engine.values.Value; |
|
6 |
//import com.iver.cit.gvsig.fmap.core.IFeature; |
|
7 |
import com.iver.utiles.IPersistence; |
|
9 | 8 |
import com.iver.utiles.XMLEntity; |
10 | 9 |
|
11 |
public class IndexFilter implements ICustomVectorialFilter, IPersistance { |
|
10 |
//public class IndexFilter implements ICustomVectorialFilter, IPersistence { |
|
11 |
public class IndexFilter { |
|
12 | 12 |
|
13 |
private int filterFieldIndex=-1; |
|
14 |
private int minIndex = -1; |
|
15 |
private int maxIndex = -1; |
|
16 |
|
|
17 |
public void setFieldIndex(int index) { |
|
18 |
filterFieldIndex = index; |
|
19 |
} |
|
20 |
|
|
21 |
// if type is INTEGER, use these instead of setMinDate/setMaxDate |
|
22 |
// internally, the int value is used as year |
|
23 |
public void setMinIndex(int miniIndex) { |
|
24 |
minIndex = miniIndex; |
|
25 |
} |
|
26 |
|
|
27 |
public void setMaxIndex(int maxiIndex) { |
|
28 |
maxIndex = maxiIndex; |
|
29 |
} |
|
30 |
|
|
31 |
public boolean accepts(IFeature feature) { |
|
32 |
|
|
33 |
Value val = feature.getAttribute(filterFieldIndex); |
|
34 |
if (val instanceof NullValue) |
|
35 |
return false; |
|
36 |
|
|
37 |
if (!(val instanceof NumericValue)) |
|
38 |
return false; |
|
39 |
|
|
40 |
int intVal = ((NumericValue)val).intValue(); |
|
41 |
|
|
42 |
if (intVal < minIndex) |
|
43 |
return false; |
|
44 |
|
|
45 |
if (intVal > maxIndex) |
|
46 |
return false; |
|
47 |
|
|
48 |
return true; |
|
49 |
} |
|
13 |
// private int filterFieldIndex=-1; |
|
14 |
// private int minIndex = -1; |
|
15 |
// private int maxIndex = -1; |
|
16 |
// |
|
17 |
// public void setFieldIndex(int index) { |
|
18 |
// filterFieldIndex = index; |
|
19 |
// } |
|
20 |
// |
|
21 |
// // if type is INTEGER, use these instead of setMinDate/setMaxDate |
|
22 |
// // internally, the int value is used as year |
|
23 |
// public void setMinIndex(int miniIndex) { |
|
24 |
// minIndex = miniIndex; |
|
25 |
// } |
|
26 |
// |
|
27 |
// public void setMaxIndex(int maxiIndex) { |
|
28 |
// maxIndex = maxiIndex; |
|
29 |
// } |
|
30 |
// |
|
31 |
// public boolean accepts(IFeature feature) { |
|
32 |
// |
|
33 |
// Value val = feature.getAttribute(filterFieldIndex); |
|
34 |
// if (val instanceof NullValue) |
|
35 |
// return false; |
|
36 |
// |
|
37 |
// if (!(val instanceof NumericValue)) |
|
38 |
// return false; |
|
39 |
// |
|
40 |
// int intVal = ((NumericValue)val).intValue(); |
|
41 |
// |
|
42 |
// if (intVal < minIndex) |
|
43 |
// return false; |
|
44 |
// |
|
45 |
// if (intVal > maxIndex) |
|
46 |
// return false; |
|
47 |
// |
|
48 |
// return true; |
|
49 |
// } |
|
50 |
// |
|
51 |
// public String getClassName() { |
|
52 |
// return this.getClass().getName(); |
|
53 |
// } |
|
54 |
// |
|
55 |
// public XMLEntity getXMLEntity() { |
|
56 |
// XMLEntity xml = new XMLEntity(); |
|
57 |
// |
|
58 |
// xml.putProperty("fieldIndex", filterFieldIndex); |
|
59 |
// xml.putProperty("minIndex", minIndex); |
|
60 |
// xml.putProperty("maxIndex", maxIndex); |
|
61 |
// |
|
62 |
// return xml; |
|
63 |
// } |
|
64 |
// |
|
65 |
// public void setXMLEntity(XMLEntity xml) { |
|
66 |
// |
|
67 |
// if (xml.contains("fieldIndex")) |
|
68 |
// filterFieldIndex = xml.getIntProperty("fieldIndex"); |
|
69 |
// |
|
70 |
// if (xml.contains("minIndex")) |
|
71 |
// minIndex = xml.getIntProperty("minIndex"); |
|
72 |
// |
|
73 |
// if (xml.contains("maxIndex")) |
|
74 |
// maxIndex = xml.getIntProperty("maxIndex"); |
|
75 |
// } |
|
76 |
// |
|
77 |
// public boolean compareTo(ICustomVectorialFilter filter) { |
|
78 |
// IndexFilter filterAux = (IndexFilter) filter; |
|
79 |
// |
|
80 |
// return ((this.minIndex == filterAux.minIndex) && (this.maxIndex == filterAux.maxIndex)); |
|
81 |
// } |
|
50 | 82 |
|
51 |
public String getClassName() { |
|
52 |
return this.getClass().getName(); |
|
53 |
} |
|
54 |
|
|
55 |
public XMLEntity getXMLEntity() { |
|
56 |
XMLEntity xml = new XMLEntity(); |
|
57 |
|
|
58 |
xml.putProperty("fieldIndex", filterFieldIndex); |
|
59 |
xml.putProperty("minIndex", minIndex); |
|
60 |
xml.putProperty("maxIndex", maxIndex); |
|
61 |
|
|
62 |
return xml; |
|
63 |
} |
|
64 |
|
|
65 |
public void setXMLEntity(XMLEntity xml) { |
|
66 |
|
|
67 |
if (xml.contains("fieldIndex")) |
|
68 |
filterFieldIndex = xml.getIntProperty("fieldIndex"); |
|
69 |
|
|
70 |
if (xml.contains("minIndex")) |
|
71 |
minIndex = xml.getIntProperty("minIndex"); |
|
72 |
|
|
73 |
if (xml.contains("maxIndex")) |
|
74 |
maxIndex = xml.getIntProperty("maxIndex"); |
|
75 |
} |
|
76 |
|
|
77 |
public boolean compareTo(ICustomVectorialFilter filter) { |
|
78 |
IndexFilter filterAux = (IndexFilter) filter; |
|
79 |
|
|
80 |
return ((this.minIndex == filterAux.minIndex) && (this.maxIndex == filterAux.maxIndex)); |
|
81 |
} |
|
82 |
|
|
83 | 83 |
} |
Also available in: Unified diff