svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / filter / ui / FilterDialog.java @ 18962
History | View | Annotate | Download (4.49 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.filter.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
|
23 |
import javax.swing.JPanel; |
24 |
|
25 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
26 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
27 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
28 |
import org.gvsig.raster.RasterLibrary; |
29 |
|
30 |
import com.iver.andami.PluginServices; |
31 |
import com.iver.andami.ui.mdiManager.IWindow; |
32 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
33 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
34 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
35 |
/**
|
36 |
* Dialogo para los filtros de raster.
|
37 |
*
|
38 |
* @version 30/05/2007
|
39 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
40 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
41 |
*/
|
42 |
public class FilterDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener { |
43 |
private static final long serialVersionUID = 7152780112689637266L; |
44 |
|
45 |
private FilterPanel filterPanel = null; |
46 |
private FLayer lyr = null; |
47 |
|
48 |
/**
|
49 |
* Controla si se ha presionado el boton aceptar para el cerrado de la ventana
|
50 |
*/
|
51 |
private boolean accepted = false; |
52 |
|
53 |
/**
|
54 |
* Constructor
|
55 |
* @param width Ancho del panel
|
56 |
* @param height Alto del panel
|
57 |
*/
|
58 |
public FilterDialog(FLayer layer, int width, int height) { |
59 |
this.lyr = layer;
|
60 |
this.setSize(width, height);
|
61 |
this.setLayout(new BorderLayout()); |
62 |
this.add(getFilterPanel(), BorderLayout.CENTER); |
63 |
this.setLayer(lyr);
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* Definir el layer a tratar para el filterPanel
|
68 |
* @param layer
|
69 |
*/
|
70 |
private void setLayer(FLayer layer) { |
71 |
getFilterPanel().setLayer(layer); |
72 |
} |
73 |
|
74 |
/**
|
75 |
* Obtiene el panel de filtros
|
76 |
* @return HistogramPanel
|
77 |
*/
|
78 |
private FilterPanel getFilterPanel() {
|
79 |
if (filterPanel == null) { |
80 |
filterPanel = new FilterPanel(lyr);
|
81 |
filterPanel.addButtonPressedListener(this);
|
82 |
} |
83 |
return filterPanel;
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
88 |
*/
|
89 |
public WindowInfo getWindowInfo() {
|
90 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
91 |
if (getFilterPanel().getLayer() != null) |
92 |
m_viewinfo.setAdditionalInfo(getFilterPanel().getLayer().getName()); |
93 |
m_viewinfo.setTitle(PluginServices.getText(this, "filtros")); |
94 |
m_viewinfo.setHeight(this.getHeight());
|
95 |
m_viewinfo.setWidth(this.getWidth());
|
96 |
return m_viewinfo;
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Acciones a ejecutar cuando se cancela
|
101 |
*/
|
102 |
private void close() { |
103 |
try {
|
104 |
RasterLibrary.removeOnlyLayerNameListener(getFilterPanel()); |
105 |
PluginServices.getMDIManager().closeWindow(this);
|
106 |
} catch (ArrayIndexOutOfBoundsException e) { |
107 |
//Si la ventana no se puede eliminar no hacemos nada
|
108 |
} |
109 |
} |
110 |
|
111 |
/*
|
112 |
* (non-Javadoc)
|
113 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
114 |
*/
|
115 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
116 |
// Restauramos la vista con los filtros originales antes de cualquier acci?n
|
117 |
filterPanel.restoreFilters(); |
118 |
|
119 |
// Al pulsar Aceptar o Aplicar se ejecuta el aceptar del panel
|
120 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
121 |
filterPanel.accept(); |
122 |
} |
123 |
|
124 |
// Al pulsar Cancelar la ventana se cierra y se refresca la vista
|
125 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
126 |
filterPanel.cancel(); |
127 |
close(); |
128 |
} |
129 |
|
130 |
// Al pulsar Aceptar simplemente la ventana se cierra
|
131 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
132 |
accepted = true;
|
133 |
close(); |
134 |
} |
135 |
} |
136 |
|
137 |
/*
|
138 |
* (non-Javadoc)
|
139 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
140 |
*/
|
141 |
public void windowClosed() { |
142 |
if (!accepted) {
|
143 |
filterPanel.restoreFilters(); |
144 |
filterPanel.cancel(); |
145 |
} |
146 |
} |
147 |
|
148 |
public void windowActivated() {} |
149 |
} |