gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.app / org.gvsig.raster.app.common / src / main / java / org / gvsig / raster / mainplugin / beans / createlayer / CreateLayerPanel.java @ 2861
History | View | Annotate | Download (6.96 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.mainplugin.beans.createlayer; |
23 |
|
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
import java.awt.event.ItemEvent; |
28 |
import java.awt.event.ItemListener; |
29 |
|
30 |
import javax.swing.BorderFactory; |
31 |
import javax.swing.ButtonGroup; |
32 |
import javax.swing.JPanel; |
33 |
import javax.swing.JRadioButton; |
34 |
|
35 |
import org.gvsig.andami.PluginServices; |
36 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
37 |
|
38 |
/**
|
39 |
* Panel para unificar las propiedades de generacion de capas nuevas en ficheros
|
40 |
* o solo en visualizacion.
|
41 |
*
|
42 |
* @version 10/03/2008
|
43 |
* @author BorSanZa - Borja S?nchez Zamorano
|
44 |
*/
|
45 |
public class CreateLayerPanel { |
46 |
private JPanel panel = null; |
47 |
private JRadioButton jRBOnlyView = null; |
48 |
private JRadioButton jRBNewLayer = null; |
49 |
private NewLayerPanel panelNewLayer = null; |
50 |
private FLyrRaster lyr = null; |
51 |
|
52 |
/**
|
53 |
* Constructor de un CreateLayerPanel
|
54 |
*/
|
55 |
public CreateLayerPanel(FLyrRaster lyr) {
|
56 |
this.lyr = lyr;
|
57 |
initialize(); |
58 |
translate(); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Disables the new layer option. It is useful for remote
|
63 |
* services
|
64 |
*/
|
65 |
public void disableNewLayer() { |
66 |
getRadioOnlyView().setSelected(true);
|
67 |
getRadioNewLayer().setEnabled(false);
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* Devuelve el panel principal
|
72 |
* @return
|
73 |
*/
|
74 |
public JPanel getJPanel() { |
75 |
if (panel == null) { |
76 |
panel = new JPanel(); |
77 |
} |
78 |
return panel;
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Seccion donde ir?n todas las traducciones invariables del componente
|
83 |
*/
|
84 |
private void translate() { |
85 |
getRadioOnlyView().setText(PluginServices.getText(this, "solo_visualizacion")); |
86 |
getRadioNewLayer().setText(PluginServices.getText(this, "capa_nueva")); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Inicializar el panel de CreateLayer
|
91 |
*/
|
92 |
private void initialize() { |
93 |
ButtonGroup buttonGroup1;
|
94 |
GridBagConstraints gridBagConstraints;
|
95 |
|
96 |
getJPanel().setLayout(new GridBagLayout()); |
97 |
|
98 |
buttonGroup1 = new ButtonGroup(); |
99 |
buttonGroup1.add(getRadioOnlyView()); |
100 |
|
101 |
gridBagConstraints = new GridBagConstraints(); |
102 |
gridBagConstraints.gridx = 0;
|
103 |
gridBagConstraints.gridy = 0;
|
104 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
105 |
gridBagConstraints.insets = new Insets(3, 3, 3, 3); |
106 |
getJPanel().add(getRadioOnlyView(), gridBagConstraints); |
107 |
|
108 |
buttonGroup1.add(getRadioNewLayer()); |
109 |
|
110 |
gridBagConstraints = new GridBagConstraints(); |
111 |
gridBagConstraints.gridx = 0;
|
112 |
gridBagConstraints.gridy = 1;
|
113 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
114 |
gridBagConstraints.insets = new Insets(3, 3, 3, 3); |
115 |
getJPanel().add(getRadioNewLayer(), gridBagConstraints); |
116 |
|
117 |
gridBagConstraints = new GridBagConstraints(); |
118 |
gridBagConstraints.gridx = 0;
|
119 |
gridBagConstraints.gridy = 2;
|
120 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
121 |
gridBagConstraints.insets = new Insets(3, 3, 3, 3); |
122 |
getJPanel().add(getPanelNewLayer().getJPanel(), gridBagConstraints); |
123 |
} |
124 |
|
125 |
public NewLayerPanel getPanelNewLayer() {
|
126 |
if (panelNewLayer == null) |
127 |
panelNewLayer = new NewLayerPanel(lyr);
|
128 |
return panelNewLayer;
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* Poner los estados de los RadioButton en caso de que cambien de valor
|
133 |
* @param evt
|
134 |
*/
|
135 |
private void jRBNewLayerStateChanged(ItemEvent evt) { |
136 |
if (getRadioNewLayer().getSelectedObjects() != null) { |
137 |
getPanelNewLayer().getRadioFileGenerate().setEnabled(true);
|
138 |
getPanelNewLayer().getRadioOpenMemory().setEnabled(true);
|
139 |
if (getPanelNewLayer().getRadioOpenMemory().getSelectedObjects() != null) |
140 |
getPanelNewLayer().setFilenameEnabled(true);
|
141 |
else
|
142 |
getPanelNewLayer().setFilenameEnabled(false);
|
143 |
} else {
|
144 |
getPanelNewLayer().getRadioFileGenerate().setEnabled(false);
|
145 |
getPanelNewLayer().getRadioOpenMemory().setEnabled(false);
|
146 |
getPanelNewLayer().setFilenameEnabled(false);
|
147 |
} |
148 |
} |
149 |
|
150 |
/**
|
151 |
* Especifica si se generara solo en la vista o se guardara en un fichero
|
152 |
* @param enabled
|
153 |
*/
|
154 |
public void setOnlyView(boolean enabled) { |
155 |
getRadioOnlyView().setSelected(enabled); |
156 |
} |
157 |
|
158 |
/**
|
159 |
* Devuelve el JRadioButton de Solo vista
|
160 |
* @return
|
161 |
*/
|
162 |
private JRadioButton getRadioOnlyView() { |
163 |
if (jRBOnlyView == null) { |
164 |
jRBOnlyView = new JRadioButton(); |
165 |
jRBOnlyView.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
166 |
jRBOnlyView.setMargin(new Insets(0, 0, 0, 0)); |
167 |
} |
168 |
return jRBOnlyView;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* Devuelve el JRadioButton de nueva capa
|
173 |
* @return
|
174 |
*/
|
175 |
private JRadioButton getRadioNewLayer() { |
176 |
if (jRBNewLayer == null) { |
177 |
jRBNewLayer = new JRadioButton(); |
178 |
jRBNewLayer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
179 |
jRBNewLayer.setMargin(new Insets(0, 0, 0, 0)); |
180 |
jRBNewLayer.addItemListener(new ItemListener() { |
181 |
public void itemStateChanged(ItemEvent evt) { |
182 |
jRBNewLayerStateChanged(evt); |
183 |
} |
184 |
}); |
185 |
jRBNewLayer.setSelected(true);
|
186 |
} |
187 |
return jRBNewLayer;
|
188 |
} |
189 |
|
190 |
/**
|
191 |
* This method initializes jPNameFile
|
192 |
*
|
193 |
* @return javax.swing.JPanel
|
194 |
*/
|
195 |
public JPanel getFileNamePanel() { |
196 |
return getPanelNewLayer().getFileNamePanel();
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* Establece el texto de la etiqueta del nombre de fichero
|
201 |
* @param text
|
202 |
*/
|
203 |
public void setLabelFilename(String text) { |
204 |
getPanelNewLayer().setLabelFilename(text); |
205 |
} |
206 |
|
207 |
public boolean isNewLayerSelected() { |
208 |
return getRadioNewLayer().isSelected();
|
209 |
} |
210 |
|
211 |
public boolean isOnlyViewSelected() { |
212 |
return getRadioOnlyView().isSelected();
|
213 |
} |
214 |
|
215 |
/**
|
216 |
* Asigna un valor para el par?metro que informa de si el raster de salida hay
|
217 |
* que comprimirlo o no. Este valor es necesario cuando el raster de salida
|
218 |
* es mayor de 4G ya que no se puede crear un tiff tan grande.
|
219 |
* @param compress true para comprimir el raster de salida y false para no hacerlo.
|
220 |
*/
|
221 |
public void setCompress(boolean compress) { |
222 |
getPanelNewLayer().setCompress(compress); |
223 |
} |
224 |
|
225 |
/**
|
226 |
* Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
|
227 |
* en memoria, calcula el nombre sin preguntar y devuelve la ruta.
|
228 |
* @return
|
229 |
*/
|
230 |
public String getFileSelected() { |
231 |
return getPanelNewLayer().getFileSelected();
|
232 |
} |
233 |
|
234 |
public void updateNewLayerText() { |
235 |
getPanelNewLayer().updateNewLayerText(); |
236 |
} |
237 |
} |