gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / histogram / ui / HistogramDialog.java @ 1676
History | View | Annotate | Download (4.03 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.raster.tools.app.basic.tool.histogram.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
|
23 |
import javax.swing.JPanel; |
24 |
|
25 |
import org.gvsig.andami.PluginServices; |
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
27 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
28 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
29 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
30 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
31 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
32 |
|
33 |
/**
|
34 |
* <code>HistogramDialog</code>. Creaci?n de la ventana de histograma para gvSIG.
|
35 |
*
|
36 |
* @version 20/03/2007
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
* @author BorSanZa - Borja Sanchez Zamorano
|
39 |
*/
|
40 |
public class HistogramDialog extends JPanel implements IWindow, ButtonsPanelListener { |
41 |
private static final long serialVersionUID = 7362459094802955247L; |
42 |
private HistogramPanel histogramPanel = null; |
43 |
private String layerName = null; |
44 |
|
45 |
/**
|
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 |
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 |
|
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(FLyrRaster lyr) throws Exception { |
62 |
layerName = lyr.getName(); |
63 |
getHistogramPanel().setDataType(lyr.getDataStore().getDataType()[0]);
|
64 |
getHistogramPanel().setLayer(lyr); |
65 |
} |
66 |
|
67 |
/**
|
68 |
* Obtiene el panel con el histograma
|
69 |
* @return HistogramPanel
|
70 |
*/
|
71 |
public HistogramPanel getHistogramPanel() {
|
72 |
if (histogramPanel == null) { |
73 |
histogramPanel = new HistogramPanel();
|
74 |
histogramPanel.addButtonPressedListener(this);
|
75 |
} |
76 |
return histogramPanel;
|
77 |
} |
78 |
|
79 |
/*
|
80 |
* (non-Javadoc)
|
81 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
82 |
*/
|
83 |
public WindowInfo getWindowInfo() {
|
84 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
85 |
if (getLayerName() != null) |
86 |
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 |
return m_viewinfo;
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* Acciones a ejecutar cuando se cancela
|
95 |
*/
|
96 |
private void close() { |
97 |
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 |
/*
|
105 |
* (non-Javadoc)
|
106 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
107 |
*/
|
108 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
109 |
if (e.getButton() == ButtonsPanel.BUTTON_CLOSE) {
|
110 |
close(); |
111 |
} |
112 |
} |
113 |
|
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 |
|
123 |
public Object getWindowProfile() { |
124 |
return WindowInfo.PROPERTIES_PROFILE;
|
125 |
} |
126 |
} |