Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / histogram / ui / HistogramDialog.java @ 24986

History | View | Annotate | Download (4.03 KB)

1 10799 bsanchez
/* 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.histogram.ui;
20
21
import java.awt.BorderLayout;
22
23
import javax.swing.JPanel;
24
25 13942 nacho
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
26 10949 nacho
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27 11042 bsanchez
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
29 10886 bsanchez
30 10799 bsanchez
import com.iver.andami.PluginServices;
31
import com.iver.andami.ui.mdiManager.IWindow;
32
import com.iver.andami.ui.mdiManager.WindowInfo;
33
/**
34 11228 bsanchez
 * <code>HistogramDialog</code>. Creaci?n de la ventana de histograma para gvSIG.
35 12243 bsanchez
 *
36 10799 bsanchez
 * @version 20/03/2007
37
 * @author Nacho Brodin (brodin_ign@gva.es)
38 12369 bsanchez
 * @author BorSanZa - Borja Sanchez Zamorano (borja.sanchez@iver.es)
39 10799 bsanchez
 */
40 11042 bsanchez
public class HistogramDialog extends JPanel implements IWindow, ButtonsPanelListener {
41 10799 bsanchez
        private static final long serialVersionUID = 7362459094802955247L;
42 14397 bsanchez
        private HistogramPanel histogramPanel = null;
43
        private String         layerName      = null;
44 10950 bsanchez
45 11228 bsanchez
        /**
46
         * Crea la ventana del histograma con un ancho y alto.
47
         * @param width Ancho de la ventana
48
         * @param height Alto de la ventana
49
         */
50 10799 bsanchez
        public HistogramDialog(int width, int height){
51
                this.setSize(width, height);
52
                this.setLayout(new BorderLayout(5, 5));
53
                this.add(getHistogramPanel(), java.awt.BorderLayout.CENTER);
54
        }
55 13942 nacho
56
        /**
57
         * Asigna la capa para obtener las fuentes de datos tanto del
58
         * datasource como de la visualizaci?n.
59
         * @param lyr Capa
60
         */
61
        public void setLayer(FLyrRasterSE lyr) throws Exception {
62
                layerName = lyr.getName();
63
                getHistogramPanel().setDataType(((FLyrRasterSE) lyr).getDataType()[0]);
64
                getHistogramPanel().setLayer(lyr);
65
        }
66 11228 bsanchez
67 10799 bsanchez
        /**
68
         * Obtiene el panel con el histograma
69
         * @return HistogramPanel
70
         */
71
        public HistogramPanel getHistogramPanel(){
72 11228 bsanchez
                if (histogramPanel == null) {
73 10799 bsanchez
                        histogramPanel = new HistogramPanel();
74 11042 bsanchez
                        histogramPanel.addButtonPressedListener(this);
75 10799 bsanchez
                }
76
                return histogramPanel;
77
        }
78
79 11228 bsanchez
        /*
80
         * (non-Javadoc)
81
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
82
         */
83 10799 bsanchez
        public WindowInfo getWindowInfo() {
84 15975 nbrodin
                WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
85 14397 bsanchez
                if (getLayerName() != null)
86 12225 nacho
                        m_viewinfo.setAdditionalInfo(getLayerName());
87
                m_viewinfo.setTitle(PluginServices.getText(this, "histograma"));
88
                m_viewinfo.setHeight(this.getHeight());
89
                m_viewinfo.setWidth(this.getWidth());
90 10799 bsanchez
                return m_viewinfo;
91
        }
92 11228 bsanchez
93 10886 bsanchez
        /**
94
         * Acciones a ejecutar cuando se cancela
95
         */
96 14397 bsanchez
        private void close() {
97 10886 bsanchez
                try {
98
                        PluginServices.getMDIManager().closeWindow(this);
99
                } catch (ArrayIndexOutOfBoundsException e) {
100
                        //Si la ventana no se puede eliminar no hacemos nada
101
                }
102
        }
103
104 11228 bsanchez
        /*
105
         * (non-Javadoc)
106
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
107
         */
108 11042 bsanchez
        public void actionButtonPressed(ButtonsPanelEvent e) {
109 11228 bsanchez
                if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
110 11042 bsanchez
                        close();
111
                }
112
        }
113 12225 nacho
114
        /**
115
         * Obtiene el nombre de la capa. Esto no es necesario para la funcionalidad de histograma.
116
         * Solo se usa para destruir el dialogo si est? abierto cuando se destruye la capa.
117
         * @return Nombre de la capa
118
         */
119
        public String getLayerName() {
120
                return layerName;
121
        }
122 24986 jcampos
123
        public Object getWindowProfile() {
124
                return WindowInfo.PROPERTIES_PROFILE;
125
        }
126 10799 bsanchez
}