root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 20057
History | View | Annotate | Download (5.86 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.enhanced.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
import java.awt.GridBagConstraints; |
24 |
import java.awt.GridBagLayout; |
25 |
import java.util.ArrayList; |
26 |
|
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
30 |
import org.gvsig.raster.beans.previewbase.PreviewBasePanel; |
31 |
import org.gvsig.rastertools.filter.ui.NewOrSaveLayerPanel; |
32 |
|
33 |
import com.iver.andami.PluginServices; |
34 |
import com.iver.andami.ui.mdiManager.IWindow; |
35 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
36 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
37 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
38 |
/**
|
39 |
* Dialogo para el realce por expansi?n del contraste
|
40 |
*
|
41 |
* 19/02/2008
|
42 |
* @author Nacho Brodin nachobrodin@gmail.com
|
43 |
*/
|
44 |
public class EnhancedDialog extends JPanel implements IWindow, IWindowListener { |
45 |
private static final long serialVersionUID = -5374834293534046986L; |
46 |
|
47 |
private PreviewBasePanel previewBasePanel = null; |
48 |
private GraphicsPanel graphicsPanel = null; |
49 |
private FLyrRasterSE lyr = null; |
50 |
private PreviewFiltering filteredPreview = null; |
51 |
private SelectorsPanel controlsPanel = null; |
52 |
private NewOrSaveLayerPanel layerPanel = null; |
53 |
private String viewName = null; |
54 |
|
55 |
/**
|
56 |
* Constructor
|
57 |
* @param lyr Capa raster sobre la que se opera
|
58 |
* @param lyrs Lista de capas cargadas en el TOC
|
59 |
* @param width Ancho
|
60 |
* @param height Alto
|
61 |
*/
|
62 |
public EnhancedDialog(FLyrRasterSE lyr, ArrayList lyrs, int width, int height) { |
63 |
this.setPreferredSize(new Dimension(width, height)); |
64 |
this.setSize(width, height);
|
65 |
this.setLayout(new BorderLayout(5, 5)); |
66 |
this.lyr = lyr;
|
67 |
|
68 |
graphicsPanel = new GraphicsPanel(this.lyr); |
69 |
filteredPreview = new PreviewFiltering();
|
70 |
filteredPreview.setFilterStatus(this.lyr.getRender().getFilterList().getStatusCloned());
|
71 |
controlsPanel = new SelectorsPanel(this.lyr, lyrs); |
72 |
|
73 |
this.add(getPreviewBasePanel(), BorderLayout.CENTER); |
74 |
|
75 |
EnhancedListener listener = new EnhancedListener(controlsPanel, graphicsPanel, this, filteredPreview); |
76 |
|
77 |
listener.firstLoad(); |
78 |
|
79 |
graphicsPanel.setListener(listener); |
80 |
|
81 |
graphicsPanel.updateHistogram(); |
82 |
listener.updatePreview(); |
83 |
|
84 |
View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
85 |
viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle(); |
86 |
|
87 |
getPreviewBasePanel().getButtonsPanel().addButtonPressedListener(listener); |
88 |
|
89 |
previewBasePanel.refreshPreview(); |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Obtiene el panel con el histograma
|
94 |
* @return HistogramPanel
|
95 |
*/
|
96 |
public PreviewBasePanel getPreviewBasePanel() {
|
97 |
if (previewBasePanel == null) { |
98 |
ArrayList list = new ArrayList(); |
99 |
list.add(graphicsPanel); |
100 |
|
101 |
JPanel downPreview = new JPanel(); |
102 |
getNewOrSaveLayerPanel().getLabelFilename().setText("");
|
103 |
downPreview.setLayout(new GridBagLayout()); |
104 |
|
105 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
106 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
107 |
downPreview.add(getNewOrSaveLayerPanel(), gridBagConstraints); |
108 |
|
109 |
gridBagConstraints = new GridBagConstraints(); |
110 |
gridBagConstraints.gridx = 0;
|
111 |
gridBagConstraints.gridy = 1;
|
112 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
113 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
114 |
gridBagConstraints.weightx = 1.0;
|
115 |
gridBagConstraints.weighty = 1.0;
|
116 |
downPreview.add(getNewOrSaveLayerPanel().getFileNamePanel(), gridBagConstraints); |
117 |
|
118 |
previewBasePanel = new PreviewBasePanel(list, controlsPanel, downPreview, filteredPreview, lyr);
|
119 |
} |
120 |
return previewBasePanel;
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* Devuelve un Panel para el guardado de capas en disco o en memoria.
|
125 |
*/
|
126 |
public NewOrSaveLayerPanel getNewOrSaveLayerPanel() {
|
127 |
if (layerPanel == null) { |
128 |
layerPanel = new NewOrSaveLayerPanel();
|
129 |
} |
130 |
return layerPanel;
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* Acciones a ejecutar cuando se cancela
|
135 |
*/
|
136 |
public void close() { |
137 |
try {
|
138 |
PluginServices.getMDIManager().closeWindow(this);
|
139 |
} catch (ArrayIndexOutOfBoundsException e) { |
140 |
//Si la ventana no se puede eliminar no hacemos nada
|
141 |
} |
142 |
} |
143 |
|
144 |
/**
|
145 |
* Obtiene la capa asociada.
|
146 |
* @return FLyrRasterSE
|
147 |
*/
|
148 |
public FLyrRasterSE getLayer() {
|
149 |
return lyr;
|
150 |
} |
151 |
|
152 |
/*
|
153 |
* (non-Javadoc)
|
154 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
155 |
*/
|
156 |
public WindowInfo getWindowInfo() {
|
157 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
158 |
if(getPreviewBasePanel().getLayer() != null) |
159 |
m_viewinfo.setAdditionalInfo(getPreviewBasePanel().getLayer().getName()); |
160 |
m_viewinfo.setTitle(PluginServices.getText(this, "enhanced")); |
161 |
m_viewinfo.setHeight(this.getHeight());
|
162 |
m_viewinfo.setWidth(this.getWidth());
|
163 |
return m_viewinfo;
|
164 |
} |
165 |
|
166 |
public void windowClosed() {} |
167 |
public void windowActivated() {} |
168 |
|
169 |
/**
|
170 |
* @return the filteredPreview
|
171 |
*/
|
172 |
public PreviewFiltering getFilteredPreview() {
|
173 |
return filteredPreview;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* @return the viewName
|
178 |
*/
|
179 |
public String getViewName() { |
180 |
return viewName;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* @return the graphicsPanel
|
185 |
*/
|
186 |
public GraphicsPanel getGraphicsPanel() {
|
187 |
return graphicsPanel;
|
188 |
} |
189 |
} |