Revision 4377 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterFilterStackManager.java
RasterFilterStackManager.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.cresques.io.raster; |
25 | 25 |
|
26 |
import java.io.IOException; |
|
26 | 27 |
import java.lang.reflect.Constructor; |
27 | 28 |
import java.util.ArrayList; |
28 | 29 |
import java.util.Hashtable; |
... | ... | |
128 | 129 |
* @param transparencyGreen Color en la banda del verde de la transparencia |
129 | 130 |
* @param transparencyBlue Color en la banda del azul de la transparencia |
130 | 131 |
*/ |
131 |
public void addTransparencyFilter(int[][] red, int[][] green, int[][] blue,
|
|
132 |
public void addTransparencyFilter(ArrayList rangesList,
|
|
132 | 133 |
int alpha, int transparencyRed, |
133 | 134 |
int transparencyGreen, |
134 | 135 |
int transparencyBlue) { |
... | ... | |
146 | 147 |
} |
147 | 148 |
|
148 | 149 |
if(filtro != null){ |
149 |
if (red != null) { |
|
150 |
filtro.addParam("red", red); |
|
151 |
} |
|
152 |
|
|
153 |
if (green != null) { |
|
154 |
filtro.addParam("green", green); |
|
155 |
} |
|
156 |
|
|
157 |
if (blue != null) { |
|
158 |
filtro.addParam("blue", blue); |
|
159 |
} |
|
160 |
|
|
150 |
filtro.addParam("rangesList", rangesList); |
|
161 | 151 |
filtro.addParam("alpha", new Integer(alpha)); |
162 | 152 |
filtro.addParam("transparencyRed", new Integer(transparencyRed)); |
163 | 153 |
filtro.addParam("transparencyGreen", new Integer(transparencyGreen)); |
... | ... | |
198 | 188 |
} |
199 | 189 |
|
200 | 190 |
/** |
201 |
* Obtiene el rango de rojo del filtro de transparencia de la pila
|
|
202 |
* @return rango de rojo
|
|
191 |
* Obtiene la lista de rangos del filtro de transparencia de la pila
|
|
192 |
* @return ArrayList con la lista de rangos. Cada elemento es un objeto TransparencyRange
|
|
203 | 193 |
*/ |
204 |
public int[][] getTransparecyR() {
|
|
205 |
for (int i = 0; i < filterStack.lenght(); i++) {
|
|
194 |
public ArrayList getTransparencyRGB(){
|
|
195 |
for (int i = 0; i < filterStack.lenght(); i++) {
|
|
206 | 196 |
if (filterStack.get(i) instanceof TransparencyImageFilter || |
207 | 197 |
filterStack.get(i) instanceof TransparencyShortFilter) { |
208 |
return ((TransparencyFilter) filterStack.get(i)).rangesR;
|
|
198 |
return ((TransparencyFilter) filterStack.get(i)).rangesList;
|
|
209 | 199 |
} |
210 | 200 |
} |
211 |
|
|
212 | 201 |
return null; |
213 | 202 |
} |
214 |
|
|
203 |
|
|
215 | 204 |
/** |
216 |
* Obtiene el rango de verde del filtro de transparencia de la pila |
|
217 |
* @return rango de verde |
|
218 |
*/ |
|
219 |
public int[][] getTransparecyG() { |
|
220 |
for (int i = 0; i < filterStack.lenght(); i++) { |
|
221 |
if (filterStack.get(i) instanceof TransparencyImageFilter || |
|
222 |
filterStack.get(i) instanceof TransparencyShortFilter) { |
|
223 |
return ((TransparencyFilter) filterStack.get(i)).rangesG; |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
return null; |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* Obtiene el rango de azul del filtro de transparencia de la pila |
|
232 |
* @return rango de azul |
|
233 |
*/ |
|
234 |
public int[][] getTransparecyB() { |
|
235 |
for (int i = 0; i < filterStack.lenght(); i++) { |
|
236 |
if (filterStack.get(i) instanceof TransparencyImageFilter || |
|
237 |
filterStack.get(i) instanceof TransparencyShortFilter) { |
|
238 |
return ((TransparencyFilter) filterStack.get(i)).rangesB; |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 |
return null; |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 | 205 |
* A?ade un filtro de eliminado de bandas. Las pone a 0 |
247 | 206 |
* @param bands |
248 | 207 |
*/ |
... | ... | |
605 | 564 |
|
606 | 565 |
if (rf instanceof TransparencyFilter) { |
607 | 566 |
filterList.add("filter.transparency.active=true"); |
608 |
filterList.add("filter.transparency.rangeR=" + |
|
609 |
rangeToString(((TransparencyFilter) rf).getRangeR())); |
|
610 |
filterList.add("filter.transparency.rangeG=" + |
|
611 |
rangeToString(((TransparencyFilter) rf).getRangeG())); |
|
612 |
filterList.add("filter.transparency.rangeB=" + |
|
613 |
rangeToString(((TransparencyFilter) rf).getRangeB())); |
|
567 |
for(int j=0;j<((TransparencyFilter) rf).rangesList.size();j++) |
|
568 |
filterList.add("filter.transparency.transparencyRange"+j+"="+ |
|
569 |
((TransparencyRange)((TransparencyFilter) rf).rangesList.get(j)).getStrEntry()); |
|
614 | 570 |
} else if (rf instanceof LinearEnhancementFilter) { |
615 | 571 |
filterList.add("filter.enhanced.active=true"); |
616 | 572 |
filterList.add("filter.enhanced.remove=" + |
... | ... | |
688 | 644 |
int[][] r = null; |
689 | 645 |
int[][] g = null; |
690 | 646 |
int[][] b = null; |
691 |
|
|
647 |
|
|
648 |
ArrayList list = new ArrayList(); |
|
692 | 649 |
for (int propFilter = 0;propFilter < filters.size();propFilter++) { |
693 | 650 |
String elem = (String) filters.get(propFilter); |
694 | 651 |
|
695 |
if (elem.startsWith("filter.transparency.rangeR")) { |
|
652 |
//TODO: Para compatibilidad con versiones anteriores hay que hacer que a partir de esto se cree un filtro |
|
653 |
/*if (elem.startsWith("filter.transparency.rangeR")) { |
|
696 | 654 |
r = stringToRange(getValue(elem)); |
697 | 655 |
filters.remove(propFilter); |
698 | 656 |
propFilter--; |
... | ... | |
708 | 666 |
b = stringToRange(getValue(elem)); |
709 | 667 |
filters.remove(propFilter); |
710 | 668 |
propFilter--; |
669 |
}*/ |
|
670 |
if (elem.startsWith("filter.transparency.transparencyRange")) { |
|
671 |
TransparencyRange tr = new TransparencyRange(); |
|
672 |
String value = getValue(elem); |
|
673 |
tr.setStrEntry(value); |
|
674 |
int[] red = new int[2]; |
|
675 |
int[] green = new int[2]; |
|
676 |
int[] blue = new int[2]; |
|
677 |
boolean and = true; |
|
678 |
try{ |
|
679 |
and = TransparencyRange.stringToInterval(value, red, green, blue); |
|
680 |
if(red[0] == -1) |
|
681 |
red = null; |
|
682 |
if(green[0] == -1) |
|
683 |
green = null; |
|
684 |
if(blue[0] == -1) |
|
685 |
blue = null; |
|
686 |
}catch(IOException e){ |
|
687 |
e.printStackTrace(); |
|
688 |
} |
|
689 |
tr.setAnd(and); |
|
690 |
tr.setRed(red); |
|
691 |
tr.setGreen(green); |
|
692 |
tr.setBlue(blue); |
|
693 |
list.add(tr); |
|
694 |
filters.remove(propFilter); |
|
695 |
propFilter--; |
|
711 | 696 |
} |
712 | 697 |
} |
713 | 698 |
|
714 |
this.addTransparencyFilter(r, g, b, 0x10, 0xff, 0xff, 0xff); |
|
699 |
this.addTransparencyFilter(list, 0x10, 0xff, 0xff, 0xff); |
|
700 |
|
|
715 | 701 |
filteri = -1; |
716 | 702 |
} |
717 | 703 |
|
Also available in: Unified diff