Revision 42506 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/General.java
General.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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 3
|
|
9 |
* of the License, or (at your option) any later version.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.app.project.documents.view.legend.gui; |
25 | 24 |
|
... | ... | |
67 | 66 |
import org.gvsig.gui.beans.swing.JBlank; |
68 | 67 |
import org.gvsig.tools.locator.LocatorException; |
69 | 68 |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 | 69 |
/** |
74 |
* This class implements an useful and intuitive graphic interface to change some |
|
75 |
* properties of the layer. This class extends AbstractThemeManager. The properties |
|
76 |
* that allow modified are the name of the layer, the scale, if the user want to use |
|
77 |
* Spatial index or not and the HyperLink. Also shows a scroll with a little resume |
|
78 |
* with the properties of the layer. |
|
79 |
* @author jmorell |
|
80 |
* |
|
81 |
* TODO To change the template for this generated type comment go to |
|
82 |
* Window - Preferences - Java - Code Style - Code Templates |
|
70 |
* @deprecated This tab is outdated and not used. It has been replaced by "GeneralLayerPropertiesPage" |
|
71 |
* @see GeneralLayerPropertiesPage |
|
72 |
|
|
83 | 73 |
*/ |
84 | 74 |
public class General extends AbstractThemeManagerPage { |
85 | 75 |
|
86 |
private static final long serialVersionUID = 1L;
|
|
76 |
private static final long serialVersionUID = 1L;
|
|
87 | 77 |
private FLayer layer; |
88 |
private NumberFormat nf = NumberFormat.getInstance();
|
|
89 |
private JPanel pnlLayerName = null;
|
|
90 |
private GridBagLayoutPanel pnlScale = null;
|
|
91 |
private JPanel pnlProperties = null;
|
|
92 |
private JLabel lblLayerName = null;
|
|
93 |
private JTextField txtLayerName = null;
|
|
94 |
private JTextField txtMaxScale = null;
|
|
95 |
private JTextArea propertiesTextArea = null;
|
|
96 |
private JRadioButton rdBtnShowAlways = null;
|
|
97 |
private JRadioButton rdBtnDoNotShow = null;
|
|
98 |
private JTextField txtMinScale = null;
|
|
99 |
private JScrollPane scrlProperties;
|
|
78 |
private NumberFormat nf = NumberFormat.getInstance();
|
|
79 |
private JPanel pnlLayerName = null;
|
|
80 |
private GridBagLayoutPanel pnlScale = null;
|
|
81 |
private JPanel pnlProperties = null;
|
|
82 |
private JLabel lblLayerName = null;
|
|
83 |
private JTextField txtLayerName = null;
|
|
84 |
private JTextField txtMaxScale = null;
|
|
85 |
private JTextArea propertiesTextArea = null;
|
|
86 |
private JRadioButton rdBtnShowAlways = null;
|
|
87 |
private JRadioButton rdBtnDoNotShow = null;
|
|
88 |
private JTextField txtMinScale = null;
|
|
89 |
private JScrollPane scrlProperties;
|
|
100 | 90 |
|
101 | 91 |
/** |
102 |
* This is the default constructor. |
|
103 |
*/ |
|
104 |
public General() { |
|
105 |
super(); |
|
106 |
initialize(); |
|
107 |
} |
|
108 |
/** |
|
109 |
* This method initializes this |
|
110 |
* |
|
111 |
* @return void |
|
112 |
*/ |
|
113 |
private void initialize() { |
|
114 |
this.setLayout(new BorderLayout()); |
|
115 |
GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
116 |
aux.addComponent(getPnlLayerName()); |
|
117 |
aux.addComponent(new JBlank(10, 10)); |
|
118 |
aux.addComponent("", getPnlScale()); |
|
119 |
JPanel aux2 = new JPanel(new GridLayout(1,2)); |
|
120 |
aux2.add(getPnlProperties()); |
|
121 |
aux.addComponent(aux2); |
|
92 |
* This is the default constructor. |
|
93 |
*/ |
|
94 |
public General() { |
|
95 |
super(); |
|
96 |
initialize(); |
|
97 |
} |
|
122 | 98 |
|
99 |
/** |
|
100 |
* This method initializes this |
|
101 |
* |
|
102 |
* @return void |
|
103 |
*/ |
|
104 |
private void initialize() { |
|
105 |
this.setLayout(new BorderLayout()); |
|
106 |
GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
107 |
aux.addComponent(getPnlLayerName()); |
|
108 |
aux.addComponent(new JBlank(10, 10)); |
|
109 |
aux.addComponent("", getPnlScale()); |
|
110 |
JPanel aux2 = new JPanel(new GridLayout(1, 2)); |
|
111 |
aux2.add(getPnlProperties()); |
|
112 |
aux.addComponent(aux2); |
|
123 | 113 |
|
114 |
aux.setPreferredSize(getPreferredSize()); |
|
115 |
this.add(aux, BorderLayout.CENTER); |
|
116 |
this.add(new JBlank(5, 10), BorderLayout.WEST); |
|
117 |
this.add(new JBlank(5, 10), BorderLayout.EAST); |
|
124 | 118 |
|
125 |
aux.setPreferredSize(getPreferredSize()); |
|
126 |
this.add(aux, BorderLayout.CENTER); |
|
127 |
this.add(new JBlank(5, 10), BorderLayout.WEST); |
|
128 |
this.add(new JBlank(5, 10), BorderLayout.EAST); |
|
119 |
} |
|
129 | 120 |
|
130 |
} |
|
131 |
|
|
132 | 121 |
@Override |
133 | 122 |
public int getPriority() { |
134 | 123 |
return 1000; |
135 | 124 |
} |
136 | 125 |
|
137 |
|
|
126 |
/** |
|
127 |
* Sets the necessary properties in the panel. This properties are extracted |
|
128 |
* from the layer. With this properties fills the TextFields, ComboBoxes and |
|
129 |
* the rest of GUI components. |
|
130 |
* |
|
131 |
* @param FLayer layer, |
|
132 |
*/ |
|
133 |
public void setModel(FLayer layer) { |
|
134 |
this.layer = layer; |
|
138 | 135 |
|
139 |
/** |
|
140 |
* Sets the necessary properties in the panel. This properties are |
|
141 |
* extracted from the layer. With this properties fills the TextFields, |
|
142 |
* ComboBoxes and the rest of GUI components. |
|
143 |
* @param FLayer layer, |
|
144 |
*/ |
|
145 |
public void setModel(FLayer layer) { |
|
146 |
this.layer = layer; |
|
136 |
if (layer.getMinScale() != -1) { |
|
137 |
getTxtMaxScale().setText(nf.format(layer.getMinScale())); |
|
138 |
} |
|
139 |
if (layer.getMaxScale() != -1) { |
|
140 |
getTxtMinScale().setText(nf.format(layer.getMaxScale())); |
|
141 |
} |
|
142 |
if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) { |
|
143 |
getRdBtnShowAlways().setSelected(true); |
|
144 |
txtMaxScale.setEnabled(false); |
|
145 |
txtMinScale.setEnabled(false); |
|
147 | 146 |
|
148 |
if (layer.getMinScale() != -1) { |
|
149 |
getTxtMaxScale().setText(nf.format(layer.getMinScale())); |
|
150 |
} |
|
151 |
if (layer.getMaxScale() != -1) { |
|
152 |
getTxtMinScale().setText(nf.format(layer.getMaxScale())); |
|
153 |
} |
|
154 |
if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) { |
|
155 |
getRdBtnShowAlways().setSelected(true); |
|
156 |
txtMaxScale.setEnabled(false); |
|
157 |
txtMinScale.setEnabled(false); |
|
147 |
} else { |
|
148 |
getRdBtnDoNotShowWhen().setSelected(true); |
|
149 |
txtMaxScale.setEnabled(true); |
|
150 |
txtMinScale.setEnabled(true); |
|
151 |
} |
|
152 |
txtLayerName.setText(layer.getName()); |
|
153 |
showLayerInfo(); |
|
158 | 154 |
|
159 |
} else { |
|
160 |
getRdBtnDoNotShowWhen().setSelected(true); |
|
161 |
txtMaxScale.setEnabled(true); |
|
162 |
txtMinScale.setEnabled(true); |
|
163 |
} |
|
164 |
txtLayerName.setText(layer.getName()); |
|
165 |
showLayerInfo(); |
|
155 |
} |
|
166 | 156 |
|
167 |
} |
|
157 |
/** |
|
158 |
* This method initializes jPanel |
|
159 |
* |
|
160 |
* @return javax.swing.JPanel |
|
161 |
*/ |
|
162 |
private JPanel getPnlLayerName() { |
|
163 |
if (pnlLayerName == null) { |
|
164 |
lblLayerName = new JLabel(); |
|
165 |
pnlLayerName = new JPanel(); |
|
166 |
lblLayerName.setText(PluginServices.getText(this, "Nombre") + ":"); |
|
167 |
lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN); |
|
168 |
pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN); |
|
169 |
pnlLayerName.add(lblLayerName, null); |
|
170 |
pnlLayerName.add(getTxtLayerName(), null); |
|
171 |
} |
|
172 |
return pnlLayerName; |
|
173 |
} |
|
168 | 174 |
|
169 |
/** |
|
170 |
* This method initializes jPanel |
|
171 |
* |
|
172 |
* @return javax.swing.JPanel |
|
173 |
*/ |
|
174 |
private JPanel getPnlLayerName() { |
|
175 |
if (pnlLayerName == null) { |
|
176 |
lblLayerName = new JLabel(); |
|
177 |
pnlLayerName = new JPanel(); |
|
178 |
lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":"); |
|
179 |
lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN); |
|
180 |
pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN); |
|
181 |
pnlLayerName.add(lblLayerName, null); |
|
182 |
pnlLayerName.add(getTxtLayerName(), null); |
|
183 |
} |
|
184 |
return pnlLayerName; |
|
185 |
} |
|
186 |
/** |
|
187 |
* This method initializes jPanel1 |
|
188 |
* |
|
189 |
* @return javax.swing.JPanel |
|
190 |
*/ |
|
191 |
private GridBagLayoutPanel getPnlScale() { |
|
192 |
if (pnlScale == null) { |
|
193 |
pnlScale = new GridBagLayoutPanel(); |
|
194 |
pnlScale.setBorder(BorderFactory.createTitledBorder( |
|
195 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
196 |
PluginServices.getText(this, "rango_de_escalas"), |
|
197 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
198 |
TitledBorder.DEFAULT_POSITION, null, null) |
|
199 |
); |
|
200 |
ButtonGroup buttonGroup = new ButtonGroup(); |
|
201 |
buttonGroup.add(getRdBtnShowAlways()); |
|
202 |
buttonGroup.add(getRdBtnDoNotShowWhen()); |
|
203 |
pnlScale.addComponent(getRdBtnShowAlways()); |
|
204 |
pnlScale.addComponent(getRdBtnDoNotShowWhen()); |
|
205 |
JPanel aux; |
|
175 |
/** |
|
176 |
* This method initializes jPanel1 |
|
177 |
* |
|
178 |
* @return javax.swing.JPanel |
|
179 |
*/ |
|
180 |
private GridBagLayoutPanel getPnlScale() { |
|
181 |
if (pnlScale == null) { |
|
182 |
pnlScale = new GridBagLayoutPanel(); |
|
183 |
pnlScale.setBorder(BorderFactory.createTitledBorder( |
|
184 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
185 |
PluginServices.getText(this, "rango_de_escalas"), |
|
186 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
187 |
TitledBorder.DEFAULT_POSITION, null, null) |
|
188 |
); |
|
189 |
ButtonGroup buttonGroup = new ButtonGroup(); |
|
190 |
buttonGroup.add(getRdBtnShowAlways()); |
|
191 |
buttonGroup.add(getRdBtnDoNotShowWhen()); |
|
192 |
pnlScale.addComponent(getRdBtnShowAlways()); |
|
193 |
pnlScale.addComponent(getRdBtnDoNotShowWhen()); |
|
194 |
JPanel aux; |
|
206 | 195 |
|
196 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
197 |
aux.add(getTxtMaxScale()); |
|
198 |
aux.add(new JLabel("(" + PluginServices.getText(this, "escala_maxima") + ")")); |
|
207 | 199 |
|
208 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
209 |
aux.add(getTxtMaxScale()); |
|
210 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")")); |
|
200 |
GridBagLayoutPanel aux2; |
|
201 |
aux2 = new GridBagLayoutPanel(); |
|
202 |
aux2.addComponent(PluginServices.getText( |
|
203 |
this, "este_por_encima_de") + " 1:", |
|
204 |
aux); |
|
205 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
206 |
aux.add(getTxtMinScale()); |
|
207 |
aux.add(new JLabel("(" + PluginServices.getText(this, "escala_minima") + ")")); |
|
211 | 208 |
|
212 |
GridBagLayoutPanel aux2; |
|
213 |
aux2 = new GridBagLayoutPanel(); |
|
214 |
aux2.addComponent(PluginServices.getText( |
|
215 |
this,"este_por_encima_de")+" 1:", |
|
216 |
aux); |
|
217 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
218 |
aux.add(getTxtMinScale()); |
|
219 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")")); |
|
209 |
aux2.addComponent(PluginServices.getText( |
|
210 |
this, "este_por_debajo_de_") + " 1:", |
|
211 |
aux); |
|
220 | 212 |
|
221 |
aux2.addComponent(PluginServices.getText( |
|
222 |
this,"este_por_debajo_de_")+" 1:", |
|
223 |
aux); |
|
213 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
|
224 | 214 |
|
225 |
pnlScale.addComponent(new JBlank(20, 1), aux2);
|
|
215 |
pnlScale.addComponent(new JBlank(20, 1), aux2);
|
|
226 | 216 |
|
227 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
|
217 |
} |
|
218 |
return pnlScale; |
|
219 |
} |
|
228 | 220 |
|
229 |
} |
|
230 |
return pnlScale; |
|
231 |
} |
|
232 |
/** |
|
233 |
* This method initializes jPanel2, this contains the ScrollPane with the |
|
234 |
* properies. |
|
235 |
* |
|
236 |
* @return javax.swing.JPanel |
|
237 |
*/ |
|
238 |
private JPanel getPnlProperties() { |
|
239 |
if (pnlProperties == null) { |
|
240 |
pnlProperties = new JPanel(); |
|
241 |
pnlProperties.setBorder(BorderFactory.createTitledBorder( |
|
242 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
243 |
PluginServices.getText(this, "propiedades"), |
|
244 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
245 |
TitledBorder.DEFAULT_POSITION, null, null) |
|
246 |
); |
|
247 |
pnlProperties.add(getScrlProperties(), null); |
|
248 |
} |
|
249 |
return pnlProperties; |
|
250 |
} |
|
221 |
/** |
|
222 |
* This method initializes jPanel2, this contains the ScrollPane with the |
|
223 |
* properies. |
|
224 |
* |
|
225 |
* @return javax.swing.JPanel |
|
226 |
*/ |
|
227 |
private JPanel getPnlProperties() { |
|
228 |
if (pnlProperties == null) { |
|
229 |
pnlProperties = new JPanel(); |
|
230 |
pnlProperties.setBorder(BorderFactory.createTitledBorder( |
|
231 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
232 |
PluginServices.getText(this, "propiedades"), |
|
233 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
234 |
TitledBorder.DEFAULT_POSITION, null, null) |
|
235 |
); |
|
236 |
pnlProperties.add(getScrlProperties(), null); |
|
237 |
} |
|
238 |
return pnlProperties; |
|
239 |
} |
|
251 | 240 |
|
252 |
/**
|
|
253 |
* This method initializes jTextField
|
|
254 |
*
|
|
255 |
* @return javax.swing.JTextField
|
|
256 |
*/
|
|
257 |
private JTextField getTxtLayerName() {
|
|
258 |
if (txtLayerName == null) {
|
|
259 |
txtLayerName = new JTextField(25);
|
|
260 |
txtLayerName.setEditable(false);
|
|
261 |
}
|
|
262 |
return txtLayerName;
|
|
263 |
}
|
|
241 |
/**
|
|
242 |
* This method initializes jTextField
|
|
243 |
*
|
|
244 |
* @return javax.swing.JTextField
|
|
245 |
*/
|
|
246 |
private JTextField getTxtLayerName() {
|
|
247 |
if (txtLayerName == null) {
|
|
248 |
txtLayerName = new JTextField(25);
|
|
249 |
txtLayerName.setEditable(false);
|
|
250 |
}
|
|
251 |
return txtLayerName;
|
|
252 |
}
|
|
264 | 253 |
|
265 |
/** |
|
266 |
* This method initializes TxtMaxScale |
|
267 |
* @return jTextField1 |
|
268 |
*/ |
|
269 |
private JTextField getTxtMaxScale() { |
|
270 |
if (txtMaxScale == null) { |
|
271 |
txtMaxScale = new JTextField(15); |
|
272 |
txtMaxScale.setEnabled(false); |
|
273 |
} |
|
274 |
return txtMaxScale; |
|
275 |
} |
|
276 |
/** |
|
277 |
* This method initilizes TxtArea, in this TextArea sets the text with |
|
278 |
* the properties of the layer |
|
279 |
* @return |
|
280 |
*/ |
|
281 |
private JTextArea getPropertiesTextArea() { |
|
282 |
if (propertiesTextArea == null) { |
|
283 |
propertiesTextArea = new JTextArea(); |
|
284 |
propertiesTextArea.setEditable(false); |
|
285 |
propertiesTextArea.setBackground(SystemColor.control); |
|
254 |
/** |
|
255 |
* This method initializes TxtMaxScale |
|
256 |
* |
|
257 |
* @return jTextField1 |
|
258 |
*/ |
|
259 |
private JTextField getTxtMaxScale() { |
|
260 |
if (txtMaxScale == null) { |
|
261 |
txtMaxScale = new JTextField(15); |
|
262 |
txtMaxScale.setEnabled(false); |
|
263 |
} |
|
264 |
return txtMaxScale; |
|
265 |
} |
|
286 | 266 |
|
287 |
} |
|
288 |
return propertiesTextArea; |
|
289 |
} |
|
267 |
/** |
|
268 |
* This method initilizes TxtArea, in this TextArea sets the text with the |
|
269 |
* properties of the layer |
|
270 |
* |
|
271 |
* @return |
|
272 |
*/ |
|
273 |
private JTextArea getPropertiesTextArea() { |
|
274 |
if (propertiesTextArea == null) { |
|
275 |
propertiesTextArea = new JTextArea(); |
|
276 |
propertiesTextArea.setEditable(false); |
|
277 |
propertiesTextArea.setBackground(SystemColor.control); |
|
290 | 278 |
|
291 |
/** |
|
292 |
* This method initializes jScrollPane |
|
293 |
* |
|
294 |
* @return javax.swing.JScrollPane |
|
295 |
*/ |
|
296 |
private JScrollPane getScrlProperties() { |
|
297 |
if (scrlProperties == null) { |
|
298 |
scrlProperties = new JScrollPane(); |
|
299 |
scrlProperties.setViewportView(getPropertiesTextArea()); |
|
300 |
scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
|
301 |
scrlProperties.setPreferredSize(new Dimension(350, 180)); |
|
302 |
} |
|
303 |
return scrlProperties; |
|
304 |
} |
|
305 |
/** |
|
306 |
* This method initializes jRadioButton |
|
307 |
* |
|
308 |
* @return javax.swing.JRadioButton |
|
309 |
*/ |
|
310 |
private JRadioButton getRdBtnShowAlways() { |
|
311 |
if (rdBtnShowAlways == null) { |
|
312 |
rdBtnShowAlways = new JRadioButton(); |
|
313 |
rdBtnShowAlways.setText(PluginServices.getText(this,"Mostrar_siempre")); |
|
314 |
rdBtnShowAlways.setSelected(true); |
|
315 |
rdBtnShowAlways.addActionListener(new ActionListener() { |
|
316 |
public void actionPerformed(ActionEvent e) { |
|
317 |
txtMaxScale.setEnabled(false); |
|
318 |
txtMinScale.setEnabled(false); |
|
319 |
} |
|
320 |
}); |
|
321 |
} |
|
322 |
return rdBtnShowAlways; |
|
323 |
} |
|
324 |
/** |
|
325 |
* This method initializes jRadioButton1 |
|
326 |
* |
|
327 |
* @return javax.swing.JRadioButton |
|
328 |
*/ |
|
329 |
private JRadioButton getRdBtnDoNotShowWhen() { |
|
330 |
if (rdBtnDoNotShow == null) { |
|
331 |
rdBtnDoNotShow = new JRadioButton(); |
|
332 |
rdBtnDoNotShow.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala")); |
|
333 |
rdBtnDoNotShow.addActionListener(new ActionListener() { |
|
334 |
public void actionPerformed(ActionEvent e) { |
|
335 |
txtMaxScale.setEnabled(true); |
|
336 |
txtMinScale.setEnabled(true); |
|
337 |
} |
|
338 |
}); |
|
339 |
} |
|
340 |
return rdBtnDoNotShow; |
|
341 |
} |
|
342 |
/** |
|
343 |
* This method initializes jTextField2 |
|
344 |
* |
|
345 |
* @return javax.swing.JTextField |
|
346 |
*/ |
|
347 |
private JTextField getTxtMinScale() { |
|
348 |
if (txtMinScale == null) { |
|
349 |
txtMinScale = new JTextField(15); |
|
350 |
txtMinScale.setEnabled(false); |
|
351 |
} |
|
352 |
return txtMinScale; |
|
353 |
} |
|
279 |
} |
|
280 |
return propertiesTextArea; |
|
281 |
} |
|
354 | 282 |
|
355 |
private String getLayerName(){ |
|
356 |
return txtLayerName.getText().toString(); |
|
357 |
} |
|
283 |
/** |
|
284 |
* This method initializes jScrollPane |
|
285 |
* |
|
286 |
* @return javax.swing.JScrollPane |
|
287 |
*/ |
|
288 |
private JScrollPane getScrlProperties() { |
|
289 |
if (scrlProperties == null) { |
|
290 |
scrlProperties = new JScrollPane(); |
|
291 |
scrlProperties.setViewportView(getPropertiesTextArea()); |
|
292 |
scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
|
293 |
scrlProperties.setPreferredSize(new Dimension(350, 180)); |
|
294 |
} |
|
295 |
return scrlProperties; |
|
296 |
} |
|
358 | 297 |
|
359 | 298 |
/** |
299 |
* This method initializes jRadioButton |
|
300 |
* |
|
301 |
* @return javax.swing.JRadioButton |
|
302 |
*/ |
|
303 |
private JRadioButton getRdBtnShowAlways() { |
|
304 |
if (rdBtnShowAlways == null) { |
|
305 |
rdBtnShowAlways = new JRadioButton(); |
|
306 |
rdBtnShowAlways.setText(PluginServices.getText(this, "Mostrar_siempre")); |
|
307 |
rdBtnShowAlways.setSelected(true); |
|
308 |
rdBtnShowAlways.addActionListener(new ActionListener() { |
|
309 |
public void actionPerformed(ActionEvent e) { |
|
310 |
txtMaxScale.setEnabled(false); |
|
311 |
txtMinScale.setEnabled(false); |
|
312 |
} |
|
313 |
}); |
|
314 |
} |
|
315 |
return rdBtnShowAlways; |
|
316 |
} |
|
317 |
|
|
318 |
/** |
|
319 |
* This method initializes jRadioButton1 |
|
320 |
* |
|
321 |
* @return javax.swing.JRadioButton |
|
322 |
*/ |
|
323 |
private JRadioButton getRdBtnDoNotShowWhen() { |
|
324 |
if (rdBtnDoNotShow == null) { |
|
325 |
rdBtnDoNotShow = new JRadioButton(); |
|
326 |
rdBtnDoNotShow.setText(PluginServices.getText(this, "No_mostrar_la_capa_cuando_la_escala")); |
|
327 |
rdBtnDoNotShow.addActionListener(new ActionListener() { |
|
328 |
public void actionPerformed(ActionEvent e) { |
|
329 |
txtMaxScale.setEnabled(true); |
|
330 |
txtMinScale.setEnabled(true); |
|
331 |
} |
|
332 |
}); |
|
333 |
} |
|
334 |
return rdBtnDoNotShow; |
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* This method initializes jTextField2 |
|
339 |
* |
|
340 |
* @return javax.swing.JTextField |
|
341 |
*/ |
|
342 |
private JTextField getTxtMinScale() { |
|
343 |
if (txtMinScale == null) { |
|
344 |
txtMinScale = new JTextField(15); |
|
345 |
txtMinScale.setEnabled(false); |
|
346 |
} |
|
347 |
return txtMinScale; |
|
348 |
} |
|
349 |
|
|
350 |
private String getLayerName() { |
|
351 |
return txtLayerName.getText().toString(); |
|
352 |
} |
|
353 |
|
|
354 |
/** |
|
360 | 355 |
* Add the information of the layer to the textArea |
361 | 356 |
*/ |
362 | 357 |
private void showLayerInfo() { |
363 |
try { |
|
364 |
String info = ((FLyrDefault)layer).getInfoString(); |
|
365 |
if (info == null) { |
|
366 |
StringBuffer buff= new StringBuffer(); |
|
367 |
Envelope fullExtentViewPort = layer.getFullEnvelope(); |
|
368 |
IProjection viewPortProj = layer.getMapContext().getProjection(); |
|
369 |
buff.append(PluginServices.getText(this,"Extent")); |
|
370 |
buff.append(" "); |
|
371 |
buff.append(viewPortProj.getAbrev()); |
|
372 |
buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t"); |
|
373 |
buff.append(PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaximum(1) + "\n\t"); |
|
374 |
buff.append(PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinimum(1) + "\n\t"); |
|
375 |
buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinimum(0) + "\n\t"); |
|
376 |
buff.append(PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaximum(0) + "\n"); |
|
377 |
// show layer native projection |
|
378 |
if (layer.getProjection() != null |
|
379 |
&& !layer.getProjection().getAbrev().equals( |
|
380 |
viewPortProj.getAbrev())) { |
|
381 |
IProjection nativeLayerProj = layer.getProjection(); |
|
382 |
ICoordTrans ct = viewPortProj.getCT(nativeLayerProj); |
|
383 |
// Rectangle2D r=new Rectangle2D.Double(fullExtentViewPort.getMinimum(0),fullExtentViewPort.getMinimum(1),fullExtentViewPort.getLength(0),fullExtentViewPort.getLength(1)); |
|
384 |
// Rectangle2D nativeLayerExtent = ct.convert(r); |
|
385 |
Envelope nativeLayerExtent = fullExtentViewPort.convert(ct); |
|
386 |
buff.append(PluginServices.getText(this,"Extent") + " "); |
|
387 |
buff.append(nativeLayerProj.getAbrev()); |
|
388 |
buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t"); |
|
389 |
buff.append(PluginServices.getText(this, "Superior") |
|
390 |
+ ":\t" + nativeLayerExtent.getMaximum(1) + "\n\t"); |
|
391 |
buff.append(PluginServices.getText(this, "Inferior") |
|
392 |
+ ":\t" + nativeLayerExtent.getMinimum(1) + "\n\t"); |
|
393 |
buff.append(PluginServices.getText(this, "Izquierda") |
|
394 |
+ ":\t" + nativeLayerExtent.getMinimum(0) + "\n\t"); |
|
395 |
buff.append(PluginServices.getText(this, "Derecha") + ":\t" |
|
396 |
+ nativeLayerExtent.getMaximum(0) + "\n"); |
|
358 |
try { |
|
359 |
String info = ((FLyrDefault) layer).getInfoString(); |
|
360 |
if (info == null) { |
|
361 |
StringBuffer buff = new StringBuffer(); |
|
362 |
Envelope fullExtentViewPort = layer.getFullEnvelope(); |
|
363 |
IProjection viewPortProj = layer.getMapContext().getProjection(); |
|
364 |
buff.append(PluginServices.getText(this, "Extent")); |
|
365 |
buff.append(" "); |
|
366 |
buff.append(viewPortProj.getAbrev()); |
|
367 |
buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t"); |
|
368 |
buff.append(PluginServices.getText(this, "Superior") + ":\t" + fullExtentViewPort.getMaximum(1) + "\n\t"); |
|
369 |
buff.append(PluginServices.getText(this, "Inferior") + ":\t" + fullExtentViewPort.getMinimum(1) + "\n\t"); |
|
370 |
buff.append(PluginServices.getText(this, "Izquierda") + ":\t" + fullExtentViewPort.getMinimum(0) + "\n\t"); |
|
371 |
buff.append(PluginServices.getText(this, "Derecha") + ":\t" + fullExtentViewPort.getMaximum(0) + "\n"); |
|
372 |
// show layer native projection |
|
373 |
if (layer.getProjection() != null |
|
374 |
&& !layer.getProjection().getAbrev().equals( |
|
375 |
viewPortProj.getAbrev())) { |
|
376 |
IProjection nativeLayerProj = layer.getProjection(); |
|
377 |
ICoordTrans ct = viewPortProj.getCT(nativeLayerProj); |
|
378 |
Envelope nativeLayerExtent = fullExtentViewPort.convert(ct); |
|
379 |
buff.append(PluginServices.getText(this, "Extent") + " "); |
|
380 |
buff.append(nativeLayerProj.getAbrev()); |
|
381 |
buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t"); |
|
382 |
buff.append(PluginServices.getText(this, "Superior") |
|
383 |
+ ":\t" + nativeLayerExtent.getMaximum(1) + "\n\t"); |
|
384 |
buff.append(PluginServices.getText(this, "Inferior") |
|
385 |
+ ":\t" + nativeLayerExtent.getMinimum(1) + "\n\t"); |
|
386 |
buff.append(PluginServices.getText(this, "Izquierda") |
|
387 |
+ ":\t" + nativeLayerExtent.getMinimum(0) + "\n\t"); |
|
388 |
buff.append(PluginServices.getText(this, "Derecha") + ":\t" |
|
389 |
+ nativeLayerExtent.getMaximum(0) + "\n"); |
|
397 | 390 |
|
398 |
}
|
|
399 |
if (layer instanceof FLyrVect) {
|
|
400 |
FeatureStore fStore=((FLyrVect)layer).getFeatureStore();
|
|
391 |
}
|
|
392 |
if (layer instanceof FLyrVect) {
|
|
393 |
FeatureStore fStore = ((FLyrVect) layer).getFeatureStore();
|
|
401 | 394 |
|
402 |
buff.append(PluginServices.getText(this,"Origen_de_datos") + ": ");
|
|
403 |
buff.append(fStore.getName());
|
|
404 |
info=buff.toString();
|
|
395 |
buff.append(PluginServices.getText(this, "Origen_de_datos") + ": ");
|
|
396 |
buff.append(fStore.getName());
|
|
397 |
info = buff.toString();
|
|
405 | 398 |
|
406 |
DataStoreParameters parameters=fStore.getParameters();
|
|
407 |
if (parameters instanceof FilesystemStoreParameters) {
|
|
408 |
info = info + "\n" +
|
|
409 |
PluginServices.getText(this, "fichero")
|
|
410 |
+ ": "
|
|
411 |
+ ((FilesystemStoreParameters) parameters)
|
|
412 |
.getFile();
|
|
413 |
}else{
|
|
414 |
info = info + "\n" + fStore.getName() + "\n";
|
|
415 |
}
|
|
416 |
String sGeomType= "Unknow";
|
|
399 |
DataStoreParameters parameters = fStore.getParameters();
|
|
400 |
if (parameters instanceof FilesystemStoreParameters) {
|
|
401 |
info = info + "\n"
|
|
402 |
+ PluginServices.getText(this, "fichero")
|
|
403 |
+ ": "
|
|
404 |
+ ((FilesystemStoreParameters) parameters)
|
|
405 |
.getFile();
|
|
406 |
} else {
|
|
407 |
info = info + "\n" + fStore.getName() + "\n";
|
|
408 |
}
|
|
409 |
String sGeomType = "Unknow";
|
|
417 | 410 |
|
418 |
try {
|
|
419 |
GeometryType geomType = ((FLyrVect)layer).getTypeVectorLayer();
|
|
420 |
sGeomType = geomType.getName();
|
|
421 |
} catch (LocatorException e) {
|
|
422 |
NotificationManager.addError(e);
|
|
423 |
} catch (GeometryTypeNotSupportedException e) {
|
|
424 |
NotificationManager.showMessageWarning("Not supported GeometryType", e);
|
|
425 |
} catch (GeometryTypeNotValidException e) {
|
|
426 |
NotificationManager.showMessageWarning("Not valid GeometryType", e);
|
|
427 |
}
|
|
411 |
try {
|
|
412 |
GeometryType geomType = ((FLyrVect) layer).getTypeVectorLayer();
|
|
413 |
sGeomType = geomType.getName();
|
|
414 |
} catch (LocatorException e) {
|
|
415 |
NotificationManager.addError(e);
|
|
416 |
} catch (GeometryTypeNotSupportedException e) {
|
|
417 |
NotificationManager.showMessageWarning("Not supported GeometryType", e);
|
|
418 |
} catch (GeometryTypeNotValidException e) {
|
|
419 |
NotificationManager.showMessageWarning("Not valid GeometryType", e);
|
|
420 |
}
|
|
428 | 421 |
|
429 |
info += "\n" + PluginServices.getText(this,"type")+ ": "+sGeomType + "\n";
|
|
422 |
info += "\n" + PluginServices.getText(this, "type") + ": " + sGeomType + "\n";
|
|
430 | 423 |
|
431 |
} else {
|
|
432 |
info=buff.toString();
|
|
433 |
info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
|
|
434 |
}
|
|
424 |
} else {
|
|
425 |
info = buff.toString();
|
|
426 |
info = info + PluginServices.getText(this, "Origen_de_datos") + ": " + layer.getName();
|
|
427 |
}
|
|
435 | 428 |
|
436 |
}
|
|
437 |
getPropertiesTextArea().setText(info);
|
|
429 |
}
|
|
430 |
getPropertiesTextArea().setText(info);
|
|
438 | 431 |
|
439 |
} catch (ReadException e) {
|
|
440 |
NotificationManager.addError(e.getMessage(), e);
|
|
441 |
} catch (DataException e) {
|
|
442 |
NotificationManager.addError(e.getMessage(), e);
|
|
443 |
}
|
|
432 |
} catch (ReadException e) {
|
|
433 |
NotificationManager.addError(e.getMessage(), e);
|
|
434 |
} catch (DataException e) {
|
|
435 |
NotificationManager.addError(e.getMessage(), e);
|
|
436 |
}
|
|
444 | 437 |
|
445 | 438 |
} |
446 | 439 |
|
447 | 440 |
/** |
448 | 441 |
* Returns true or false if the scale is activa |
449 | 442 |
*/ |
450 |
private boolean isScaleActive() {
|
|
451 |
return getRdBtnDoNotShowWhen().isSelected();
|
|
452 |
}
|
|
443 |
private boolean isScaleActive() {
|
|
444 |
return getRdBtnDoNotShowWhen().isSelected();
|
|
445 |
}
|
|
453 | 446 |
|
447 |
public void acceptAction() { |
|
454 | 448 |
|
455 |
public void acceptAction() {
|
|
449 |
}
|
|
456 | 450 |
|
457 |
} |
|
451 |
public void cancelAction() { |
|
452 |
// does nothing |
|
453 |
} |
|
458 | 454 |
|
459 |
public void cancelAction() { |
|
460 |
// does nothing |
|
461 |
} |
|
455 |
/** |
|
456 |
* When we press the apply button, sets the new properties of the layer thar |
|
457 |
* the user modified using the UI components |
|
458 |
*/ |
|
459 |
public void applyAction() { |
|
460 |
if (isScaleActive()) { |
|
461 |
try { |
|
462 |
layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue()); |
|
463 |
} catch (ParseException ex) { |
|
464 |
if (getTxtMaxScale().getText().compareTo("") == 0) { |
|
465 |
layer.setMinScale(-1); |
|
466 |
} else { |
|
467 |
System.err.print(ex.getLocalizedMessage()); |
|
468 |
} |
|
469 |
} |
|
462 | 470 |
|
463 |
/** |
|
464 |
* When we press the apply button, sets the new properties of the layer thar the |
|
465 |
* user modified using the UI components |
|
466 |
*/ |
|
467 |
public void applyAction() { |
|
468 |
if (isScaleActive()) { |
|
469 |
try { |
|
470 |
layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue()); |
|
471 |
} catch (ParseException ex) { |
|
472 |
if (getTxtMaxScale().getText().compareTo("") == 0) { |
|
473 |
layer.setMinScale(-1); |
|
474 |
} else { |
|
475 |
System.err.print(ex.getLocalizedMessage()); |
|
476 |
} |
|
477 |
} |
|
471 |
try { |
|
472 |
layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue()); |
|
473 |
} catch (ParseException ex) { |
|
474 |
if (getTxtMinScale().getText().compareTo("") == 0) { |
|
475 |
layer.setMaxScale(-1); |
|
476 |
} else { |
|
477 |
System.err.print(ex.getLocalizedMessage()); |
|
478 |
} |
|
479 |
} |
|
478 | 480 |
|
479 |
try { |
|
480 |
layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue()); |
|
481 |
} catch (ParseException ex) { |
|
482 |
if (getTxtMinScale().getText().compareTo("") == 0) { |
|
483 |
layer.setMaxScale(-1); |
|
484 |
} else { |
|
485 |
System.err.print(ex.getLocalizedMessage()); |
|
486 |
} |
|
487 |
} |
|
481 |
} else { |
|
482 |
layer.setMinScale(-1); |
|
483 |
layer.setMaxScale(-1); |
|
484 |
} |
|
488 | 485 |
|
489 |
} else { |
|
490 |
layer.setMinScale(-1); |
|
491 |
layer.setMaxScale(-1); |
|
492 |
} |
|
486 |
if (!getLayerName().equals(layer.getName())) { |
|
487 |
layer.setName(getLayerName()); |
|
488 |
} |
|
493 | 489 |
|
494 |
if (!getLayerName().equals(layer.getName())){ |
|
495 |
layer.setName(getLayerName()); |
|
496 |
} |
|
490 |
} |
|
497 | 491 |
|
498 |
} |
|
499 |
|
|
500 |
/* |
|
501 |
* (non-Javadoc) |
|
502 |
* @see java.awt.Component#getName() |
|
503 |
*/ |
|
504 |
public String getName() { |
|
505 |
return PluginServices.getText(this,"General"); |
|
506 |
} |
|
507 |
} |
|
508 |
|
|
492 |
/* |
|
493 |
* (non-Javadoc) |
|
494 |
* @see java.awt.Component#getName() |
|
495 |
*/ |
|
496 |
public String getName() { |
|
497 |
return PluginServices.getText(this, "General"); |
|
498 |
} |
|
499 |
} |
Also available in: Unified diff