Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 29717

History | View | Annotate | Download (6.14 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 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.enhanced.ui;
20

    
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.util.ArrayList;
26

    
27
import javax.swing.JPanel;
28

    
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.ui.mdiManager.IWindow;
31
import org.gvsig.andami.ui.mdiManager.IWindowListener;
32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
33
import org.gvsig.app.project.documents.view.gui.BaseView;
34
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
35
import org.gvsig.raster.beans.createlayer.CreateLayerPanel;
36
import org.gvsig.raster.beans.previewbase.PreviewBasePanel;
37

    
38
/**
39
 * Dialogo para el realce por expansi?n del contraste
40
 * 
41
 * 19/02/2008
42
 * @author Nacho Brodin nachobrodin@gmail.com
43
 */
44
public class EnhancedDialog extends JPanel implements IWindow, IWindowListener {
45
        private static final long serialVersionUID = -5374834293534046986L;
46
        
47
        private PreviewBasePanel    previewBasePanel = null;
48
        private GraphicsPanel       graphicsPanel    = null;
49
        private FLyrRasterSE        lyr              = null;
50
        private PreviewFiltering    filteredPreview  = null;
51
        private SelectorsPanel      controlsPanel    = null;
52
        private CreateLayerPanel    layerPanel       = null;
53
        private String              viewName         = null;
54
        private EnhancedListener    listener         = null;
55
        
56
        /**
57
         * Constructor
58
         * @param lyr Capa raster sobre la que se opera
59
         * @param lyrs Lista de capas cargadas en el TOC
60
         * @param width Ancho
61
         * @param height Alto
62
         */
63
        public EnhancedDialog(FLyrRasterSE lyr, int width, int height) {
64
                this.setPreferredSize(new Dimension(width, height));
65
                this.setSize(width, height);
66
                this.setLayout(new BorderLayout(5, 5));
67
                this.lyr = lyr;
68
                
69
                graphicsPanel = new GraphicsPanel(this.lyr);
70
                filteredPreview = new PreviewFiltering();
71
                filteredPreview.setFilterStatus(this.lyr.getRender().getFilterList().getStatusCloned());
72
                controlsPanel = new SelectorsPanel(this.lyr, graphicsPanel.getInputHistogram());
73
                                
74
                this.add(getPreviewBasePanel(), BorderLayout.CENTER);
75
                
76
                listener = new EnhancedListener(controlsPanel, graphicsPanel, this, filteredPreview);
77
                
78
                listener.firstLoad();
79
                
80
                graphicsPanel.setListener(listener);
81
                
82
                graphicsPanel.updateHistogram();
83
                listener.updatePreview();
84
                
85
                IWindow window = PluginServices.getMDIManager().getActiveWindow();
86
                if(window instanceof BaseView) {
87
                        BaseView view = (BaseView)window;
88
                        viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle();
89
                }
90
                
91
                getPreviewBasePanel().getButtonsPanel().addButtonPressedListener(listener);
92
                
93
                previewBasePanel.refreshPreview();
94
        }
95

    
96
        /**
97
         * Obtiene el panel con el histograma
98
         * @return HistogramPanel
99
         */
100
        public PreviewBasePanel getPreviewBasePanel() {
101
                if (previewBasePanel == null) {
102
                        ArrayList list = new ArrayList();
103
                        list.add(graphicsPanel);
104
                        
105
                        JPanel downPreview = new JPanel();
106
                        getNewOrSaveLayerPanel().setLabelFilename("");
107
                        downPreview.setLayout(new GridBagLayout());
108
                        
109
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
110
                        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
111
                        downPreview.add(getNewOrSaveLayerPanel().getJPanel(), gridBagConstraints);
112
                        
113
                        gridBagConstraints = new GridBagConstraints();
114
                        gridBagConstraints.gridx = 0;
115
                        gridBagConstraints.gridy = 1;
116
                        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
117
                        gridBagConstraints.anchor = GridBagConstraints.NORTH;
118
                        gridBagConstraints.weightx = 1.0;
119
                        gridBagConstraints.weighty = 1.0;
120
                        downPreview.add(getNewOrSaveLayerPanel().getFileNamePanel(), gridBagConstraints);
121
                        
122
                        previewBasePanel = new PreviewBasePanel(list, controlsPanel, downPreview, filteredPreview, lyr);
123
                }
124
                return previewBasePanel;
125
        }
126
        
127
        /**
128
         * Devuelve un Panel para el guardado de capas en disco o en memoria.
129
         */
130
        public CreateLayerPanel getNewOrSaveLayerPanel() {
131
                 if (layerPanel == null) {
132
                         layerPanel = new CreateLayerPanel(lyr);
133
                 }
134
                 return layerPanel;
135
         }
136
        
137
        /**
138
         * Acciones a ejecutar cuando se cancela
139
         */
140
        public void close() {
141
                try {
142
                        PluginServices.getMDIManager().closeWindow(this);
143
                } catch (ArrayIndexOutOfBoundsException e) {
144
                        //Si la ventana no se puede eliminar no hacemos nada
145
                }
146
        }
147
        
148
        /**
149
         * Obtiene la capa asociada.
150
         * @return FLyrRasterSE
151
         */
152
        public FLyrRasterSE getLayer() {
153
                return lyr;
154
        }
155

    
156
        /*
157
         * (non-Javadoc)
158
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
159
         */
160
        public WindowInfo getWindowInfo() {
161
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
162
                if(getPreviewBasePanel().getLayer() != null)
163
                        m_viewinfo.setAdditionalInfo(getPreviewBasePanel().getLayer().getName());
164
                m_viewinfo.setTitle(PluginServices.getText(this, "enhanced"));
165
                m_viewinfo.setHeight(this.getHeight());
166
                m_viewinfo.setWidth(this.getWidth());
167
                return m_viewinfo;
168
        }
169

    
170
        /**
171
         * Evento de cerrado de la ventana desde el aspa
172
         */
173
        public void windowClosed() {
174
                listener.cancel();
175
        }
176
        
177
        public void windowActivated() {}
178

    
179
        /**
180
         * @return the filteredPreview
181
         */
182
        public PreviewFiltering getFilteredPreview() {
183
                return filteredPreview;
184
        }
185

    
186
        /**
187
         * @return the viewName
188
         */
189
        public String getViewName() {
190
                return viewName;
191
        }
192

    
193
        /**
194
         * @return the graphicsPanel
195
         */
196
        public GraphicsPanel getGraphicsPanel() {
197
                return graphicsPanel;
198
        }
199

    
200
        public Object getWindowProfile() {
201
                return WindowInfo.PROPERTIES_PROFILE;
202
        }
203
}