Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / clipping / ui / ClippingDialog.java @ 18962

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

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

    
24
import javax.swing.JPanel;
25

    
26
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
29
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
30
import org.gvsig.raster.RasterLibrary;
31

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

    
44
        /**
45
         * Panel de recortado de imagen que est? en la libreria raster
46
         */
47
        private ClippingPanel clippingPanel = null;
48

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

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

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

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

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

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