root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 19568
History | View | Annotate | Download (5.66 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 |
|
67 |
graphicsPanel = new GraphicsPanel(lyr);
|
68 |
filteredPreview = new PreviewFiltering();
|
69 |
filteredPreview.setFilterStatus(lyr.getRender().getFilterList().getStatusCloned()); |
70 |
controlsPanel = new SelectorsPanel(lyr, lyrs);
|
71 |
|
72 |
this.lyr = lyr;
|
73 |
this.add(getPreviewBasePanel(), BorderLayout.CENTER); |
74 |
|
75 |
EnhancedListener listener = new EnhancedListener(controlsPanel, graphicsPanel, getPreviewBasePanel(), this, filteredPreview); |
76 |
graphicsPanel.setListener(listener); |
77 |
|
78 |
View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
79 |
viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle(); |
80 |
|
81 |
getPreviewBasePanel().getButtonsPanel().addButtonPressedListener(listener); |
82 |
|
83 |
previewBasePanel.refreshPreview(); |
84 |
} |
85 |
|
86 |
/**
|
87 |
* Obtiene el panel con el histograma
|
88 |
* @return HistogramPanel
|
89 |
*/
|
90 |
public PreviewBasePanel getPreviewBasePanel() {
|
91 |
if (previewBasePanel == null) { |
92 |
ArrayList list = new ArrayList(); |
93 |
list.add(graphicsPanel); |
94 |
|
95 |
JPanel downPreview = new JPanel(); |
96 |
getNewOrSaveLayerPanel().getLabelFilename().setText("");
|
97 |
downPreview.setLayout(new GridBagLayout()); |
98 |
|
99 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
100 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
101 |
downPreview.add(getNewOrSaveLayerPanel(), gridBagConstraints); |
102 |
|
103 |
gridBagConstraints = new GridBagConstraints(); |
104 |
gridBagConstraints.gridx = 0;
|
105 |
gridBagConstraints.gridy = 1;
|
106 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
107 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
108 |
gridBagConstraints.weightx = 1.0;
|
109 |
gridBagConstraints.weighty = 1.0;
|
110 |
downPreview.add(getNewOrSaveLayerPanel().getFileNamePanel(), gridBagConstraints); |
111 |
|
112 |
previewBasePanel = new PreviewBasePanel(list, controlsPanel, downPreview, filteredPreview, lyr);
|
113 |
} |
114 |
return previewBasePanel;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Devuelve un Panel para el guardado de capas en disco o en memoria.
|
119 |
*/
|
120 |
public NewOrSaveLayerPanel getNewOrSaveLayerPanel() {
|
121 |
if (layerPanel == null) { |
122 |
layerPanel = new NewOrSaveLayerPanel();
|
123 |
} |
124 |
return layerPanel;
|
125 |
} |
126 |
|
127 |
/**
|
128 |
* Acciones a ejecutar cuando se cancela
|
129 |
*/
|
130 |
public void close() { |
131 |
try {
|
132 |
PluginServices.getMDIManager().closeWindow(this);
|
133 |
} catch (ArrayIndexOutOfBoundsException e) { |
134 |
//Si la ventana no se puede eliminar no hacemos nada
|
135 |
} |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Obtiene la capa asociada.
|
140 |
* @return FLyrRasterSE
|
141 |
*/
|
142 |
public FLyrRasterSE getLayer() {
|
143 |
return lyr;
|
144 |
} |
145 |
|
146 |
/*
|
147 |
* (non-Javadoc)
|
148 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
149 |
*/
|
150 |
public WindowInfo getWindowInfo() {
|
151 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
152 |
if(getPreviewBasePanel().getLayer() != null) |
153 |
m_viewinfo.setAdditionalInfo(getPreviewBasePanel().getLayer().getName()); |
154 |
m_viewinfo.setTitle(PluginServices.getText(this, "enhanced")); |
155 |
m_viewinfo.setHeight(this.getHeight());
|
156 |
m_viewinfo.setWidth(this.getWidth());
|
157 |
return m_viewinfo;
|
158 |
} |
159 |
|
160 |
public void windowClosed() {} |
161 |
public void windowActivated() {} |
162 |
|
163 |
/**
|
164 |
* @return the filteredPreview
|
165 |
*/
|
166 |
public PreviewFiltering getFilteredPreview() {
|
167 |
return filteredPreview;
|
168 |
} |
169 |
|
170 |
/**
|
171 |
* @return the viewName
|
172 |
*/
|
173 |
public String getViewName() { |
174 |
return viewName;
|
175 |
} |
176 |
} |