Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / imagefusion / gui / FusionDialog.java @ 26348

History | View | Annotate | Download (4.57 KB)

1
/*
2
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
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
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Iba?ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
35
*   Campus Universitario s/n
36
*   02071 Alabacete
37
*   Spain
38
*
39
*   +34 967 599 200
40
*/
41

    
42
package org.gvsig.remotesensing.imagefusion.gui;
43

    
44
import java.awt.BorderLayout;
45

    
46
import javax.swing.JPanel;
47

    
48
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
49
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
50
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
51
import org.gvsig.raster.RasterLibrary;
52

    
53
import com.iver.andami.PluginServices;
54
import com.iver.andami.ui.mdiManager.IWindow;
55
import com.iver.andami.ui.mdiManager.IWindowListener;
56
import com.iver.andami.ui.mdiManager.WindowInfo;
57
import com.iver.cit.gvsig.fmap.layers.FLayer;
58

    
59
/**
60
 * Dialogo para la fusi?n de imagenes de distinta resolucion espacial 
61
 *  
62
 * @version 25/02/2008
63
 * @author aMu?oz (alejandro.munoz@uclm.es)
64
 */
65

    
66
public class FusionDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener {
67
        
68
        private static final long serialVersionUID = 818691082984915388L;
69
        private FLayer      layer       = null;
70
        private FusionPanel fusionPanel = null;
71

    
72
        /**
73
         * Controla si se ha presionado el boton aceptar para el cerrado de la ventana
74
         */
75
        private boolean     accepted    = false;
76

    
77
        /**
78
         * Constructor
79
         * @param width Ancho
80
         * @param height Alto
81
         */
82
        public FusionDialog(FLayer layer, int width, int height) {
83
                this.layer = layer;
84
                setSize(width, height);
85
                setLayout(new BorderLayout(5, 5));
86
                add(getFusionPanel(), java.awt.BorderLayout.CENTER);
87
        }
88
        
89
        
90
        /*
91
         * (non-Javadoc)
92
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
93
         */
94
        public WindowInfo getWindowInfo() {
95
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
96
                if (layer != null)
97
                        m_viewinfo.setAdditionalInfo(layer.getName());
98
                m_viewinfo.setTitle(PluginServices.getText(this, "fusion"));
99
                m_viewinfo.setHeight(this.getHeight());
100
                m_viewinfo.setWidth(this.getWidth());
101
                return m_viewinfo;
102
        }
103

    
104
        
105
        /**
106
         * Obtiene el panel para la fusion
107
         * @return 
108
         */
109
        private FusionPanel getFusionPanel() {
110
                if (fusionPanel == null) {
111
                        fusionPanel = new FusionPanel(layer, this);
112
                }
113
                return fusionPanel;
114
        }
115
        
116
        /**
117
         * Acciones a ejecutar cuando se cancela
118
         */
119
        private void close() {
120
                try {
121
                        RasterLibrary.removeOnlyLayerNameListener(getFusionPanel().getNewLayerPanel().getPanelNewLayer());
122
                        PluginServices.getMDIManager().closeWindow(this);
123
                } catch (ArrayIndexOutOfBoundsException e) {
124
                        //Si la ventana no se puede eliminar no hacemos nada
125
                }
126
        }
127
        
128
        
129
        /*
130
         * (non-Javadoc)
131
         * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
132
         */
133
        public void windowClosed() {
134
                if (!accepted) {
135
                        getFusionPanel().cancel();
136
                }
137
        }
138
        
139
        /*
140
         * (non-Javadoc)
141
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
142
         */
143
        public void actionButtonPressed(ButtonsPanelEvent e) {
144
        
145
                // Al pulsar Aceptar o Aplicar se ejecuta el aceptar del panel
146
                if (e.getButton() == ButtonsPanel.BUTTON_APPLY || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
147
                        getFusionPanel().accept();
148
                }
149
        
150
                // Al pulsar Cancelar la ventana se cierra y se refresca la vista
151
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
152
                        getFusionPanel().cancel();
153
                        close();
154
                }
155
        
156
                // Al pulsar Aceptar simplemente la ventana se cierra
157
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
158
                        accepted = true;
159
                        close();
160
                }
161
        }
162
        
163
        
164
        public void windowActivated() {}
165

    
166

    
167
        public Object getWindowProfile() {
168
                return WindowInfo.PROPERTIES_PROFILE;
169
        }
170
}