gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / clip / ui / ClippingDialog.java @ 2480
History | View | Annotate | Download (3.54 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.tool.clip.ui; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Dimension; |
26 |
|
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.gvsig.andami.PluginServices; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
32 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
33 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
34 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
35 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
36 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
37 |
|
38 |
/**
|
39 |
* <code>ClippingDialog</code>. Creaci?n de la ventana de recorte para gvSIG.
|
40 |
*
|
41 |
* @version 17/04/2007
|
42 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
43 |
*/
|
44 |
public class ClippingDialog extends JPanel implements IWindow, ButtonsPanelListener { |
45 |
private static final long serialVersionUID = -5374834293534046986L; |
46 |
private String name = null; |
47 |
|
48 |
/**
|
49 |
* Panel de recortado de imagen que est? en la libreria raster
|
50 |
*/
|
51 |
private ClippingPanel clippingPanel = null; |
52 |
|
53 |
/**
|
54 |
* Constructor
|
55 |
* @param width Ancho
|
56 |
* @param height Alto
|
57 |
*/
|
58 |
public ClippingDialog(int width, int height, String name) { |
59 |
this.name = name;
|
60 |
this.setPreferredSize(new Dimension(width, height)); |
61 |
this.setSize(width, height);
|
62 |
this.setLayout(new BorderLayout(5, 5)); |
63 |
this.add(getClippingPanel(), java.awt.BorderLayout.CENTER);
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* Obtiene el panel con el histograma
|
68 |
* @return HistogramPanel
|
69 |
*/
|
70 |
public ClippingPanel getClippingPanel() {
|
71 |
if (clippingPanel == null) { |
72 |
clippingPanel = new ClippingPanel(this); |
73 |
clippingPanel.addButtonPressedListener(this);
|
74 |
} |
75 |
return clippingPanel;
|
76 |
} |
77 |
|
78 |
public WindowInfo getWindowInfo() {
|
79 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
|
80 |
if (name != null) |
81 |
m_viewinfo.setAdditionalInfo(name); |
82 |
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 |
FileUtils util = RasterLocator.getManager().getFileUtils(); |
94 |
util.removeOnlyLayerNameListener(getClippingPanel().getOptionsPanel()); |
95 |
PluginServices.getMDIManager().closeWindow(this);
|
96 |
} catch (ArrayIndexOutOfBoundsException e) { |
97 |
// Si la ventana no se puede eliminar no hacemos nada
|
98 |
} |
99 |
} |
100 |
|
101 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
102 |
if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
|
103 |
close(); |
104 |
} |
105 |
} |
106 |
|
107 |
public Object getWindowProfile() { |
108 |
return WindowInfo.PROPERTIES_PROFILE;
|
109 |
} |
110 |
} |