root / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / wizards / projection / RasterProjectionActionsPanel.java @ 31496
History | View | Annotate | Download (7.05 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.gui.wizards.projection; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
|
25 |
import javax.swing.ButtonGroup; |
26 |
import javax.swing.JCheckBox; |
27 |
import javax.swing.JLabel; |
28 |
import javax.swing.JPanel; |
29 |
import javax.swing.JRadioButton; |
30 |
|
31 |
import org.gvsig.andami.PluginServices; |
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
33 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
34 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
35 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
36 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
37 |
import org.gvsig.raster.gui.wizards.FileOpenRaster; |
38 |
|
39 |
/**
|
40 |
* Obtiene el panel con las opciones a realizar con la proyecci?n. Nos ofrece
|
41 |
* las siguientes posibilidades:
|
42 |
* <UL>
|
43 |
* <LI>Cambiar la proyecci?n de la vista</LI>
|
44 |
* <LI>Reproyectar el raster</LI>
|
45 |
* <LI>Ignorar la proyecci?n del raster y cargar</LI>
|
46 |
* <LI>No cargar</LI>
|
47 |
* </UL>
|
48 |
*
|
49 |
* 07/04/2008
|
50 |
* @author Nacho Brodin nachobrodin@gmail.com
|
51 |
*/
|
52 |
public class RasterProjectionActionsPanel extends DefaultButtonsPanel { |
53 |
private static final long serialVersionUID = -3868504818382448187L; |
54 |
|
55 |
public static boolean selectAllFiles = false; |
56 |
private JPanel buttonsPanel = null; |
57 |
private ButtonGroup group = new ButtonGroup(); |
58 |
private JRadioButton changeViewProjection = null; |
59 |
private JRadioButton reproject = null; |
60 |
private JRadioButton ignoreRasterProjection = null; |
61 |
private JRadioButton notLoad = null; |
62 |
private JCheckBox allfiles = null; |
63 |
private FLyrRasterSE lyr = null; |
64 |
|
65 |
/**
|
66 |
* Constructor. Llama al inicializador de componentes gr?ficos.
|
67 |
*/
|
68 |
public RasterProjectionActionsPanel(FLyrRasterSE lyr) {
|
69 |
super(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
|
70 |
this.lyr = lyr;
|
71 |
init(lyr.getName()); |
72 |
setSelection(FileOpenRaster.defaultActionLayer); |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Inicializaci?n de componentes gr?ficos.
|
77 |
*/
|
78 |
public void init(String lyrName) { |
79 |
BorderLayout bl = new BorderLayout(); |
80 |
bl.setVgap(5);
|
81 |
setLayout(bl); |
82 |
add(new JLabel("<html><b>" + lyrName + "</b><BR><BR>" + PluginServices.getText(this, "dif_proj") + "</html>"), BorderLayout.NORTH); |
83 |
add(getButtonsActionPanel(), BorderLayout.CENTER);
|
84 |
add(getCheckOption(), BorderLayout.SOUTH);
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Obtiene el panel con los botones se selecci?n de opci?n.
|
89 |
* @return JPanel
|
90 |
*/
|
91 |
private JPanel getButtonsActionPanel() { |
92 |
if (buttonsPanel == null) { |
93 |
buttonsPanel = new JPanel(); |
94 |
buttonsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "proj_options"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
95 |
|
96 |
group.add(getIgnoreRasterProjectionButton()); |
97 |
group.add(getChangeViewProjectionButton()); |
98 |
group.add(getReprojectButton()); |
99 |
group.add(getNotLoadButton()); |
100 |
|
101 |
buttonsPanel.setLayout(new GridBagLayout()); |
102 |
GridBagConstraints gbc = new GridBagConstraints(); |
103 |
gbc.insets = new java.awt.Insets(0, 5, 5, 0); |
104 |
|
105 |
gbc.gridx = 0;
|
106 |
gbc.gridy = 0;
|
107 |
gbc.weightx = 1;
|
108 |
gbc.anchor = GridBagConstraints.WEST;
|
109 |
buttonsPanel.add(getIgnoreRasterProjectionButton(), gbc); |
110 |
|
111 |
gbc.gridy = 1;
|
112 |
buttonsPanel.add(getReprojectButton(), gbc); |
113 |
|
114 |
gbc.gridy = 2;
|
115 |
buttonsPanel.add(getChangeViewProjectionButton(), gbc); |
116 |
|
117 |
gbc.gridy = 3;
|
118 |
buttonsPanel.add(getNotLoadButton(), gbc); |
119 |
} |
120 |
return buttonsPanel;
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* Obtiene el bot?n de cambio de projecci?n de la vista
|
125 |
* @return
|
126 |
*/
|
127 |
private JRadioButton getChangeViewProjectionButton() { |
128 |
if(changeViewProjection == null) { |
129 |
changeViewProjection = new JRadioButton(PluginServices.getText(this, "change_view_proj")); |
130 |
|
131 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
132 |
if (activeWindow instanceof DefaultViewPanel) { |
133 |
DefaultViewPanel activeView = (org.gvsig.app.project.documents.view.gui.DefaultViewPanel) activeWindow; |
134 |
if (activeView.getMapControl().getMapContext().getLayers().getLayersCount() >= 1) |
135 |
changeViewProjection.setEnabled(false);
|
136 |
} |
137 |
} |
138 |
return changeViewProjection;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Obtiene el bot?n de cambio de reproyecci?n
|
143 |
* @return
|
144 |
*/
|
145 |
private JRadioButton getReprojectButton() { |
146 |
if(reproject == null) { |
147 |
reproject = new JRadioButton(PluginServices.getText(this, "reproject")); |
148 |
reproject.setEnabled(lyr.isReproyectable()); |
149 |
} |
150 |
return reproject;
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* Obtiene el bot?n de ignorar la proyecci?n del raster
|
155 |
* @return
|
156 |
*/
|
157 |
private JRadioButton getIgnoreRasterProjectionButton() { |
158 |
if(ignoreRasterProjection == null) { |
159 |
ignoreRasterProjection = new JRadioButton(PluginServices.getText(this, "ignore_raster_proj")); |
160 |
} |
161 |
return ignoreRasterProjection;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Obtiene el bot?n de no cargar el raster.
|
166 |
* @return
|
167 |
*/
|
168 |
private JRadioButton getNotLoadButton() { |
169 |
if(notLoad == null) { |
170 |
notLoad = new JRadioButton(PluginServices.getText(this, "not_load")); |
171 |
} |
172 |
return notLoad;
|
173 |
} |
174 |
|
175 |
/**
|
176 |
* Obtiene la selecci?n del panel
|
177 |
* @return entero con la selecci?n. Esta representada por las constantes de FileOpenRaster.
|
178 |
*/
|
179 |
public int getSelection() { |
180 |
if (getChangeViewProjectionButton().isSelected())
|
181 |
return FileOpenRaster.CHANGE_VIEW_PROJECTION;
|
182 |
if (getReprojectButton().isSelected())
|
183 |
return FileOpenRaster.REPROJECT;
|
184 |
if (getIgnoreRasterProjectionButton().isSelected())
|
185 |
return FileOpenRaster.IGNORE;
|
186 |
if (getNotLoadButton().isSelected())
|
187 |
return FileOpenRaster.NOTLOAD;
|
188 |
return -1; |
189 |
} |
190 |
|
191 |
/**
|
192 |
* Asigna una selecci?n de opci?n
|
193 |
* @param entero con la selecci?n. Esta representada por las constantes de FileOpenRaster.
|
194 |
*/
|
195 |
public void setSelection(int value) { |
196 |
if (value == FileOpenRaster.CHANGE_VIEW_PROJECTION)
|
197 |
getChangeViewProjectionButton().setSelected(true);
|
198 |
if (value == FileOpenRaster.REPROJECT)
|
199 |
getReprojectButton().setSelected(true);
|
200 |
if (value == FileOpenRaster.IGNORE)
|
201 |
getIgnoreRasterProjectionButton().setSelected(true);
|
202 |
if (value == FileOpenRaster.NOTLOAD)
|
203 |
getNotLoadButton().setSelected(true);
|
204 |
} |
205 |
|
206 |
/**
|
207 |
* Obtiene el check con la opci?n de aplicar a todos los ficheros
|
208 |
* @return
|
209 |
*/
|
210 |
public JCheckBox getCheckOption() { |
211 |
if (allfiles == null) |
212 |
allfiles = new JCheckBox(PluginServices.getText(this, "apply_all")); |
213 |
return allfiles;
|
214 |
} |
215 |
} |