gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.api / src / main / java / org / gvsig / fmap / dal / coverage / grid / render / Render.java @ 723
History | View | Annotate | Download (9.14 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.grid.render; |
23 |
|
24 |
import java.awt.Graphics2D; |
25 |
import java.awt.geom.Dimension2D; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
29 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
30 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
31 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
32 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
33 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
34 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
35 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
36 |
|
37 |
|
38 |
|
39 |
/**
|
40 |
* Renders a Grid object
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public interface Render extends Runnable { |
44 |
|
45 |
/**
|
46 |
* Obtiene las lista de filtros aplicados en la renderizaci?n
|
47 |
* @return RasterFilterList
|
48 |
*/
|
49 |
public RasterFilterList getFilterList();
|
50 |
|
51 |
/**
|
52 |
* Asigna la lista de filtros que se usar? en el renderizado
|
53 |
* @param RasterFilterList
|
54 |
*/
|
55 |
public void setFilterList(RasterFilterList filterList); |
56 |
|
57 |
/**
|
58 |
* Asigna el ?ltimo estado de transparencia de la renderizaci?n.
|
59 |
* @param lastTransparency
|
60 |
*/
|
61 |
public void setLastTransparency(Transparency lastTransparency); |
62 |
|
63 |
/**
|
64 |
* Obtiene el ?ltimo objeto transparencia aplicado en la renderizaci?n
|
65 |
* @return GridTransparency
|
66 |
*/
|
67 |
public Transparency getLastTransparency(); |
68 |
|
69 |
/**
|
70 |
* Gets the last alpha band number
|
71 |
* @return
|
72 |
*/
|
73 |
public int getLastAlphaBandNumber(); |
74 |
|
75 |
/**
|
76 |
* Obtiene el ?ltimo buffer renderizado.
|
77 |
* @return Buffer
|
78 |
*/
|
79 |
public Buffer getLastRenderBuffer(); |
80 |
|
81 |
/**
|
82 |
* Asigna el ?ltimo renderizado.
|
83 |
* @param buf
|
84 |
*/
|
85 |
public void setLastRenderBuffer(Buffer buf); |
86 |
|
87 |
/**
|
88 |
* Informa de si el raster tiene tabla de color asociada o no.
|
89 |
* @return true si tiene tabla de color y false si no la tiene.
|
90 |
*/
|
91 |
public boolean existColorTable(); |
92 |
|
93 |
/**
|
94 |
* Gets a data store
|
95 |
* @return
|
96 |
*/
|
97 |
public RasterDataStore getDataStore();
|
98 |
|
99 |
/**
|
100 |
* Sets a data store
|
101 |
* @param dataStore
|
102 |
*/
|
103 |
public void setDataStore(RasterDataStore dataStore); |
104 |
|
105 |
/**
|
106 |
* Gets the color table
|
107 |
* @return
|
108 |
*/
|
109 |
public ColorTable getColorTable();
|
110 |
|
111 |
/**
|
112 |
* Asigna un listener a la lista que ser? informado cuando cambie una
|
113 |
* propiedad visual en la renderizaci?n.
|
114 |
* @param listener VisualPropertyListener
|
115 |
*/
|
116 |
public void addVisualPropertyListener(VisualPropertyListener listener); |
117 |
|
118 |
/**
|
119 |
* Devuelve si la asignacion de las bandas a renderizar representa una capa
|
120 |
* en escala de grises
|
121 |
* @return
|
122 |
*/
|
123 |
public boolean isRenderingAsGray(); |
124 |
|
125 |
/**
|
126 |
* Asigna el n?mero de bandas y el orden de renderizado. Cada posici?n del vector es una banda
|
127 |
* del buffer y el contenido de esa posici?n es la banda de la imagen que se dibujar?
|
128 |
* sobre ese buffer. A la hora de renderizar hay que tener en cuenta que solo se renderizan las
|
129 |
* tres primeras bandas del buffer por lo que solo se tienen en cuenta los tres primeros
|
130 |
* elementos. Por ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3 de un
|
131 |
* raster que tiene al menos 4 bandas. La notaci?n con -1 en alguna posici?n del vector solo tiene sentido
|
132 |
* en la visualizaci?n pero no se puede as?gnar una banda del buffer a null.
|
133 |
* Algunos ejemplos:
|
134 |
* <P>
|
135 |
* {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n.
|
136 |
* Si replicateBand es true R = G = B sino R = B = 0
|
137 |
* {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3
|
138 |
* {0} La R = banda 0 del raster. Si replicateBand es true R = G = B sino G = B = 0
|
139 |
* </P>
|
140 |
*
|
141 |
*
|
142 |
* @param renderBands: bandas y su posici?n
|
143 |
*/
|
144 |
public void setRenderBands(int[] renderBands); |
145 |
|
146 |
/**
|
147 |
* Obtiene el n?mero de bandas y el orden de renderizado. Cada posici?n del
|
148 |
* vector es una banda del buffer y el contenido de esa posici?n es la banda
|
149 |
* de la imagen que se dibujar? sobre ese buffer. A la hora de renderizar hay
|
150 |
* que tener en cuenta que solo se renderizan las tres primeras bandas del
|
151 |
* buffer por lo que solo se tienen en cuenta los tres primeros elementos. Por
|
152 |
* ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3
|
153 |
* de un raster de al menos 4 bandas. La notaci?n con -1 en alguna posici?n
|
154 |
* del vector solo tiene sentido en la visualizaci?n pero no se puede as?gnar
|
155 |
* una banda del buffer a null. Algunos ejemplos:
|
156 |
* <P>
|
157 |
* <UL>
|
158 |
* <LI> {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n. Si
|
159 |
* replicateBand es true R = G = B sino R = B = 0 </LI>
|
160 |
* <LI> {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3 </LI>
|
161 |
* <LI> {0} La R = banda 0 del raster. Si replicateBand es true R = G = B
|
162 |
* sino G = B = 0</LI>
|
163 |
* </UL>
|
164 |
* </P>
|
165 |
*
|
166 |
* @return bandas y su posici?n
|
167 |
*/
|
168 |
public int[] getRenderBands(); |
169 |
|
170 |
/**
|
171 |
* Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
|
172 |
* vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n
|
173 |
* calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula
|
174 |
* el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro
|
175 |
* del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
|
176 |
* se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
|
177 |
* sobre el Image que ha devuelto el driver.
|
178 |
*
|
179 |
* Para calcular en que coordenada pixel (pt) se empezar? a pintar el BufferedImage con el raster le?do
|
180 |
* se aplica sobre la esquina superior izquierda de esta la matriz de transformaci?n del ViewPortData
|
181 |
* pasado vp.mat.transform(pt, pt). Si el raster no est? rotado este punto es el resultante de la
|
182 |
* funci?n calculateNewView que devuelve la petici?n ajustada al extent de la imagen (sin rotar). Si
|
183 |
* el raster est? rotado necesitaremos para la transformaci?n el resultado de la funci?n coordULRotateRaster.
|
184 |
* Lo que hace esta ?ltima es colocar la petici?n que ha sido puesta en coordenadas de la imagen sin rotar
|
185 |
* (para pedir al driver de forma correcta) otra vez en coordenadas de la imagen rotada (para calcular su
|
186 |
* posici?n de dibujado).
|
187 |
*
|
188 |
* Para dibujar sobre el Graphics2D el raster rotado aplicaremos la matriz de transformaci?n con los
|
189 |
* par?metros de Shear sobre este Graphics de forma inversa. Como hemos movido el fondo tendremos que
|
190 |
* recalcular ahora el punto donde se comienza a dibujar aplicandole la transformaci?n sobre este
|
191 |
* at.inverseTransform(pt, pt);. Finalmente volcamos el BufferedImage sobre el Graphics volviendo a dejar
|
192 |
* el Graphics en su posici?n original al acabar.
|
193 |
*
|
194 |
* @param g Graphics sobre el que se pinta
|
195 |
* @param vp ViewPort de la extensi?n a dibujar
|
196 |
* @throws InvalidSetViewException
|
197 |
* @throws ArrayIndexOutOfBoundsException
|
198 |
*/
|
199 |
public void draw(Graphics2D g, ViewPortData vp) |
200 |
throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
|
201 |
|
202 |
/**
|
203 |
* Este m?todo dibuja sobre el Graphics a partir de un Viewport sin ajustar. Los tiles que van llegando
|
204 |
* no est?n en el tama?o ajustado sino que llegan en su tama?o origina, tipicamente 256x256 p?xeles. Estos
|
205 |
* son reescalados al ir a dibujarlos sobre el Graphics.
|
206 |
* @param g
|
207 |
* @param vp
|
208 |
* @throws RasterDriverException
|
209 |
* @throws InvalidSetViewException
|
210 |
* @throws ProcessInterruptedException
|
211 |
*/
|
212 |
public void drawTiledService(Graphics2D g, ViewPortData vp, Dimension2D viewDimension) |
213 |
throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
|
214 |
|
215 |
/**
|
216 |
* <p>
|
217 |
* This method throws the draw call in a Thread. This is useful to draw tiles.
|
218 |
* </p>
|
219 |
* <p>
|
220 |
* Strategy:
|
221 |
* <ul>
|
222 |
* <li>If the image is out of the view the thread won't be thrown</li>
|
223 |
* <li>Throw the thread to draw</li>
|
224 |
* <li>The main thread waits until the secondary thread ends</li>
|
225 |
* <li>When the buffer of a new tile has been received then nextBuffer is called from the store</li>
|
226 |
* <li>When the last tile has been received then endReading is called from the store. This method unlocks the main
|
227 |
* thread and will finish the process</li>
|
228 |
* <li></li>
|
229 |
* </ul>
|
230 |
* </p>
|
231 |
*
|
232 |
* @see draw
|
233 |
*/
|
234 |
public void drawThread(Graphics2D g, ViewPortData vp); |
235 |
|
236 |
/**
|
237 |
* Sets the view structures to draw
|
238 |
* @param g
|
239 |
* @param vp
|
240 |
*/
|
241 |
public void setGraphicInfo(Graphics2D g, ViewPortData vp); |
242 |
|
243 |
public void setReading(boolean reading); |
244 |
} |