Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / colortable / ui / ColorTableDialog.java @ 12514

History | View | Annotate | Download (3.48 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.colortable.ui;
20

    
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
23

    
24
import javax.swing.JPanel;
25

    
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
29

    
30
import com.iver.andami.PluginServices;
31
import com.iver.andami.ui.mdiManager.IWindow;
32
import com.iver.andami.ui.mdiManager.WindowInfo;
33
import com.iver.cit.gvsig.fmap.layers.FLayer;
34
/**
35
* <code>CuttingDialog</code>. Creaci?n de la ventana de recorte para gvSIG.
36
*
37
* @version 17/04/2007
38
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
39
*/
40
public class ColorTableDialog extends JPanel implements IWindow, ButtonsPanelListener {
41
        private static final long serialVersionUID = -5374834293534046986L;
42

    
43
        /**
44
         * Panel de recortado de imagen que est? en la libreria raster
45
         */
46
        private ColorTablePanel colorTablePanel = null;
47

    
48
        /**
49
         * Constructor
50
         * @param width Ancho
51
         * @param height Alto
52
         */
53
        public ColorTableDialog(int width, int height) {
54
                this.setPreferredSize(new Dimension(width, height));
55
                this.setSize(width, height);
56
                this.setLayout(new BorderLayout(5, 5));
57
                this.add(getColorTablePanel(), java.awt.BorderLayout.CENTER);
58
        }
59

    
60
        /**
61
         * Especificar el layer para el recorte
62
         * @param layer
63
         */
64
        public void setLayer(FLayer layer) {
65
                getColorTablePanel().setLayer(layer);
66
        }
67

    
68
        /**
69
         * Obtiene el panel con el histograma
70
         * @return HistogramPanel
71
         */
72
        public ColorTablePanel getColorTablePanel() {
73
                if (colorTablePanel == null) {
74
                        colorTablePanel = new ColorTablePanel();
75
                        colorTablePanel.addButtonPressedListener(this);
76
                }
77
                return colorTablePanel;
78
        }
79

    
80
        /*
81
         * (non-Javadoc)
82
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
83
         */
84
        public WindowInfo getWindowInfo() {
85
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
86
                if(getColorTablePanel().getLayer() != null)
87
                        m_viewinfo.setAdditionalInfo(getColorTablePanel().getLayer().getName());
88
                m_viewinfo.setTitle(PluginServices.getText(this, "recorte"));
89
                m_viewinfo.setHeight(this.getHeight());
90
                m_viewinfo.setWidth(this.getWidth());
91
                return m_viewinfo;
92
        }
93

    
94
        /**
95
         * Acciones a ejecutar cuando se cancela
96
         */
97
        public void close() {
98
                try {
99
                        PluginServices.getMDIManager().closeWindow(this);
100
                } catch (ArrayIndexOutOfBoundsException e) {
101
                        // Si la ventana no se puede eliminar no hacemos nada
102
                }
103
        }
104

    
105
        /*
106
         * (non-Javadoc)
107
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
108
         */
109
        public void actionButtonPressed(ButtonsPanelEvent e) {
110
                if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
111
                        close();
112
                }
113
        }
114
}