svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / TransparencyShortFilter.java @ 2312
History | View | Annotate | Download (3.16 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.io.raster; |
25 |
|
26 |
import java.awt.Image; |
27 |
import java.util.Vector; |
28 |
|
29 |
/**
|
30 |
* Filtro de transparencia aplicada a un rango de valores de un pixel sobre un objeto image
|
31 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
32 |
*
|
33 |
*/
|
34 |
public class TransparencyShortFilter extends TransparencyFilter{ |
35 |
|
36 |
/**
|
37 |
* Constructor
|
38 |
*
|
39 |
*/
|
40 |
public TransparencyShortFilter(){
|
41 |
super();
|
42 |
} |
43 |
|
44 |
/* (non-Javadoc)
|
45 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
46 |
*/
|
47 |
public void pre(){ |
48 |
//Obtenci?n de par?metros
|
49 |
|
50 |
this.raster = (RasterBuf)params.get("raster"); |
51 |
height = raster.getHeight(); |
52 |
width = raster.getWidth(); |
53 |
super.pre();
|
54 |
} |
55 |
|
56 |
/**
|
57 |
* Para un vector de rangos de una banda concreta, si el punto pasado como par?metro
|
58 |
* en la banda concreta est? en el rango especificado se asigna al valor de transparencia
|
59 |
* por defecto.
|
60 |
* @param range
|
61 |
* @param banda
|
62 |
* @param px
|
63 |
*/
|
64 |
private void processRange(int[][] range, int banda, int[] px){ |
65 |
for(int i=0;i<range.length;i++){ |
66 |
if( (px[banda] >= range[i][0] && px[banda] <= range[i][1]) ){ |
67 |
px[3] = this.alpha; |
68 |
px[0] = this.transparencyColorRed; |
69 |
px[1] = this.transparencyColorGreen; |
70 |
px[2] = this.transparencyColorBlue; |
71 |
} |
72 |
} |
73 |
} |
74 |
|
75 |
/* (non-Javadoc)
|
76 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int)
|
77 |
*/
|
78 |
public void process(int x, int y) { |
79 |
raster.getElemInt(x, y, px); |
80 |
if(rangesR!=null) |
81 |
processRange(rangesR, 0, px);
|
82 |
if(rangesG!=null) |
83 |
processRange(rangesG, 1, px);
|
84 |
if(rangesB!=null) |
85 |
processRange(rangesB, 2, px);
|
86 |
raster.setElemInt(x, y, px); |
87 |
} |
88 |
|
89 |
/* (non-Javadoc)
|
90 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
91 |
*/
|
92 |
public int getInRasterDataType(){ |
93 |
return RasterBuf.TYPE_SHORT;
|
94 |
} |
95 |
|
96 |
/* (non-Javadoc)
|
97 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
98 |
*/
|
99 |
public int getOutRasterDataType(){ |
100 |
return RasterBuf.TYPE_SHORT;
|
101 |
} |
102 |
|
103 |
/* (non-Javadoc)
|
104 |
* @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
|
105 |
*/
|
106 |
public Object getResult(String name){ |
107 |
if(name.equals("raster")) |
108 |
return (Object)this.raster; |
109 |
else
|
110 |
return null; |
111 |
} |
112 |
|
113 |
/* (non-Javadoc)
|
114 |
* @see org.cresques.io.raster.RasterFilter#processLine(int)
|
115 |
*/
|
116 |
public void processLine(int y){}; |
117 |
|
118 |
/* (non-Javadoc)
|
119 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
120 |
*/
|
121 |
public void post(){} |
122 |
|
123 |
} |
124 |
|
125 |
|
126 |
|