Revision 1191
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/bean/previewbase/IPreviewRenderProcess.java | ||
---|---|---|
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.raster.tools.app.basic.raster.bean.previewbase; |
|
23 |
|
|
24 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
25 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
26 |
|
|
27 |
/** |
|
28 |
* Interfaz para el procesado del rendering antes de dibujar la preview. |
|
29 |
* El cliente puede obtener la lista de filtros del rendering de la imagen |
|
30 |
* que va a dibujarse como preview y modificarla para visulizar la preview |
|
31 |
* modificada. En caso de no modificar la preview se ver? la imagen sin variaciones |
|
32 |
* con respecto a la original. |
|
33 |
* |
|
34 |
* 19/02/2008 |
|
35 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
36 |
*/ |
|
37 |
public interface IPreviewRenderProcess { |
|
38 |
|
|
39 |
/** |
|
40 |
* Procesado del rendering |
|
41 |
* @param rendering |
|
42 |
* @throws ImageUnavailable Cuando se ha producido un error y hay que mostrar un mensaje en la |
|
43 |
* previsualizaci?n porque no se puede mostrar la imagen |
|
44 |
*/ |
|
45 |
public void process(FLyrRaster lyr) throws ImageUnavailableException; |
|
46 |
|
|
47 |
/** |
|
48 |
* Obtiene el flag que informa de si se est? mostrando la previsualizaci?n o no. |
|
49 |
* En caso de no mostrarse deber?a lanzarse una excepci?n ImageUnavailableExcepcion al |
|
50 |
* hacer un process. |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
public boolean isShowPreview(); |
|
54 |
|
|
55 |
/** |
|
56 |
* Asigna el flag para mostrar u ocultar la preview. En caso de no mostrarse deber?a lanzarse una |
|
57 |
* excepci?n ImageUnavailableExcepcion cuando se hace un process. |
|
58 |
* @param showPreview |
|
59 |
*/ |
|
60 |
public void setShowPreview(boolean showPreview); |
|
61 |
} |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/bean/previewbase/PreviewBasePanel.java | ||
---|---|---|
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.raster.tools.app.basic.raster.bean.previewbase; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.util.ArrayList; |
|
28 |
|
|
29 |
import javax.swing.BorderFactory; |
|
30 |
import javax.swing.JPanel; |
|
31 |
import javax.swing.JSplitPane; |
|
32 |
import javax.swing.JTabbedPane; |
|
33 |
import javax.swing.border.Border; |
|
34 |
import javax.swing.border.TitledBorder; |
|
35 |
import javax.swing.plaf.basic.BasicSplitPaneDivider; |
|
36 |
import javax.swing.plaf.basic.BasicSplitPaneUI; |
|
37 |
|
|
38 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
39 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
40 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
41 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
42 |
import org.gvsig.gui.beans.imagenavigator.ImageNavigator; |
|
43 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
44 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
45 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
|
46 |
/** |
|
47 |
* Panel base para componentes con previsualizaci?n. |
|
48 |
* |
|
49 |
* 19/02/2008 |
|
50 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
51 |
*/ |
|
52 |
public class PreviewBasePanel extends DefaultButtonsPanel { |
|
53 |
private static final long serialVersionUID = 6028780107787443656L; |
|
54 |
|
|
55 |
private ImageNavigator imageNavigator = null; |
|
56 |
private FLyrRaster fLayer = null; |
|
57 |
|
|
58 |
/** |
|
59 |
* Lista de paneles de usuario que son a?adidos a los tabs |
|
60 |
*/ |
|
61 |
private ArrayList userPanel = new ArrayList(); |
|
62 |
/** |
|
63 |
* Panel de la base del cuadro con opciones comunes para todos los tabs |
|
64 |
*/ |
|
65 |
private JPanel generalPanel = null; |
|
66 |
/** |
|
67 |
* Panel de debajo de la vista previa |
|
68 |
*/ |
|
69 |
private JPanel downPreviewPanel = null; |
|
70 |
private IPreviewRenderProcess renderProcess = null; |
|
71 |
|
|
72 |
/** |
|
73 |
* Panel central para el caso de que sea m?s de uno (con pesta?as) |
|
74 |
*/ |
|
75 |
private JTabbedPane tabbedPane = null; |
|
76 |
/** |
|
77 |
* Panel central para el caso de que sea solo uno (sin pesta?as) |
|
78 |
*/ |
|
79 |
private JPanel mainPanel = null; |
|
80 |
|
|
81 |
private JSplitPane jPanelRight = null; |
|
82 |
private JPanel jPanelPreview = null; |
|
83 |
|
|
84 |
private PreviewRequestManager previewRequestManager = null; |
|
85 |
|
|
86 |
/** |
|
87 |
* Construir un nuevo PreviewBasePanel |
|
88 |
* @param userPanel. Lista de paneles de usuario para los tabs |
|
89 |
* @param generalPanel. Panel inferior global para todos los tabs |
|
90 |
* @param downPreviewPanel. Panel inferior al de la previsualizaci?n |
|
91 |
* @param renderProcess. Clase para procesar el raster antes del dibujado |
|
92 |
* @param lyr. Capa raster a mostrar en la previsualizaci?n |
|
93 |
*/ |
|
94 |
public PreviewBasePanel(ArrayList userPanel, |
|
95 |
JPanel generalPanel, |
|
96 |
JPanel downPreviewPanel, |
|
97 |
IPreviewRenderProcess renderProcess, |
|
98 |
FLyrRaster lyr) { |
|
99 |
this(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY, userPanel, generalPanel, downPreviewPanel, renderProcess, lyr); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Construir un nuevo PreviewBasePanel |
|
104 |
* @param buttons |
|
105 |
* @param userPanel |
|
106 |
* @param generalPanel |
|
107 |
* @param downPreviewPanel |
|
108 |
* @param renderProcess |
|
109 |
* @param lyr |
|
110 |
*/ |
|
111 |
public PreviewBasePanel(int buttons, |
|
112 |
ArrayList userPanel, |
|
113 |
JPanel generalPanel, |
|
114 |
JPanel downPreviewPanel, |
|
115 |
IPreviewRenderProcess renderProcess, |
|
116 |
FLyrRaster lyr) { |
|
117 |
super(buttons); |
|
118 |
this.userPanel = userPanel; |
|
119 |
this.generalPanel = generalPanel; |
|
120 |
this.downPreviewPanel = downPreviewPanel; |
|
121 |
this.renderProcess = renderProcess; |
|
122 |
setLayer(lyr); |
|
123 |
initialize(); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* Inicializa los componentes gr?ficos |
|
128 |
*/ |
|
129 |
private void initialize() { |
|
130 |
setLayout(new BorderLayout(8, 8)); |
|
131 |
|
|
132 |
JPanel panelLeft = new JPanel(); |
|
133 |
panelLeft.setPreferredSize(new Dimension(390, 0)); |
|
134 |
panelLeft.setLayout(new BorderLayout(8, 8)); |
|
135 |
if(userPanel != null) { |
|
136 |
if(userPanel.size() == 1) |
|
137 |
panelLeft.add(getPanelWithoutTabs(), BorderLayout.CENTER); |
|
138 |
else if(userPanel.size() > 1) |
|
139 |
panelLeft.add(getTabbedPane(), BorderLayout.CENTER); |
|
140 |
} |
|
141 |
if(generalPanel != null) |
|
142 |
panelLeft.add(getGeneralPanel(), BorderLayout.SOUTH); |
|
143 |
|
|
144 |
JSplitPane jSplitPane1 = new JSplitPane(); |
|
145 |
jSplitPane1.setLeftComponent(panelLeft); |
|
146 |
jSplitPane1.setRightComponent(getPanelRight()); |
|
147 |
jSplitPane1.setResizeWeight(1.0); |
|
148 |
jSplitPane1.setContinuousLayout(true); |
|
149 |
jSplitPane1.setUI(new BasicSplitPaneUI() { |
|
150 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
151 |
return new BasicSplitPaneDivider(this) { |
|
152 |
private static final long serialVersionUID = 1L; |
|
153 |
|
|
154 |
public void setBorder(Border b) { |
|
155 |
} |
|
156 |
}; |
|
157 |
} |
|
158 |
}); |
|
159 |
jSplitPane1.setBorder(null); |
|
160 |
|
|
161 |
add(jSplitPane1, BorderLayout.CENTER); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Asigna el panel de la posici?n 0 del array. Este panel es el que se utiliza |
|
166 |
* cuando no hay un JTabbedPane |
|
167 |
* @param panel |
|
168 |
*/ |
|
169 |
public void setUniquePanel(JPanel panel) { |
|
170 |
userPanel.clear(); |
|
171 |
userPanel.add(panel); |
|
172 |
mainPanel = panel; |
|
173 |
((JSplitPane)getContent().getComponent(0)).setLeftComponent(mainPanel); |
|
174 |
getContent().updateUI(); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Obtiene el componente con los tabs donde se a?aden las pesta?as del usuario. |
|
179 |
* @return JTabbedPane |
|
180 |
*/ |
|
181 |
public JTabbedPane getTabbedPane() { |
|
182 |
if (tabbedPane == null) { |
|
183 |
tabbedPane = new JTabbedPane(); |
|
184 |
for (int i = 0; i < userPanel.size(); i++) |
|
185 |
tabbedPane.addTab(((PreviewBasePanelTab)userPanel.get(i)).getTitle(), ((PreviewBasePanelTab)userPanel.get(i)).getPanel()); |
|
186 |
} |
|
187 |
return tabbedPane; |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Obtiene el panel central sin tabs. Esto ocurre cuando el usuario solo quiere un |
|
192 |
* panel. En este caso no hacen falta pesta?as por lo que se incorpora solo un JPanel |
|
193 |
* @return JTabbedPane |
|
194 |
*/ |
|
195 |
public JPanel getPanelWithoutTabs() { |
|
196 |
if (mainPanel == null) { |
|
197 |
if(((PreviewBasePanelTab)userPanel.get(0)) instanceof JPanel) { |
|
198 |
mainPanel = ((PreviewBasePanelTab)userPanel.get(0)).getPanel(); |
|
199 |
} else |
|
200 |
mainPanel = new JPanel(); |
|
201 |
} |
|
202 |
return mainPanel; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* Obtiene el panel con opciones comunes a todas las pesta?as. |
|
207 |
* @return JPanel |
|
208 |
*/ |
|
209 |
public JPanel getGeneralPanel() { |
|
210 |
return generalPanel; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Obtiene el panel de debajo de la vista previa |
|
215 |
* @return JPanel |
|
216 |
*/ |
|
217 |
public JPanel getDownPreviewPanel() { |
|
218 |
return downPreviewPanel; |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* Obtiene la lista de paneles de usuario |
|
223 |
* @return ArrayList de IUserPanelInterface |
|
224 |
*/ |
|
225 |
public ArrayList getUserPanels() { |
|
226 |
return userPanel; |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Obtiene el objeto IClientImageNavigator |
|
231 |
* @return |
|
232 |
*/ |
|
233 |
public IClientImageNavigator getPreviewManager() { |
|
234 |
return previewRequestManager; |
|
235 |
} |
|
236 |
|
|
237 |
/** |
|
238 |
* Devuelve el componente para la vista previa |
|
239 |
* @return |
|
240 |
*/ |
|
241 |
public ImageNavigator getImageNavigator() { |
|
242 |
if (imageNavigator == null) { |
|
243 |
imageNavigator = new ImageNavigator(getPreviewManager()); |
|
244 |
imageNavigator.setFocusable(true); |
|
245 |
imageNavigator.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
|
246 |
} |
|
247 |
return imageNavigator; |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Obtiene el panel con el componente con la vista previa |
|
252 |
* @return JPanel |
|
253 |
*/ |
|
254 |
public JPanel getPanelPreview() { |
|
255 |
if (jPanelPreview == null) { |
|
256 |
jPanelPreview = new JPanel(); |
|
257 |
JPanel jsubpanel2 = new JPanel(); |
|
258 |
jPanelPreview.setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "vista_previa"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
|
259 |
jPanelPreview.setLayout(new BorderLayout()); |
|
260 |
jsubpanel2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
|
261 |
jsubpanel2.setLayout(new BorderLayout()); |
|
262 |
|
|
263 |
jsubpanel2.add(getImageNavigator(), BorderLayout.CENTER); |
|
264 |
jPanelPreview.add(jsubpanel2, BorderLayout.CENTER); |
|
265 |
|
|
266 |
jPanelPreview.setPreferredSize(new Dimension(237, 237)); |
|
267 |
jPanelPreview.setMinimumSize(new Dimension(237, 237)); |
|
268 |
jPanelPreview.setMaximumSize(new Dimension(237, 237)); |
|
269 |
} |
|
270 |
return jPanelPreview; |
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* Devuelve el panel donde estar? el widget de preview |
|
275 |
* @return |
|
276 |
*/ |
|
277 |
private JSplitPane getPanelRight() { |
|
278 |
if (jPanelRight == null) { |
|
279 |
jPanelRight = new JSplitPane(); |
|
280 |
jPanelRight.setOrientation(JSplitPane.VERTICAL_SPLIT); |
|
281 |
jPanelRight.setContinuousLayout(true); |
|
282 |
jPanelRight.setResizeWeight(0.0); |
|
283 |
jPanelRight.setPreferredSize(new Dimension(220, 0)); |
|
284 |
jPanelRight.setMinimumSize(new Dimension(220, 0)); |
|
285 |
|
|
286 |
if(getPanelPreview() != null) |
|
287 |
jPanelRight.setTopComponent(getPanelPreview()); |
|
288 |
else |
|
289 |
jPanelRight.setTopComponent(new JPanel()); |
|
290 |
if(getDownPreviewPanel() != null) |
|
291 |
jPanelRight.setBottomComponent(getDownPreviewPanel()); |
|
292 |
else |
|
293 |
jPanelRight.setBottomComponent(new JPanel()); |
|
294 |
jPanelRight.setUI(new BasicSplitPaneUI() { |
|
295 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
296 |
return new BasicSplitPaneDivider(this) { |
|
297 |
private static final long serialVersionUID = 1L; |
|
298 |
|
|
299 |
public void setBorder(Border b) { |
|
300 |
} |
|
301 |
}; |
|
302 |
} |
|
303 |
}); |
|
304 |
jPanelRight.setBorder(null); |
|
305 |
} |
|
306 |
return jPanelRight; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* Especificar la capa para la previsualizaci?n |
|
311 |
* @param layer |
|
312 |
*/ |
|
313 |
public void setLayer(FLyrRaster fLayer) { |
|
314 |
this.fLayer = fLayer; |
|
315 |
previewRequestManager = new PreviewRequestManager(this, renderProcess, fLayer); |
|
316 |
|
|
317 |
// Util para ejecutar el test sin una capa de prueba |
|
318 |
if (fLayer == null) |
|
319 |
return; |
|
320 |
|
|
321 |
// Especificar las dimensiones de la capa en la vista previa |
|
322 |
Extent extent2 = fLayer.getFullRasterExtent();//.getBufferFactory().getDataSource().getExtent(); |
|
323 |
getImageNavigator().setViewDimensions(extent2.getMin().getX(), extent2.getMax().getY(), extent2.getMax().getX(), extent2.getMin().getY()); |
|
324 |
getImageNavigator().setZoom(1.0/ fLayer.getDataStore().getCellSize()); |
|
325 |
getImageNavigator().setAutoAdjusted(); |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* Especificar el layer para el recorte |
|
330 |
* @param layer |
|
331 |
*/ |
|
332 |
public FLyrRaster getLayer() { |
|
333 |
return fLayer; |
|
334 |
} |
|
335 |
|
|
336 |
/** |
|
337 |
* Especifica el tama?o de la vista previa |
|
338 |
* @param dimension |
|
339 |
*/ |
|
340 |
public void setPreviewSize(Dimension dimension) { |
|
341 |
getPanelPreview().setPreferredSize(dimension); |
|
342 |
getPanelPreview().setMinimumSize(dimension); |
|
343 |
getPanelPreview().setMaximumSize(dimension); |
|
344 |
} |
|
345 |
|
|
346 |
/** |
|
347 |
* Actualizamos la vista previa |
|
348 |
*/ |
|
349 |
public void refreshPreview() { |
|
350 |
if (fLayer == null) |
|
351 |
return; |
|
352 |
getImageNavigator().updateBuffer(); |
|
353 |
} |
|
354 |
|
|
355 |
} |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/bean/previewbase/PreviewRequestManager.java | ||
---|---|---|
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.raster.tools.app.basic.raster.bean.previewbase; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
|
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
29 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
30 |
import org.gvsig.fmap.geom.GeometryManager; |
|
31 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
32 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
33 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
34 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
35 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
36 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
37 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
38 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
39 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Gestor de visualizaci?n de preview. Se encarga del repintado de la imagen |
|
46 |
* de la previsualizaci?n |
|
47 |
* |
|
48 |
* 19/02/2008 |
|
49 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
50 |
*/ |
|
51 |
public class PreviewRequestManager implements IClientImageNavigator { |
|
52 |
private static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
53 |
private static final Logger logger = LoggerFactory.getLogger(PreviewRequestManager.class); |
|
54 |
private PreviewBasePanel previewBasePanel = null; |
|
55 |
private FLyrRaster previewLayer = null; |
|
56 |
private IPreviewRenderProcess renderProcess = null; |
|
57 |
|
|
58 |
/** |
|
59 |
* Construye un ColorTableListener |
|
60 |
* @param |
|
61 |
*/ |
|
62 |
public PreviewRequestManager( PreviewBasePanel panel, |
|
63 |
IPreviewRenderProcess renderProcess, |
|
64 |
FLyrRaster layer) { |
|
65 |
this.previewBasePanel = panel; |
|
66 |
this.renderProcess = renderProcess; |
|
67 |
setLayer(layer); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Asigna la capa raster de la vista |
|
72 |
* @param fLayer |
|
73 |
*/ |
|
74 |
private void setLayer(FLyrRaster fLayer) { |
|
75 |
if (fLayer instanceof IRasterLayerActions) { |
|
76 |
IRasterLayerActions ly = (IRasterLayerActions) fLayer; |
|
77 |
try { |
|
78 |
//Este c?digo no va bien pq la preview siempre tiene el extent global y el ?ltimo fichero |
|
79 |
//puede ser de un zoom |
|
80 |
/*if(ly.isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS)) |
|
81 |
previewLayer = (FLyrRaster)fLayer.getFileLayer(); |
|
82 |
else*/ |
|
83 |
previewLayer = (FLyrRaster) fLayer.cloneLayer(); |
|
84 |
} catch (Exception e) { |
|
85 |
RasterToolsUtil.messageBoxError("preview_not_available", previewBasePanel, e); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Cierra la capa abierta para previsualizaci?n |
|
92 |
*/ |
|
93 |
public void closePreviewLayer() { |
|
94 |
if (previewLayer != null) { |
|
95 |
previewLayer.setRemoveRasterFlag(true); |
|
96 |
previewLayer.removeLayerListener(null); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* (non-Javadoc) |
|
102 |
* @see org.gvsig.gui.beans.imagenavigator.IClientImageNavigator#drawImage(java.awt.Graphics2D, |
|
103 |
* double, double, double, double, double, int, int) |
|
104 |
*/ |
|
105 |
public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) |
|
106 |
throws ImageUnavailableException { |
|
107 |
if (previewLayer == null) |
|
108 |
throw new ImageUnavailableException(PluginServices.getText(this, "error_dont_exists_layer")); |
|
109 |
|
|
110 |
|
|
111 |
// Inicializo el ViewPort |
|
112 |
ViewPort vp = new ViewPort(null); |
|
113 |
Envelope env; |
|
114 |
try { |
|
115 |
env = geomManager.createEnvelope(x1, y2, x2, y1, SUBTYPES.GEOM2D); |
|
116 |
vp.setEnvelope(env); |
|
117 |
} catch (CreateEnvelopeException e3) { |
|
118 |
logger.error("Error drawing the image", e3); |
|
119 |
} |
|
120 |
vp.setImageSize(new Dimension(width, height)); |
|
121 |
|
|
122 |
previewLayer.getRender().getFilterList().pushStatus(); |
|
123 |
try { |
|
124 |
renderProcess.process(previewLayer); |
|
125 |
} catch (ImageUnavailableException e2) { |
|
126 |
throw new ImageUnavailableException(PluginServices.getText(this, "error_adding_filters")); |
|
127 |
} catch (Exception e2) { |
|
128 |
RasterToolsUtil.debug("error_adding_filters", this, e2); |
|
129 |
throw new ImageUnavailableException(PluginServices.getText(this, "error_adding_filters")); |
|
130 |
} |
|
131 |
|
|
132 |
try { |
|
133 |
previewLayer.draw(null, g, vp, null, 1.0); |
|
134 |
} catch (ReadException e) { |
|
135 |
RasterToolsUtil.debug("error_preview_render", this, e); |
|
136 |
throw new ImageUnavailableException(PluginServices.getText(this, "error_preview_render")); |
|
137 |
} catch (Exception e2) { |
|
138 |
RasterToolsUtil.debug("error_preview_render", this, e2); |
|
139 |
throw new ImageUnavailableException(PluginServices.getText(this, "error_preview_render")); |
|
140 |
} |
|
141 |
previewLayer.getRender().getFilterList().popStatus(); |
|
142 |
} |
|
143 |
} |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/bean/previewbase/RasterDataSourcePreview.java | ||
---|---|---|
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.raster.tools.app.basic.raster.bean.previewbase; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.awt.image.BufferedImage; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
30 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
31 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
32 |
import org.gvsig.fmap.geom.GeometryManager; |
|
33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
34 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
35 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
36 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
37 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
38 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
39 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
40 |
import org.gvsig.tools.task.Cancellable; |
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
/** |
|
45 |
* Source for a preview using a raster layer |
|
46 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
47 |
*/ |
|
48 |
public class RasterDataSourcePreview implements DataSourcePreview { |
|
49 |
private FLyrRaster lyr = null; |
|
50 |
private static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
51 |
private static final Logger logger = LoggerFactory.getLogger(RasterDataSourcePreview.class); |
|
52 |
|
|
53 |
public RasterDataSourcePreview(FLyrRaster lyr) { |
|
54 |
this.lyr = lyr; |
|
55 |
} |
|
56 |
|
|
57 |
public void closePreviewLayer() { |
|
58 |
if (lyr != null) { |
|
59 |
lyr.setRemoveRasterFlag(true); |
|
60 |
lyr.removeLayerListener(null); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
public Rectangle2D getBBoxRectangle() { |
|
65 |
Extent e = lyr.getFullRasterExtent(); |
|
66 |
return e.toRectangle2D(); |
|
67 |
} |
|
68 |
|
|
69 |
public double getCellSize() { |
|
70 |
return lyr.getDataStore().getCellSize(); |
|
71 |
} |
|
72 |
|
|
73 |
public DataSourcePreview cloneDataSourcePreview() { |
|
74 |
if(lyr != null) { |
|
75 |
try { |
|
76 |
return new RasterDataSourcePreview((FLyrRaster)lyr.cloneLayer()); |
|
77 |
} catch (Exception e) { |
|
78 |
} |
|
79 |
} |
|
80 |
return null; |
|
81 |
} |
|
82 |
|
|
83 |
public void popStatus() { |
|
84 |
if (lyr != null) |
|
85 |
lyr.getRender().getFilterList().popStatus(); |
|
86 |
} |
|
87 |
|
|
88 |
public void pushStatus() { |
|
89 |
if (lyr != null) |
|
90 |
lyr.getRender().getFilterList().pushStatus(); |
|
91 |
} |
|
92 |
|
|
93 |
public void draw(BufferedImage image, Graphics2D g, double[] coords, int w, int h, Cancellable cancel, double scale) throws ImageUnavailableException { |
|
94 |
try { |
|
95 |
// Inicializo el ViewPort |
|
96 |
ViewPort vp = new ViewPort(null); |
|
97 |
Envelope env; |
|
98 |
try { |
|
99 |
env = geomManager.createEnvelope(coords[0], coords[3], coords[2], coords[1], SUBTYPES.GEOM2D); |
|
100 |
vp.setEnvelope(env); |
|
101 |
} catch (CreateEnvelopeException e3) { |
|
102 |
logger.error("Error drawing the image", e3); |
|
103 |
} |
|
104 |
vp.setImageSize(new Dimension(w, h)); |
|
105 |
|
|
106 |
if (lyr != null) |
|
107 |
lyr.draw(image, g, vp, cancel, scale); |
|
108 |
} catch (ReadException e) { |
|
109 |
throw new ImageUnavailableException("Error drawing raster"); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
public Object getSource() { |
|
114 |
return lyr; |
|
115 |
} |
|
116 |
|
|
117 |
} |
|
0 | 118 |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/enhanced/ui/EnhancedDialog.java | ||
---|---|---|
22 | 22 |
package org.gvsig.raster.tools.app.basic.tool.enhanced.ui; |
23 | 23 |
|
24 | 24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Component; |
|
25 | 26 |
import java.awt.Dimension; |
26 | 27 |
import java.awt.GridBagConstraints; |
27 | 28 |
import java.awt.GridBagLayout; |
... | ... | |
35 | 36 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
36 | 37 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
37 | 38 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
39 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
40 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
41 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
38 | 42 |
import org.gvsig.raster.tools.app.basic.raster.bean.createlayer.CreateLayerPanel; |
39 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.PreviewBasePanel;
|
|
43 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.RasterDataSourcePreview;
|
|
40 | 44 |
|
41 | 45 |
/** |
42 | 46 |
* Dialogo para el realce por expansi?n del contraste |
... | ... | |
47 | 51 |
public class EnhancedDialog extends JPanel implements IWindow { |
48 | 52 |
private static final long serialVersionUID = -5374834293534046986L; |
49 | 53 |
|
50 |
private PreviewBasePanel previewBasePanel = null;
|
|
54 |
private PreviewPanel previewBasePanel = null;
|
|
51 | 55 |
private GraphicsPanel graphicsPanel = null; |
52 | 56 |
private FLyrRaster lyr = null; |
53 | 57 |
private PreviewFiltering filteredPreview = null; |
... | ... | |
74 | 78 |
filteredPreview.setFilterStatus(this.lyr.getRender().getFilterList().getStatusCloned()); |
75 | 79 |
controlsPanel = new SelectorsPanel(this.lyr, graphicsPanel.getInputHistogram()); |
76 | 80 |
|
77 |
this.add(getPreviewBasePanel(), BorderLayout.CENTER); |
|
81 |
this.add((Component)getPreviewBasePanel(), BorderLayout.CENTER);
|
|
78 | 82 |
|
79 | 83 |
listener = new EnhancedListener(controlsPanel, graphicsPanel, this, filteredPreview); |
80 | 84 |
|
... | ... | |
100 | 104 |
* Obtiene el panel con el histograma |
101 | 105 |
* @return HistogramPanel |
102 | 106 |
*/ |
103 |
public PreviewBasePanel getPreviewBasePanel() {
|
|
107 |
public PreviewPanel getPreviewBasePanel() { |
|
104 | 108 |
if (previewBasePanel == null) { |
105 |
ArrayList<GraphicsPanel> list = new ArrayList<GraphicsPanel>();
|
|
106 |
list.add(graphicsPanel); |
|
109 |
ArrayList<PreviewBasePanelTab> list = new ArrayList<PreviewBasePanelTab>();
|
|
110 |
list.add((PreviewBasePanelTab)graphicsPanel);
|
|
107 | 111 |
|
108 | 112 |
JPanel downPreview = new JPanel(); |
109 | 113 |
getNewOrSaveLayerPanel().setLabelFilename(""); |
... | ... | |
122 | 126 |
gridBagConstraints.weighty = 1.0; |
123 | 127 |
downPreview.add(getNewOrSaveLayerPanel().getFileNamePanel(), gridBagConstraints); |
124 | 128 |
|
125 |
previewBasePanel = new PreviewBasePanel(ButtonsPanel.BUTTONS_APPLYCLOSE, list, controlsPanel, downPreview, filteredPreview, lyr); |
|
129 |
RasterDataSourcePreview dataSourcePreview = new RasterDataSourcePreview(lyr); |
|
130 |
previewBasePanel = RasterSwingLocator.getSwingManager().createPreviewPanel( |
|
131 |
ButtonsPanel.BUTTONS_APPLYCLOSE, |
|
132 |
list, |
|
133 |
controlsPanel, |
|
134 |
downPreview, |
|
135 |
filteredPreview, |
|
136 |
dataSourcePreview); |
|
126 | 137 |
previewBasePanel.getButtonsPanel().addCancel(); |
127 | 138 |
} |
128 | 139 |
return previewBasePanel; |
... | ... | |
165 | 176 |
*/ |
166 | 177 |
public WindowInfo getWindowInfo() { |
167 | 178 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE); |
168 |
if(getPreviewBasePanel().getLayer() != null) |
|
169 |
m_viewinfo.setAdditionalInfo(getPreviewBasePanel().getLayer().getName()); |
|
179 |
if(getPreviewBasePanel().getDataSourcePreview().getSource() != null) { |
|
180 |
FLyrRaster lyr = (FLyrRaster)getPreviewBasePanel().getDataSourcePreview().getSource(); |
|
181 |
m_viewinfo.setAdditionalInfo(lyr.getName()); |
|
182 |
} |
|
170 | 183 |
m_viewinfo.setTitle(PluginServices.getText(this, "enhanced")); |
171 | 184 |
m_viewinfo.setHeight(this.getHeight()); |
172 | 185 |
m_viewinfo.setWidth(this.getWidth()); |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/enhanced/ui/PreviewFiltering.java | ||
---|---|---|
33 | 33 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
34 | 34 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
35 | 35 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
36 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
37 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
36 | 38 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
37 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.IPreviewRenderProcess; |
|
38 | 39 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.ParamStruct; |
39 | 40 |
|
40 | 41 |
/** |
... | ... | |
47 | 48 |
* 19/02/2008 |
48 | 49 |
* @author Nacho Brodin nachobrodin@gmail.com |
49 | 50 |
*/ |
50 |
public class PreviewFiltering implements IPreviewRenderProcess {
|
|
51 |
public class PreviewFiltering implements PreviewRenderProcess { |
|
51 | 52 |
|
52 | 53 |
private boolean showFiltersSelected = true; |
53 | 54 |
private ArrayList<ParamStruct> paramsList = new ArrayList<ParamStruct>(); |
... | ... | |
120 | 121 |
* de construir la lista. |
121 | 122 |
*/ |
122 | 123 |
@SuppressWarnings("unchecked") |
123 |
public void process(FLyrRaster rendering) throws ImageUnavailableException {
|
|
124 |
public void process(DataSourcePreview rendering) throws ImageUnavailableException {
|
|
124 | 125 |
if(!showPreview) |
125 | 126 |
throw new ImageUnavailableException(RasterToolsUtil.getText(this, "panel_preview_not_available")); |
126 | 127 |
|
127 |
rendering.getRender().getFilterList().clear(); |
|
128 |
if(!(rendering.getSource() instanceof FLyrRaster)) |
|
129 |
return; |
|
130 |
FLyrRaster lyr = (FLyrRaster)rendering.getSource(); |
|
131 |
|
|
132 |
lyr.getRender().getFilterList().clear(); |
|
128 | 133 |
|
129 | 134 |
if (showFiltersSelected) { |
130 |
RasterFilterList filterList = rendering.getRender().getFilterList();
|
|
131 |
filterList.setInitDataType(rendering.getDataStore().getDataType()[0]);
|
|
135 |
RasterFilterList filterList = lyr.getRender().getFilterList();
|
|
136 |
filterList.setInitDataType(lyr.getDataStore().getDataType()[0]);
|
|
132 | 137 |
|
133 |
ArrayList<ParamStruct> listFilterUsed = applyFilters(rendering);
|
|
138 |
ArrayList<ParamStruct> listFilterUsed = applyFilters(lyr);
|
|
134 | 139 |
ArrayList<Exception> exc = new ArrayList<Exception>(); |
135 | 140 |
for (int i = 0; i < listFilterUsed.size(); i++) { |
136 | 141 |
try { |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/filter/ui/FilterDialog.java | ||
---|---|---|
31 | 31 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
32 | 32 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
33 | 33 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
34 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.PreviewRequestManager; |
|
35 | 34 |
|
36 | 35 |
/** |
37 | 36 |
* Dialogo para los filtros de raster. |
... | ... | |
118 | 117 |
} |
119 | 118 |
|
120 | 119 |
if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) { |
121 |
((PreviewRequestManager)getFilterPanel().getPreviewBasePanel().getPreviewManager()).closePreviewLayer();
|
|
120 |
getFilterPanel().getPreviewBasePanel().closePreviewLayer();
|
|
122 | 121 |
close(); |
123 | 122 |
} |
124 | 123 |
} |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/filter/ui/FilterPanel.java | ||
---|---|---|
19 | 19 |
package org.gvsig.raster.tools.app.basic.tool.filter.ui; |
20 | 20 |
|
21 | 21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Component; |
|
22 | 23 |
import java.awt.Dimension; |
23 | 24 |
import java.awt.GridBagConstraints; |
24 | 25 |
import java.awt.GridBagLayout; |
... | ... | |
45 | 46 |
import org.gvsig.gui.beans.propertiespanel.PropertiesComponent; |
46 | 47 |
import org.gvsig.gui.beans.treelist.TreeListContainer; |
47 | 48 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
49 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
50 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
51 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
52 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
53 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
48 | 54 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
49 | 55 |
import org.gvsig.raster.tools.app.basic.raster.bean.createlayer.CreateLayerPanel; |
50 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.IPreviewRenderProcess; |
|
51 | 56 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.ParamStruct; |
52 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.PreviewBasePanel;
|
|
57 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.RasterDataSourcePreview;
|
|
53 | 58 |
import org.gvsig.raster.tools.app.basic.tool.filter.FilterListener; |
54 | 59 |
import org.gvsig.raster.util.LayerVisualStatusList; |
55 | 60 |
|
... | ... | |
60 | 65 |
* @author Nacho Brodin <brodin_ign@gva.es> |
61 | 66 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
62 | 67 |
*/ |
63 |
public class FilterPanel extends JPanel implements IPreviewRenderProcess {
|
|
68 |
public class FilterPanel extends JPanel implements PreviewRenderProcess { |
|
64 | 69 |
private static final long serialVersionUID = 7152780112689637266L; |
65 | 70 |
|
66 |
private PreviewBasePanel previewBasePanel = null;
|
|
71 |
private PreviewPanel previewBasePanel = null;
|
|
67 | 72 |
private FLyrRaster layer = null; |
68 | 73 |
private FilterListener filterListener = null; |
69 | 74 |
private PropertiesComponent propertiesComponent = null; |
... | ... | |
91 | 96 |
private void initialize() { |
92 | 97 |
translate(); |
93 | 98 |
setLayout(new BorderLayout()); |
94 |
add(getPreviewBasePanel(), BorderLayout.CENTER); |
|
99 |
add((Component)getPreviewBasePanel(), BorderLayout.CENTER);
|
|
95 | 100 |
} |
96 | 101 |
|
97 | 102 |
/** |
... | ... | |
105 | 110 |
* Obtiene el panel con el histograma |
106 | 111 |
* @return HistogramPanel |
107 | 112 |
*/ |
108 |
public PreviewBasePanel getPreviewBasePanel() {
|
|
113 |
public PreviewPanel getPreviewBasePanel() { |
|
109 | 114 |
if (previewBasePanel == null) { |
110 |
ArrayList<Object> list = new ArrayList<Object>();
|
|
115 |
ArrayList<PreviewBasePanelTab> list = new ArrayList<PreviewBasePanelTab>();
|
|
111 | 116 |
list.add(getMainPanel()); |
112 |
previewBasePanel = new PreviewBasePanel(ButtonsPanel.BUTTONS_APPLYCLOSE, list, null, panelOptions(), this, (FLyrRaster) layer); |
|
117 |
RasterDataSourcePreview source = new RasterDataSourcePreview((FLyrRaster)layer); |
|
118 |
previewBasePanel = RasterSwingLocator.getSwingManager().createPreviewPanel( |
|
119 |
ButtonsPanel.BUTTONS_APPLYCLOSE, |
|
120 |
list, |
|
121 |
null, |
|
122 |
panelOptions(), |
|
123 |
this, |
|
124 |
source); |
|
113 | 125 |
previewBasePanel.getButtonsPanel().addCancel(); |
114 | 126 |
previewBasePanel.setPreviewSize(new Dimension(230, 215)); |
115 | 127 |
previewBasePanel.addButtonPressedListener(filterDialog); |
... | ... | |
292 | 304 |
return; |
293 | 305 |
|
294 | 306 |
this.layer = layer; |
295 |
getPreviewBasePanel().setLayer(layer); |
|
307 |
RasterDataSourcePreview source = new RasterDataSourcePreview(layer); |
|
308 |
getPreviewBasePanel().setLayer(source); |
|
296 | 309 |
|
297 | 310 |
// Construimos el arbol de filtros |
298 | 311 |
menuBuild(); |
... | ... | |
465 | 478 |
* (non-Javadoc) |
466 | 479 |
* @see org.gvsig.raster.beans.previewbase.IPreviewRenderProcess#process(org.gvsig.raster.hierarchy.IRasterRendering) |
467 | 480 |
*/ |
468 |
public void process(FLyrRaster rendering) throws ImageUnavailableException {
|
|
481 |
public void process(DataSourcePreview rendering) throws ImageUnavailableException {
|
|
469 | 482 |
if(!showPreview) |
470 | 483 |
throw new ImageUnavailableException(RasterToolsUtil.getText(this, "panel_preview_not_available")); |
471 | 484 |
|
472 |
getFilterListener().drawImage(rendering);
|
|
485 |
getFilterListener().drawImage((FLyrRaster)rendering.getSource());
|
|
473 | 486 |
} |
474 | 487 |
|
475 | 488 |
/** |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/colortable/ui/ColorTableListener.java | ||
---|---|---|
41 | 41 |
import org.gvsig.fmap.dal.coverage.util.PropertyListener; |
42 | 42 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
43 | 43 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
44 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
45 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
44 | 46 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
45 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.IPreviewRenderProcess; |
|
46 | 47 |
import org.gvsig.raster.tools.app.basic.tool.colortable.data.ColorTableData; |
47 | 48 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.library.ColorTableLibraryPanel; |
48 | 49 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.tabs.ColorTableUIListener; |
... | ... | |
55 | 56 |
* @version 27/06/2007 |
56 | 57 |
* @author BorSanZa - Borja S๏ฟฝnchez Zamorano (borja.sanchez@iver.es) |
57 | 58 |
*/ |
58 |
public class ColorTableListener implements PropertyListener, ColorTableUIListener, IPreviewRenderProcess {
|
|
59 |
public class ColorTableListener implements PropertyListener, ColorTableUIListener, PreviewRenderProcess { |
|
59 | 60 |
private ColorTablePanel colorTablePanel = null; |
60 | 61 |
private FLyrRaster previewLayer = null; |
61 | 62 |
private ColorTableData colorTableData = null; |
... | ... | |
350 | 351 |
//getLastColorTableUI().setColorTable(getColorTableData().getColorTable()); |
351 | 352 |
} |
352 | 353 |
|
353 |
public void process(FLyrRaster rendering) throws ImageUnavailableException {
|
|
354 |
public void process(DataSourcePreview rendering) throws ImageUnavailableException {
|
|
354 | 355 |
if(!showPreview) |
355 | 356 |
throw new ImageUnavailableException(RasterToolsUtil.getText(this, "panel_preview_not_available")); |
356 | 357 |
|
357 | 358 |
// rendering.getRenderFilterList().pushStatus(); |
358 | 359 |
try { |
359 |
applyColorTable(rendering, true); |
|
360 |
if(!(rendering.getSource() instanceof FLyrRaster)) |
|
361 |
return; |
|
362 |
FLyrRaster lyr = (FLyrRaster)rendering.getSource(); |
|
363 |
applyColorTable(lyr, true); |
|
360 | 364 |
} catch (FilterTypeException e1) { |
361 | 365 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_adding_filters"), this, e1); |
362 | 366 |
} catch (FilterManagerException e) { |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/colortable/ui/ColorTablePanel.java | ||
---|---|---|
44 | 44 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
45 | 45 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
46 | 46 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
47 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
48 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
49 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
50 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
47 | 51 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
48 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.PreviewBasePanel;
|
|
52 |
import org.gvsig.raster.tools.app.basic.raster.bean.previewbase.RasterDataSourcePreview;
|
|
49 | 53 |
import org.gvsig.raster.tools.app.basic.tool.colortable.data.ColorTableData; |
50 | 54 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.library.ColorTableLibraryEvent; |
51 | 55 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.library.ColorTableLibraryListener; |
... | ... | |
76 | 80 |
private JPanel jPanelListView = null; |
77 | 81 |
private ColorTableGlobalPanel panelGeneral = null; |
78 | 82 |
private ColorTableDialog colorTableDialog = null; |
79 |
private PreviewBasePanel previewBasePanel = null;
|
|
83 |
private PreviewPanel previewBasePanel = null;
|
|
80 | 84 |
|
81 | 85 |
/** |
82 | 86 |
* Controla si se ha presionado el boton aceptar para el cerrado de la ventana |
... | ... | |
94 | 98 |
setLayer(layer); |
95 | 99 |
} |
96 | 100 |
|
97 |
public PreviewBasePanel getPreviewBasePanel() {
|
|
101 |
public PreviewPanel getPreviewBasePanel() { |
|
98 | 102 |
if (previewBasePanel == null) { |
99 |
ArrayList<IColorTableUI> list = new ArrayList<IColorTableUI>();
|
|
100 |
list.add(getTabTable()); |
|
101 |
list.add(getTabInterpolated()); |
|
103 |
ArrayList<PreviewBasePanelTab> list = new ArrayList<PreviewBasePanelTab>();
|
|
104 |
list.add((PreviewBasePanelTab)getTabTable());
|
|
105 |
list.add((PreviewBasePanelTab)getTabInterpolated());
|
|
102 | 106 |
getColorTableListener().setLastColorTableUI(getTabTable()); |
107 |
RasterDataSourcePreview previewDataSource = new RasterDataSourcePreview(fLayer); |
|
103 | 108 |
|
104 |
previewBasePanel = new PreviewBasePanel(ButtonsPanel.BUTTONS_NONE, list, (JPanel) getGeneralPanel(), getPanelListView(), getColorTableListener(), (FLyrRaster) fLayer); |
|
109 |
previewBasePanel = RasterSwingLocator.getSwingManager().createPreviewPanel( |
|
110 |
ButtonsPanel.BUTTONS_NONE, |
|
111 |
list, |
|
112 |
(JPanel) getGeneralPanel(), |
|
113 |
getPanelListView(), |
|
114 |
(PreviewRenderProcess)getColorTableListener(), |
|
115 |
previewDataSource); |
|
105 | 116 |
previewBasePanel.getTabbedPane().addChangeListener(this); |
106 | 117 |
previewBasePanel.getButtonsPanel().addButton(RasterToolsUtil.getText(this, "equidistar"), ButtonsPanel.BUTTON_LAST + 3); |
107 | 118 |
previewBasePanel.getButtonsPanel().addButton(RasterToolsUtil.getText(this, "guardar_predeterminado"), ButtonsPanel.BUTTON_LAST + 2); |
... | ... | |
116 | 127 |
|
117 | 128 |
private void initialize() { |
118 | 129 |
setLayout(new BorderLayout()); |
119 |
add(getPreviewBasePanel(), BorderLayout.CENTER); |
|
130 |
add((JPanel)getPreviewBasePanel(), BorderLayout.CENTER);
|
|
120 | 131 |
} |
121 | 132 |
|
122 | 133 |
private IColorTableUI getTabTable() { |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/DataSourcePreview.java | ||
---|---|---|
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.raster.swing.preview; |
|
23 |
|
|
24 |
import java.awt.Graphics2D; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.awt.image.BufferedImage; |
|
27 |
|
|
28 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
29 |
import org.gvsig.tools.task.Cancellable; |
|
30 |
|
|
31 |
/** |
|
32 |
* Data source for the raster preview |
|
33 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
34 |
*/ |
|
35 |
@SuppressWarnings("deprecation") |
|
36 |
public interface DataSourcePreview { |
|
37 |
|
|
38 |
public void draw(BufferedImage image, Graphics2D g, double[] coords, int w, int h, Cancellable cancel, double scale) throws ImageUnavailableException; |
|
39 |
|
|
40 |
public Rectangle2D getBBoxRectangle(); |
|
41 |
|
|
42 |
public double getCellSize(); |
|
43 |
|
|
44 |
public void closePreviewLayer(); |
|
45 |
|
|
46 |
public void pushStatus(); |
|
47 |
|
|
48 |
public void popStatus(); |
|
49 |
|
|
50 |
public DataSourcePreview cloneDataSourcePreview(); |
|
51 |
|
|
52 |
public Object getSource(); |
|
53 |
} |
|
0 | 54 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/PreviewRenderProcess.java | ||
---|---|---|
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.raster.swing.preview; |
|
23 |
|
|
24 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
25 |
|
|
26 |
/** |
|
27 |
* Interfaz para el procesado del rendering antes de dibujar la preview. |
|
28 |
* El cliente puede obtener la lista de filtros del rendering de la imagen |
|
29 |
* que va a dibujarse como preview y modificarla para visulizar la preview |
|
30 |
* modificada. En caso de no modificar la preview se ver? la imagen sin variaciones |
|
31 |
* con respecto a la original. |
|
32 |
* |
|
33 |
* 19/02/2008 |
|
34 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
35 |
*/ |
|
36 |
public interface PreviewRenderProcess { |
|
37 |
|
|
38 |
/** |
|
39 |
* Procesado del rendering |
|
40 |
* @param rendering |
|
41 |
* @throws ImageUnavailable Cuando se ha producido un error y hay que mostrar un mensaje en la |
|
42 |
* previsualizaci?n porque no se puede mostrar la imagen |
|
43 |
*/ |
|
44 |
public void process(DataSourcePreview lyr) throws ImageUnavailableException; |
|
45 |
|
|
46 |
/** |
|
47 |
* Obtiene el flag que informa de si se est? mostrando la previsualizaci?n o no. |
|
48 |
* En caso de no mostrarse deber?a lanzarse una excepci?n ImageUnavailableExcepcion al |
|
49 |
* hacer un process. |
|
50 |
* @return |
|
51 |
*/ |
|
52 |
public boolean isShowPreview(); |
|
53 |
|
|
54 |
/** |
|
55 |
* Asigna el flag para mostrar u ocultar la preview. En caso de no mostrarse deber?a lanzarse una |
|
56 |
* excepci?n ImageUnavailableExcepcion cuando se hace un process. |
|
57 |
* @param showPreview |
|
58 |
*/ |
|
59 |
public void setShowPreview(boolean showPreview); |
|
60 |
} |
|
0 | 61 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/PreviewPanel.java | ||
---|---|---|
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.raster.swing.preview; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
|
|
26 |
import javax.swing.JTabbedPane; |
|
27 |
|
|
28 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
29 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
30 |
import org.gvsig.gui.beans.imagenavigator.ImageNavigator; |
|
31 |
|
|
32 |
/** |
|
33 |
* Base interface for panels with preview |
|
34 |
* |
|
35 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
36 |
*/ |
|
37 |
public interface PreviewPanel { |
|
38 |
|
|
39 |
/** |
|
40 |
* Gets the data source of the preview |
|
41 |
* @return |
|
42 |
*/ |
|
43 |
public DataSourcePreview getDataSourcePreview(); |
|
44 |
|
|
45 |
/** |
|
46 |
* Obtiene el componente con los tabs donde se a?aden las pesta?as del usuario. |
|
47 |
* @return JTabbedPane |
|
48 |
*/ |
|
49 |
public JTabbedPane getTabbedPane(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>. |
|
53 |
* En caso de no estar creado, lo crear?. |
|
54 |
* |
|
55 |
* @return El componente bp |
|
56 |
*/ |
|
57 |
public ButtonsPanel getButtonsPanel(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Devuelve el componente para la vista previa |
|
61 |
* @return |
|
62 |
*/ |
|
63 |
public ImageNavigator getImageNavigator(); |
|
64 |
|
|
65 |
/** |
|
66 |
* Preview refresh |
|
67 |
*/ |
|
68 |
public void refreshPreview(); |
|
69 |
|
|
70 |
public void addButtonPressedListener(ButtonsPanelListener listener); |
|
71 |
|
|
72 |
/** |
|
73 |
* Sets the size of the preview |
|
74 |
* @param dimension |
|
75 |
*/ |
|
76 |
public void setPreviewSize(Dimension dimension); |
|
77 |
|
|
78 |
/** |
|
79 |
* Especificar la capa para la previsualizaci?n |
|
80 |
* @param layer |
|
81 |
*/ |
|
82 |
public void setLayer(DataSourcePreview fLayer); |
|
83 |
|
|
84 |
/** |
|
85 |
* Cierra la capa abierta para previsualizaci?n |
|
86 |
*/ |
|
87 |
public void closePreviewLayer(); |
|
88 |
} |
|
0 | 89 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterSwingManager.java | ||
---|---|---|
22 | 22 |
package org.gvsig.raster.swing; |
23 | 23 |
|
24 | 24 |
import java.awt.Color; |
25 |
import java.util.ArrayList; |
|
25 | 26 |
|
27 |
import javax.swing.JPanel; |
|
28 |
|
|
26 | 29 |
import org.gvsig.raster.swing.gcanvas.GCanvas; |
30 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
31 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
32 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
33 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
27 | 34 |
|
28 | 35 |
|
29 | 36 |
/** |
... | ... | |
75 | 82 |
*/ |
76 | 83 |
public GCanvas createGraphicCanvas(Color backgroundColor); |
77 | 84 |
|
85 |
/** |
|
86 |
* Creates a preview panel using a data source, a render process and a list |
|
87 |
* of panels |
|
88 |
* @param buttons |
|
89 |
* @param list |
|
90 |
* @param generalPanel |
|
91 |
* @param downPreviewPanel |
|
92 |
* @param renderProcess |
|
93 |
* @param dataSource |
|
94 |
* @return |
|
95 |
*/ |
|
96 |
public PreviewPanel createPreviewPanel(int buttons, |
|
97 |
ArrayList list, |
|
98 |
JPanel generalPanel, |
|
99 |
JPanel downPreviewPanel, |
|
100 |
PreviewRenderProcess renderProcess, |
|
101 |
DataSourcePreview dataSource); |
|
102 |
|
|
78 | 103 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/DefaultRasterSwingManager.java | ||
---|---|---|
22 | 22 |
package org.gvsig.raster.swing.impl; |
23 | 23 |
|
24 | 24 |
import java.awt.Color; |
25 |
import java.util.ArrayList; |
|
25 | 26 |
|
27 |
import javax.swing.JPanel; |
|
28 |
|
|
26 | 29 |
import org.gvsig.raster.swing.BasePanel; |
27 | 30 |
import org.gvsig.raster.swing.RasterSwingManager; |
28 | 31 |
import org.gvsig.raster.swing.RasterWindowManager; |
29 | 32 |
import org.gvsig.raster.swing.gcanvas.GCanvas; |
30 | 33 |
import org.gvsig.raster.swing.impl.canvas.DefaultGCanvas; |
34 |
import org.gvsig.raster.swing.impl.preview.PreviewBasePanel; |
|
35 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
36 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
37 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
38 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
31 | 39 |
import org.gvsig.tools.ToolsLocator; |
32 | 40 |
import org.gvsig.tools.i18n.I18nManager; |
33 | 41 |
import org.slf4j.Logger; |
... | ... | |
93 | 101 |
public GCanvas createGraphicCanvas(Color backgroundColor) { |
94 | 102 |
return new DefaultGCanvas(backgroundColor); |
95 | 103 |
} |
104 |
|
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* @see org.gvsig.raster.swing.RasterSwingManager#createPreviewPanel(int, java.util.ArrayList, javax.swing.JPanel, javax.swing.JPanel, org.gvsig.raster.swing.preview.PreviewRenderProcess, org.gvsig.raster.swing.preview.DataSourcePreview) |
|
108 |
*/ |
|
109 |
public PreviewPanel createPreviewPanel(int buttons, |
|
110 |
ArrayList list, |
|
111 |
JPanel generalPanel, |
|
112 |
JPanel downPreviewPanel, |
|
113 |
PreviewRenderProcess renderProcess, |
|
114 |
DataSourcePreview dataSource) { |
|
115 |
return new PreviewBasePanel( |
|
116 |
buttons, |
|
117 |
list, |
|
118 |
generalPanel, |
|
119 |
downPreviewPanel, |
|
120 |
renderProcess, |
|
121 |
dataSource); |
|
122 |
} |
|
96 | 123 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/preview/PreviewRequestManager.java | ||
---|---|---|
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.raster.swing.impl.preview; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
30 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
31 |
import org.gvsig.i18n.Messages; |
|
32 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
33 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
/** |
|
40 |
* Gestor de visualizaci?n de preview. Se encarga del repintado de la imagen |
|
41 |
* de la previsualizaci?n |
|
42 |
* |
|
43 |
* 19/02/2008 |
|
44 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
45 |
*/ |
|
46 |
public class PreviewRequestManager implements IClientImageNavigator { |
|
47 |
private static final Logger logger = LoggerFactory.getLogger(PreviewRequestManager.class); |
|
48 |
private DataSourcePreview previewLayer = null; |
|
49 |
private PreviewRenderProcess renderProcess = null; |
|
50 |
|
|
51 |
/** |
|
52 |
* Construye un ColorTableListener |
|
53 |
* @param |
|
54 |
*/ |
|
55 |
public PreviewRequestManager( PreviewRenderProcess renderProcess, |
|
56 |
DataSourcePreview layer) { |
|
57 |
this.renderProcess = renderProcess; |
|
58 |
setLayer(layer); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Asigna la capa raster de la vista |
|
63 |
* @param fLayer |
|
64 |
*/ |
|
65 |
private void setLayer(DataSourcePreview fLayer) { |
|
66 |
//if (fLayer instanceof IRasterLayerActions) { |
|
67 |
//IRasterLayerActions ly = (IRasterLayerActions) fLayer; |
|
68 |
//try { |
|
69 |
//Este c?digo no va bien pq la preview siempre tiene el extent global y el ?ltimo fichero |
|
70 |
//puede ser de un zoom |
|
71 |
/*if(ly.isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS)) |
|
72 |
previewLayer = (FLyrRaster)fLayer.getFileLayer(); |
|
73 |
else*/ |
|
74 |
previewLayer = fLayer.cloneDataSourcePreview(); |
|
75 |
//} catch (Exception e) { |
|
76 |
//messageBoxError("preview_not_available", previewBasePanel, e); |
|
77 |
//} |
|
78 |
//} |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Cierra la capa abierta para previsualizaci?n |
|
83 |
*/ |
|
84 |
public void closePreviewLayer() { |
|
85 |
previewLayer.closePreviewLayer(); |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see org.gvsig.gui.beans.imagenavigator.IClientImageNavigator#drawImage(java.awt.Graphics2D, |
|
91 |
* double, double, double, double, double, int, int) |
|
92 |
*/ |
|
93 |
public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) |
|
94 |
throws ImageUnavailableException { |
|
95 |
if (previewLayer == null) |
|
96 |
throw new ImageUnavailableException(Messages.getText("error_dont_exists_layer")); |
|
97 |
|
|
98 |
previewLayer.pushStatus(); |
|
99 |
try { |
|
100 |
renderProcess.process(previewLayer); |
|
101 |
} catch (ImageUnavailableException e2) { |
|
102 |
throw new ImageUnavailableException(Messages.getText("error_adding_filters")); |
|
103 |
} catch (Exception e2) { |
|
104 |
logger.debug("error_adding_filters", this, e2); |
Also available in: Unified diff