Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 19564

History | View | Annotate | Download (5.72 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.fmap.raster.layers.FLyrRasterSE;
30
import org.gvsig.raster.beans.previewbase.PreviewBasePanel;
31
import org.gvsig.raster.beans.previewbase.PreviewFiltering;
32
import org.gvsig.rastertools.filter.ui.NewOrSaveLayerPanel;
33

    
34
import com.iver.andami.PluginServices;
35
import com.iver.andami.ui.mdiManager.IWindow;
36
import com.iver.andami.ui.mdiManager.IWindowListener;
37
import com.iver.andami.ui.mdiManager.WindowInfo;
38
import com.iver.cit.gvsig.project.documents.view.gui.View;
39
/**
40
 * Dialogo para el realce por expansi?n del contraste
41
 * 
42
 * 19/02/2008
43
 * @author Nacho Brodin nachobrodin@gmail.com
44
 */
45
public class EnhancedDialog extends JPanel implements IWindow, IWindowListener {
46
        private static final long serialVersionUID = -5374834293534046986L;
47
        
48
        private PreviewBasePanel    previewBasePanel = null;
49
        private GraphicsPanel       graphicsPanel    = null;
50
        private FLyrRasterSE        lyr              = null;
51
        private PreviewFiltering    filteredPreview  = null;
52
        private SelectorsPanel      controlsPanel    = null;
53
        private NewOrSaveLayerPanel layerPanel       = null;
54
        private String              viewName         = 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, ArrayList lyrs, int width, int height) {
64
                this.setPreferredSize(new Dimension(width, height));
65
                this.setSize(width, height);
66
                this.setLayout(new BorderLayout(5, 5));
67
                
68
                graphicsPanel = new GraphicsPanel(lyr);
69
                filteredPreview = new PreviewFiltering();
70
                filteredPreview.setFilterStatus(lyr.getRender().getFilterList().getStatusCloned());
71
                controlsPanel = new SelectorsPanel(lyr, lyrs);
72
                                
73
                this.lyr = lyr;
74
                this.add(getPreviewBasePanel(), BorderLayout.CENTER);
75
                
76
                EnhancedListener listener = new EnhancedListener(controlsPanel, graphicsPanel, getPreviewBasePanel(), this, filteredPreview);
77
                graphicsPanel.setListener(listener);
78
                
79
                View view = (View) PluginServices.getMDIManager().getActiveWindow();
80
                viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle();
81
                
82
                getPreviewBasePanel().getButtonsPanel().addButtonPressedListener(listener);
83
                
84
                previewBasePanel.refreshPreview();
85
        }
86

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

    
147
        /*
148
         * (non-Javadoc)
149
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
150
         */
151
        public WindowInfo getWindowInfo() {
152
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
153
                if(getPreviewBasePanel().getLayer() != null)
154
                        m_viewinfo.setAdditionalInfo(getPreviewBasePanel().getLayer().getName());
155
                m_viewinfo.setTitle(PluginServices.getText(this, "enhanced"));
156
                m_viewinfo.setHeight(this.getHeight());
157
                m_viewinfo.setWidth(this.getWidth());
158
                return m_viewinfo;
159
        }
160

    
161
        public void windowClosed() {}
162
        public void windowActivated() {}
163

    
164
        /**
165
         * @return the filteredPreview
166
         */
167
        public PreviewFiltering getFilteredPreview() {
168
                return filteredPreview;
169
        }
170

    
171
        /**
172
         * @return the viewName
173
         */
174
        public String getViewName() {
175
                return viewName;
176
        }
177
}