Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / filter / ui / FilterDialog.java @ 33611

History | View | Annotate | Download (4.1 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.andami.PluginServices;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.andami.ui.mdiManager.IWindowListener;
28
import org.gvsig.andami.ui.mdiManager.WindowInfo;
29
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
30
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
31
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
32
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
33
import org.gvsig.raster.RasterLibrary;
34

    
35
/**
36
 * Dialogo para los filtros de raster.
37
 * 
38
 * @version 25/02/2008
39
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
40
 */
41
public class FilterDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener {
42
        private static final long serialVersionUID = 818691082984915388L;
43
        private FLyrRasterSE layer      = null;
44
        private FilterPanel filterPanel = null;
45

    
46
        /**
47
         * Constructor
48
         * @param width Ancho
49
         * @param height Alto
50
         */
51
        public FilterDialog(FLyrRasterSE layer, int width, int height) {
52
                this.layer = layer;
53
                setSize(width, height);
54
                setLayout(new BorderLayout(5, 5));
55
                add(getFilterPanel(), java.awt.BorderLayout.CENTER);
56
        }
57
        
58
        /**
59
         * Obtiene el panel con el histograma
60
         * @return HistogramPanel
61
         */
62
        private FilterPanel getFilterPanel() {
63
                if (filterPanel == null) {
64
                        filterPanel = new FilterPanel(layer, this);
65
                }
66
                return filterPanel;
67
        }
68
        
69
        /**
70
         * Acciones a ejecutar cuando se cancela
71
         */
72
        private void close() {
73
                try {
74
                        RasterLibrary.removeOnlyLayerNameListener(getFilterPanel().getNewLayerPanel().getPanelNewLayer());
75
                        PluginServices.getMDIManager().closeWindow(this);
76
                } catch (ArrayIndexOutOfBoundsException e) {
77
                        //Si la ventana no se puede eliminar no hacemos nada
78
                }
79
        }
80
        
81
        /*
82
         * (non-Javadoc)
83
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
84
         */
85
        public WindowInfo getWindowInfo() {
86
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
87
                if (layer != null)
88
                        m_viewinfo.setAdditionalInfo(layer.getName());
89
                m_viewinfo.setTitle(PluginServices.getText(this, "filtros"));
90
                m_viewinfo.setHeight(this.getHeight());
91
                m_viewinfo.setWidth(this.getWidth());
92
                return m_viewinfo;
93
        }
94

    
95
        /*
96
         * (non-Javadoc)
97
         * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
98
         */
99
        public void windowClosed() {
100
        }
101
        
102
        /*
103
         * (non-Javadoc)
104
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
105
         */
106
        public void actionButtonPressed(ButtonsPanelEvent e) {
107
                // Al pulsar Aceptar o Aplicar se ejecuta el aceptar del panel
108
                if (e.getButton() == ButtonsPanel.BUTTON_APPLY /*|| e.getButton() == ButtonsPanel.BUTTON_ACCEPT*/) {
109
                        getFilterPanel().getLayerVisualStatus().restoreVisualStatus(layer);
110
                        getFilterPanel().apply();
111
                }
112
        
113
                // Al pulsar Cancelar la ventana se cierra y se refresca la vista
114
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
115
                        getFilterPanel().getLayerVisualStatus().restoreVisualStatus(layer);
116
                        getFilterPanel().cancel();
117
                }
118
                        
119
                if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
120
                        close();
121
                }
122
        }
123
        
124
        public void windowActivated() {}
125

    
126
        public Object getWindowProfile() {
127
                return WindowInfo.PROPERTIES_PROFILE;
128
        }
129
}