Statistics
| Revision:

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

History | View | Annotate | Download (4.85 KB)

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

    
41
package org.gvsig.remotesensing.scatterplot.gui;
42

    
43
import java.awt.BorderLayout;
44

    
45
import javax.swing.JPanel;
46

    
47
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
48
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
49
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
50
import org.gvsig.raster.grid.GridException;
51

    
52
import com.iver.andami.PluginServices;
53
import com.iver.andami.ui.mdiManager.IWindow;
54
import com.iver.andami.ui.mdiManager.IWindowListener;
55
import com.iver.andami.ui.mdiManager.WindowInfo;
56
import com.iver.cit.gvsig.fmap.MapControl;
57
import com.iver.cit.gvsig.fmap.layers.FLayer;
58
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
59
import com.iver.cit.gvsig.project.documents.view.gui.View;
60

    
61
/**
62
* Dialogo para el grafico de dispersion.
63
*         
64
* @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)   
65
* @version 11/12/2007
66
*  
67
**/
68

    
69
public class ScatterPlotDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener {
70
        
71
        private static final long serialVersionUID = 2847035927527203595L;
72
        private ScatterPlotPanel scatterPlotPanel = null;
73
        private MapControl mapControl = null;
74
        private String previousTool = null;
75
        
76
        
77
        /**
78
         * Constructor
79
         * @param width Ancho del panel
80
         * @param height Alto del panel
81
         */
82
        public ScatterPlotDialog(int width, int height) {
83
                this.setSize(width, height);
84
                this.setLayout(new BorderLayout());
85
                this.add(getScatterPlotPanel(), BorderLayout.CENTER);
86
                View view = (View) PluginServices.getMDIManager().getActiveWindow();
87
                mapControl = view.getMapControl();
88
                previousTool = mapControl.getCurrentTool();
89
                
90
        }
91
        
92
        
93
        public WindowInfo getWindowInfo() {
94
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
95
                if(scatterPlotPanel.getLayer() != null)
96
                        m_viewinfo.setAdditionalInfo(scatterPlotPanel.getLayer().getName());
97
                m_viewinfo.setTitle(PluginServices.getText(this, "diagrama_dispersion")+" - "+m_viewinfo.getAdditionalInfo());
98
                m_viewinfo.setHeight(this.getHeight());
99
                m_viewinfo.setWidth(this.getWidth());
100
                return m_viewinfo;
101
        }
102

    
103
        public void actionButtonPressed(ButtonsPanelEvent e) {
104
                // Al pulsar Cancelar la ventana se cierra y se refresca la vista
105
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
106
                        close();
107
                }
108

    
109
                // Al pulsar Aceptar simplemente la ventana se cierra
110
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
111
                        getScatterPlotPanel().aplicar();
112
                }
113
        }
114
        
115
        /**
116
         * Acciones a ejecutar cuando se cancela
117
         */
118
        public void close() {
119
                try {
120
                        PluginServices.getMDIManager().closeWindow(this);
121
                } catch (ArrayIndexOutOfBoundsException e) {
122
                        //Si la ventana no se puede eliminar no hacemos nada
123
                }
124
        }
125
        
126
        /**
127
         * Se asigna el layer sobre el que esta asociado el diagrama
128
         * @param layer
129
         * @throws GridException 
130
         */
131
        public void setLayer(FLayer layer) throws GridException {
132
                getScatterPlotPanel().setFLayer(layer);
133
        }
134
        
135
        
136
        /** Recupera la herramienta previa seleccionada */
137
        public void setPreviousTool(){
138
                if (previousTool!=null)
139
                        getScatterPlotPanel().getMapControl().setTool(previousTool);
140
        }
141

    
142
        public void windowActivated() {
143
                
144
        }
145

    
146
        public void windowClosed() {
147
                GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer();
148
                graphicLayer.clearAllGraphics();
149
                graphicLayer.clearSymbolsGraphics();
150
                getScatterPlotPanel().getMapControl().rePaintDirtyLayers();
151
                setPreviousTool();
152
        }
153

    
154
        
155
        /**
156
         *  @return scatterplotpanel
157
         * */
158
        public ScatterPlotPanel getScatterPlotPanel() {
159
                if (scatterPlotPanel == null){
160
                        scatterPlotPanel = new ScatterPlotPanel(this);
161
                        scatterPlotPanel.addButtonPressedListener(this);
162
                }
163
                return scatterPlotPanel;
164
        }
165

    
166

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