root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / EnhancedDialog.java @ 20947
History | View | Annotate | Download (5.85 KB)
1 | 19135 | nbrodin | /* 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 | 19535 | bsanchez | import java.awt.GridBagConstraints; |
24 | import java.awt.GridBagLayout; |
||
25 | 19135 | nbrodin | import java.util.ArrayList; |
26 | |||
27 | import javax.swing.JPanel; |
||
28 | |||
29 | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
||
30 | 20648 | nbrodin | import org.gvsig.raster.beans.createlayer.CreateLayerPanel; |
31 | 19135 | nbrodin | import org.gvsig.raster.beans.previewbase.PreviewBasePanel; |
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 | 19564 | bsanchez | import com.iver.cit.gvsig.project.documents.view.gui.View; |
38 | 19135 | nbrodin | /**
|
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 | 19564 | bsanchez | private static final long serialVersionUID = -5374834293534046986L; |
46 | 19135 | nbrodin | |
47 | 19564 | bsanchez | 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 | 20648 | nbrodin | private CreateLayerPanel layerPanel = null; |
53 | 19564 | bsanchez | private String viewName = null; |
54 | 19135 | nbrodin | |
55 | /**
|
||
56 | * Constructor
|
||
57 | 19205 | nbrodin | * @param lyr Capa raster sobre la que se opera
|
58 | * @param lyrs Lista de capas cargadas en el TOC
|
||
59 | 19135 | nbrodin | * @param width Ancho
|
60 | * @param height Alto
|
||
61 | */
|
||
62 | 19205 | nbrodin | public EnhancedDialog(FLyrRasterSE lyr, ArrayList lyrs, int width, int height) { |
63 | 19135 | nbrodin | this.setPreferredSize(new Dimension(width, height)); |
64 | this.setSize(width, height);
|
||
65 | this.setLayout(new BorderLayout(5, 5)); |
||
66 | 19978 | bsanchez | this.lyr = lyr;
|
67 | 19135 | nbrodin | |
68 | 19978 | bsanchez | graphicsPanel = new GraphicsPanel(this.lyr); |
69 | 19307 | nbrodin | filteredPreview = new PreviewFiltering();
|
70 | 19978 | bsanchez | filteredPreview.setFilterStatus(this.lyr.getRender().getFilterList().getStatusCloned());
|
71 | controlsPanel = new SelectorsPanel(this.lyr, lyrs); |
||
72 | 19280 | nbrodin | |
73 | 19535 | bsanchez | this.add(getPreviewBasePanel(), BorderLayout.CENTER); |
74 | 19280 | nbrodin | |
75 | 20057 | bsanchez | EnhancedListener listener = new EnhancedListener(controlsPanel, graphicsPanel, this, filteredPreview); |
76 | |||
77 | listener.firstLoad(); |
||
78 | |||
79 | 19296 | nbrodin | graphicsPanel.setListener(listener); |
80 | 19280 | nbrodin | |
81 | 19978 | bsanchez | graphicsPanel.updateHistogram(); |
82 | listener.updatePreview(); |
||
83 | |||
84 | 19564 | bsanchez | View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
85 | viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle(); |
||
86 | |||
87 | getPreviewBasePanel().getButtonsPanel().addButtonPressedListener(listener); |
||
88 | |||
89 | previewBasePanel.refreshPreview(); |
||
90 | 19135 | nbrodin | } |
91 | |||
92 | /**
|
||
93 | * Obtiene el panel con el histograma
|
||
94 | * @return HistogramPanel
|
||
95 | */
|
||
96 | public PreviewBasePanel getPreviewBasePanel() {
|
||
97 | 19489 | bsanchez | if (previewBasePanel == null) { |
98 | 19135 | nbrodin | ArrayList list = new ArrayList(); |
99 | list.add(graphicsPanel); |
||
100 | 19535 | bsanchez | |
101 | JPanel downPreview = new JPanel(); |
||
102 | 20840 | bsanchez | getNewOrSaveLayerPanel().setLabelFilename("");
|
103 | 19535 | bsanchez | downPreview.setLayout(new GridBagLayout()); |
104 | |||
105 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
||
106 | gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||
107 | 20840 | bsanchez | downPreview.add(getNewOrSaveLayerPanel().getJPanel(), gridBagConstraints); |
108 | 19535 | bsanchez | |
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 | 19564 | bsanchez | downPreview.add(getNewOrSaveLayerPanel().getFileNamePanel(), gridBagConstraints); |
117 | 19535 | bsanchez | |
118 | previewBasePanel = new PreviewBasePanel(list, controlsPanel, downPreview, filteredPreview, lyr);
|
||
119 | 19135 | nbrodin | } |
120 | 19489 | bsanchez | return previewBasePanel;
|
121 | 19135 | nbrodin | } |
122 | 19280 | nbrodin | |
123 | /**
|
||
124 | 19564 | bsanchez | * Devuelve un Panel para el guardado de capas en disco o en memoria.
|
125 | */
|
||
126 | 20648 | nbrodin | public CreateLayerPanel getNewOrSaveLayerPanel() {
|
127 | 19564 | bsanchez | if (layerPanel == null) { |
128 | 20648 | nbrodin | layerPanel = new CreateLayerPanel();
|
129 | 19564 | bsanchez | } |
130 | return layerPanel;
|
||
131 | } |
||
132 | |||
133 | /**
|
||
134 | 19280 | nbrodin | * 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 | 19491 | nbrodin | |
144 | /**
|
||
145 | * Obtiene la capa asociada.
|
||
146 | * @return FLyrRasterSE
|
||
147 | */
|
||
148 | public FLyrRasterSE getLayer() {
|
||
149 | return lyr;
|
||
150 | } |
||
151 | 19135 | nbrodin | |
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 | 19457 | bsanchez | public void windowClosed() {} |
167 | 19135 | nbrodin | public void windowActivated() {} |
168 | 19489 | bsanchez | |
169 | /**
|
||
170 | * @return the filteredPreview
|
||
171 | */
|
||
172 | public PreviewFiltering getFilteredPreview() {
|
||
173 | return filteredPreview;
|
||
174 | } |
||
175 | 19564 | bsanchez | |
176 | /**
|
||
177 | * @return the viewName
|
||
178 | */
|
||
179 | public String getViewName() { |
||
180 | return viewName;
|
||
181 | } |
||
182 | 19898 | bsanchez | |
183 | /**
|
||
184 | * @return the graphicsPanel
|
||
185 | */
|
||
186 | public GraphicsPanel getGraphicsPanel() {
|
||
187 | return graphicsPanel;
|
||
188 | } |
||
189 | 19135 | nbrodin | } |