root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / imagefusion / gui / FusionDialog.java @ 22165
History | View | Annotate | Download (4.49 KB)
1 | 22134 | amunoz | /*
|
---|---|---|---|
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 | * Dialogo para la fusi?n de imagenes de distinta resolucion espacial
|
||
60 | *
|
||
61 | * @version 25/02/2008
|
||
62 | * @author aMu?oz (alejandro.munoz@uclm.es)
|
||
63 | */
|
||
64 | |||
65 | public class FusionDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener { |
||
66 | |||
67 | private static final long serialVersionUID = 818691082984915388L; |
||
68 | private FLayer layer = null; |
||
69 | private FusionPanel fusionPanel = null; |
||
70 | |||
71 | /**
|
||
72 | * Controla si se ha presionado el boton aceptar para el cerrado de la ventana
|
||
73 | */
|
||
74 | private boolean accepted = false; |
||
75 | |||
76 | /**
|
||
77 | * Constructor
|
||
78 | * @param width Ancho
|
||
79 | * @param height Alto
|
||
80 | */
|
||
81 | public FusionDialog(FLayer layer, int width, int height) { |
||
82 | this.layer = layer;
|
||
83 | setSize(width, height); |
||
84 | setLayout(new BorderLayout(5, 5)); |
||
85 | add(getFusionPanel(), java.awt.BorderLayout.CENTER); |
||
86 | } |
||
87 | |||
88 | |||
89 | /*
|
||
90 | * (non-Javadoc)
|
||
91 | * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
||
92 | */
|
||
93 | public WindowInfo getWindowInfo() {
|
||
94 | WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
|
||
95 | if (layer != null) |
||
96 | m_viewinfo.setAdditionalInfo(layer.getName()); |
||
97 | m_viewinfo.setTitle(PluginServices.getText(this, "fusion")); |
||
98 | m_viewinfo.setHeight(this.getHeight());
|
||
99 | m_viewinfo.setWidth(this.getWidth());
|
||
100 | return m_viewinfo;
|
||
101 | } |
||
102 | |||
103 | |||
104 | /**
|
||
105 | * Obtiene el panel para la fusion
|
||
106 | * @return
|
||
107 | */
|
||
108 | private FusionPanel getFusionPanel() {
|
||
109 | if (fusionPanel == null) { |
||
110 | fusionPanel = new FusionPanel(layer, this); |
||
111 | } |
||
112 | return fusionPanel;
|
||
113 | } |
||
114 | |||
115 | /**
|
||
116 | * Acciones a ejecutar cuando se cancela
|
||
117 | */
|
||
118 | private void close() { |
||
119 | try {
|
||
120 | RasterLibrary.removeOnlyLayerNameListener(getFusionPanel().getNewLayerPanel().getPanelNewLayer()); |
||
121 | PluginServices.getMDIManager().closeWindow(this);
|
||
122 | } catch (ArrayIndexOutOfBoundsException e) { |
||
123 | //Si la ventana no se puede eliminar no hacemos nada
|
||
124 | } |
||
125 | } |
||
126 | |||
127 | |||
128 | /*
|
||
129 | * (non-Javadoc)
|
||
130 | * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
||
131 | */
|
||
132 | public void windowClosed() { |
||
133 | if (!accepted) {
|
||
134 | getFusionPanel().cancel(); |
||
135 | } |
||
136 | } |
||
137 | |||
138 | /*
|
||
139 | * (non-Javadoc)
|
||
140 | * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
||
141 | */
|
||
142 | public void actionButtonPressed(ButtonsPanelEvent e) { |
||
143 | |||
144 | // Al pulsar Aceptar o Aplicar se ejecuta el aceptar del panel
|
||
145 | if (e.getButton() == ButtonsPanel.BUTTON_APPLY || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
146 | getFusionPanel().accept(); |
||
147 | } |
||
148 | |||
149 | // Al pulsar Cancelar la ventana se cierra y se refresca la vista
|
||
150 | if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
||
151 | getFusionPanel().cancel(); |
||
152 | close(); |
||
153 | } |
||
154 | |||
155 | // Al pulsar Aceptar simplemente la ventana se cierra
|
||
156 | if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
157 | accepted = true;
|
||
158 | close(); |
||
159 | } |
||
160 | } |
||
161 | |||
162 | public void windowActivated() {} |
||
163 | } |