Statistics
| Revision:

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

History | View | Annotate | Download (3.62 KB)

1 14827 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.clipping.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 18962 nbrodin
import org.gvsig.raster.RasterLibrary;
30 14827 bsanchez
31
import com.iver.andami.PluginServices;
32
import com.iver.andami.ui.mdiManager.IWindow;
33
import com.iver.andami.ui.mdiManager.WindowInfo;
34
/**
35 14846 bsanchez
 * <code>ClippingDialog</code>. Creaci?n de la ventana de recorte para gvSIG.
36 14827 bsanchez
 *
37
 * @version 17/04/2007
38
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
39
 */
40
public class ClippingDialog extends JPanel implements IWindow, ButtonsPanelListener {
41 21044 nbrodin
        private static final long  serialVersionUID = -5374834293534046986L;
42
        private String             name             = null;
43 14827 bsanchez
44
        /**
45
         * Panel de recortado de imagen que est? en la libreria raster
46
         */
47 14846 bsanchez
        private ClippingPanel clippingPanel = null;
48 14827 bsanchez
49
        /**
50
         * Constructor
51
         * @param width Ancho
52
         * @param height Alto
53
         */
54 21044 nbrodin
        public ClippingDialog(int width, int height, String name) {
55
                this.name = name;
56 14827 bsanchez
                this.setPreferredSize(new Dimension(width, height));
57
                this.setSize(width, height);
58
                this.setLayout(new BorderLayout(5, 5));
59 14846 bsanchez
                this.add(getClippingPanel(), java.awt.BorderLayout.CENTER);
60 14827 bsanchez
        }
61
62
        /**
63
         * Obtiene el panel con el histograma
64
         * @return HistogramPanel
65
         */
66 14846 bsanchez
        public ClippingPanel getClippingPanel() {
67
                if (clippingPanel == null) {
68
                        clippingPanel = new ClippingPanel(this);
69
                        clippingPanel.addButtonPressedListener(this);
70 14827 bsanchez
                }
71 14846 bsanchez
                return clippingPanel;
72 14827 bsanchez
        }
73
74
        /*
75
         * (non-Javadoc)
76
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
77
         */
78
        public WindowInfo getWindowInfo() {
79
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
80 21044 nbrodin
                if (name != null)
81
                        m_viewinfo.setAdditionalInfo(name);
82 14827 bsanchez
                m_viewinfo.setTitle(PluginServices.getText(this, "recorte"));
83
                m_viewinfo.setHeight(this.getHeight());
84
                m_viewinfo.setWidth(this.getWidth());
85
                return m_viewinfo;
86
        }
87
88
        /**
89
         * Acciones a ejecutar cuando se cancela
90
         */
91
        public void close() {
92
                try {
93 18962 nbrodin
                        RasterLibrary.removeOnlyLayerNameListener(getClippingPanel().getOptionsPanel());
94 14827 bsanchez
                        PluginServices.getMDIManager().closeWindow(this);
95
                } catch (ArrayIndexOutOfBoundsException e) {
96
                        // Si la ventana no se puede eliminar no hacemos nada
97
                }
98
        }
99
100
        /*
101
         * (non-Javadoc)
102
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
103
         */
104
        public void actionButtonPressed(ButtonsPanelEvent e) {
105
                if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
106
                        close();
107
                }
108
        }
109 24986 jcampos
110
        public Object getWindowProfile() {
111
                return WindowInfo.PROPERTIES_PROFILE;
112
        }
113 14827 bsanchez
}