Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 31496

History | View | Annotate | Download (6.1 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.WindowInfo;
32
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
33
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
34
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
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 {
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 AbstractViewPanel) {
87
                        AbstractViewPanel view = (AbstractViewPanel)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(ButtonsPanel.BUTTONS_APPLYCLOSE, list, controlsPanel, downPreview, filteredPreview, lyr);
123
                        previewBasePanel.getButtonsPanel().addCancel();
124
                }
125
                return previewBasePanel;
126
        }
127
        
128
        /**
129
         * Devuelve un Panel para el guardado de capas en disco o en memoria.
130
         */
131
        public CreateLayerPanel getNewOrSaveLayerPanel() {
132
                 if (layerPanel == null) {
133
                         layerPanel = new CreateLayerPanel(lyr);
134
                 }
135
                 return layerPanel;
136
         }
137
        
138
        /**
139
         * Acciones a ejecutar cuando se cancela
140
         */
141
        public void close() {
142
                try {
143
                        PluginServices.getMDIManager().closeWindow(this);
144
                } catch (ArrayIndexOutOfBoundsException e) {
145
                        //Si la ventana no se puede eliminar no hacemos nada
146
                }
147
        }
148
        
149
        /**
150
         * Obtiene la capa asociada.
151
         * @return FLyrRasterSE
152
         */
153
        public FLyrRasterSE getLayer() {
154
                return lyr;
155
        }
156

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

    
171
        /**
172
         * @return the filteredPreview
173
         */
174
        public PreviewFiltering getFilteredPreview() {
175
                return filteredPreview;
176
        }
177

    
178
        /**
179
         * @return the viewName
180
         */
181
        public String getViewName() {
182
                return viewName;
183
        }
184

    
185
        /**
186
         * @return the graphicsPanel
187
         */
188
        public GraphicsPanel getGraphicsPanel() {
189
                return graphicsPanel;
190
        }
191

    
192
        public Object getWindowProfile() {
193
                return WindowInfo.PROPERTIES_PROFILE;
194
        }
195
}