root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / FPanelLegendLabels.java @ 13536
History | View | Annotate | Download (20 KB)
1 |
/*
|
---|---|
2 |
* Created on 01-jun-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
46 |
|
47 |
import java.awt.BorderLayout; |
48 |
import java.awt.Dimension; |
49 |
import java.awt.FlowLayout; |
50 |
import java.awt.Font; |
51 |
import java.awt.GridLayout; |
52 |
import java.awt.event.ActionEvent; |
53 |
import java.awt.event.ActionListener; |
54 |
import java.sql.Types; |
55 |
import java.util.ArrayList; |
56 |
|
57 |
import javax.swing.ButtonGroup; |
58 |
import javax.swing.DefaultComboBoxModel; |
59 |
import javax.swing.JCheckBox; |
60 |
import javax.swing.JComboBox; |
61 |
import javax.swing.JLabel; |
62 |
import javax.swing.JPanel; |
63 |
import javax.swing.JRadioButton; |
64 |
|
65 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
66 |
import org.gvsig.gui.beans.swing.JButton; |
67 |
|
68 |
import com.iver.andami.PluginServices; |
69 |
import com.iver.cit.gvsig.fmap.DriverException; |
70 |
import com.iver.cit.gvsig.fmap.core.FShape; |
71 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
72 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
73 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
74 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
75 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
76 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
77 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
78 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
79 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
80 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
81 |
import com.iver.cit.gvsig.gui.utils.FontChooser; |
82 |
|
83 |
/**
|
84 |
* @author fjp
|
85 |
*
|
86 |
*/
|
87 |
public class FPanelLegendLabels extends JPanel implements ILegendPanel { |
88 |
|
89 |
private static final Font DEFAULT_FONT = |
90 |
new Font("SansSerif", Font.PLAIN, 9); |
91 |
|
92 |
private VectorialLegend m_Renderer;
|
93 |
private ClassifiableVectorial m_lyr;
|
94 |
private FSymbol m_FSymbol;
|
95 |
|
96 |
private ColorChooserPanel m_colorChooser = new ColorChooserPanel(); |
97 |
private javax.swing.JCheckBox jCheckBox = null; |
98 |
private javax.swing.JComboBox jComboBoxTextField = null; |
99 |
private javax.swing.JComboBox jComboBoxHeightField = null; |
100 |
private javax.swing.JTextField jTextField = null; |
101 |
private javax.swing.JRadioButton jRadioButton = null; |
102 |
private javax.swing.JRadioButton jRadioButton1 = null; |
103 |
private FPreviewSymbol fPreviewSymbol = null; |
104 |
private javax.swing.JLabel jLabel3 = null; |
105 |
private JButton jButton = null; |
106 |
|
107 |
private Font labelFont = DEFAULT_FONT; |
108 |
private javax.swing.JLabel jLabel4 = null; |
109 |
private JComboBox jComboBoxRotationField = null; |
110 |
private JCheckBox jCheckBoxTextOnly = null; |
111 |
private GridBagLayoutPanel gridBagLayoutPanel = null; |
112 |
private JRadioButton rdBtnUseHeightField; |
113 |
private JRadioButton rdBtnFixedHeight; |
114 |
private final String NULL_COMBO_ITEM = "- " +PluginServices.getText(FPanelLegendLabels.class, "none") + " -"; |
115 |
/**
|
116 |
* This is the default constructor
|
117 |
*/
|
118 |
public FPanelLegendLabels(JPanel parent) { |
119 |
super();
|
120 |
initialize(); |
121 |
} |
122 |
/**
|
123 |
* This method initializes this
|
124 |
*
|
125 |
* @return void
|
126 |
*/
|
127 |
private void initialize() { |
128 |
this.setLayout(null); |
129 |
this.setSize(454, 308); |
130 |
this.add(getJCheckBox(), null); |
131 |
this.add(getJCheckBoxTextOnly(),null); |
132 |
this.add(getFPreviewSymbol(), null); |
133 |
this.add(getJLabel3(), null); |
134 |
this.add(getJButton(), null); |
135 |
ButtonGroup group = new ButtonGroup(); |
136 |
group.add(getRdBtnUseHeightField()); |
137 |
group.add(getRdBtnFixedHeight()); |
138 |
ButtonGroup jButtonGroup = new ButtonGroup(); |
139 |
jButtonGroup.add(getJRadioButton1()); |
140 |
jButtonGroup.add(getJRadioButton()); |
141 |
|
142 |
m_colorChooser.setAlpha(255);
|
143 |
m_colorChooser.setBounds(336, 114, 99, 34); |
144 |
if (getJComboBoxTextField().getSelectedIndex()!=-1) |
145 |
m_colorChooser.setEnabled(true);
|
146 |
else
|
147 |
m_colorChooser.setEnabled(false);
|
148 |
m_colorChooser.addActionListener(new java.awt.event.ActionListener() {
|
149 |
public void actionPerformed(ActionEvent e) { |
150 |
updateControls(); |
151 |
} |
152 |
}); |
153 |
this.add(getJLabel4(), null); |
154 |
this.add(m_colorChooser);
|
155 |
|
156 |
this.add(getGridBagLayoutPanel(), null); |
157 |
} |
158 |
|
159 |
public void setLayer(FLayer lyr, Legend r) |
160 |
{ |
161 |
m_lyr = (ClassifiableVectorial) lyr; |
162 |
m_Renderer = (VectorialLegend)r; |
163 |
|
164 |
fillFieldNames(); |
165 |
getJComboBoxTextField().getModel().setSelectedItem(m_Renderer.getLabelField()); |
166 |
getJComboBoxHeightField().getModel().setSelectedItem(m_Renderer.getLabelHeightField()); |
167 |
getRdBtnUseHeightField().setSelected(m_Renderer.getLabelHeightField()!=null);
|
168 |
getJComboBoxRotationField().getModel().setSelectedItem(m_Renderer.getLabelRotationField()); |
169 |
|
170 |
if (r.getDefaultSymbol() instanceof FSymbol) |
171 |
setFSymbol((FSymbol) r.getDefaultSymbol()); |
172 |
|
173 |
if (m_Renderer.getLabelField() != null) |
174 |
getJCheckBox().setSelected(true);
|
175 |
else
|
176 |
getJCheckBox().setSelected(false);
|
177 |
} |
178 |
|
179 |
public void setFSymbol(FSymbol sym) |
180 |
{ |
181 |
if (sym == null) |
182 |
{ |
183 |
m_FSymbol = new FSymbol(FShape.MULTI);
|
184 |
} |
185 |
else
|
186 |
m_FSymbol = sym; |
187 |
|
188 |
if (m_FSymbol.getFontColor()!=null){ |
189 |
m_colorChooser.setColor(m_FSymbol.getFontColor()); |
190 |
} |
191 |
fPreviewSymbol.setSymbol(m_FSymbol); |
192 |
|
193 |
getJRadioButton1().setSelected(!m_FSymbol.isFontSizeInPixels()); |
194 |
getJCheckBoxTextOnly().setSelected(!m_FSymbol.isShapeVisible()); |
195 |
double size = m_FSymbol.getFontSize();
|
196 |
// Scale the value of the font size to the value of the height
|
197 |
// and avoid too much decimal numbers
|
198 |
size = ((int) (100*size / FConstant.FONT_HEIGHT_SCALE_FACTOR))/100; |
199 |
getJTextField().setText(String.valueOf(size));
|
200 |
|
201 |
|
202 |
} |
203 |
|
204 |
private void updateControls() { |
205 |
getJComboBoxTextField().setEnabled(getJCheckBox().isSelected()); |
206 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
207 |
getJComboBoxHeightField().setEnabled(getJCheckBox().isSelected()); |
208 |
getJComboBoxRotationField().setEnabled(getJCheckBox().isSelected()); |
209 |
} |
210 |
if (m_Renderer!=null && ((VectorialLegend)m_Renderer).getLabelHeightField()!=null) { |
211 |
getRdBtnUseHeightField().setSelected(true);
|
212 |
}else {
|
213 |
getRdBtnUseHeightField().setSelected(false);
|
214 |
} |
215 |
getJRadioButton().setEnabled(getJCheckBox().isSelected()); |
216 |
getJRadioButton1().setEnabled(getJCheckBox().isSelected()); |
217 |
getRdBtnFixedHeight().setEnabled(getJCheckBox().isSelected()); |
218 |
getRdBtnUseHeightField().setEnabled(getJCheckBox().isSelected()); |
219 |
getJTextField().setEnabled(getJCheckBox().isSelected() && !getRdBtnUseHeightField().isSelected()); |
220 |
getJComboBoxHeightField().setEnabled(getJCheckBox().isSelected() && getRdBtnUseHeightField().isSelected()); |
221 |
getJCheckBoxTextOnly().setEnabled(getJCheckBox().isSelected()); |
222 |
if (m_colorChooser != null) |
223 |
m_colorChooser.setEnabled(getJCheckBox().isSelected()); |
224 |
getJButton().setEnabled(getJCheckBox().isSelected()); |
225 |
if (getJCheckBox().isSelected())
|
226 |
{ |
227 |
FSymbol sym = m_FSymbol; |
228 |
sym.setFont(labelFont); |
229 |
sym.setFontColor(m_colorChooser.getColor()); |
230 |
fPreviewSymbol.setSymbol(sym); |
231 |
} |
232 |
} |
233 |
|
234 |
public void updateValuesFromControls(VectorialLegend l) { |
235 |
if (getJCheckBox().isSelected())
|
236 |
{ |
237 |
if (!(l.getDefaultSymbol() instanceof FSymbol)) |
238 |
return;
|
239 |
m_FSymbol = (FSymbol) l.getDefaultSymbol(); |
240 |
m_FSymbol.setFont(labelFont); |
241 |
String item = (String) getJComboBoxTextField().getSelectedItem(); |
242 |
if (item == null || item.equals(NULL_COMBO_ITEM)) |
243 |
item = null;
|
244 |
l.setLabelField(item); |
245 |
|
246 |
item = (String) getJComboBoxHeightField().getSelectedItem();
|
247 |
if (item == null || item.equals(NULL_COMBO_ITEM)) |
248 |
item = null;
|
249 |
l.setLabelHeightField(item); |
250 |
|
251 |
item = (String) getJComboBoxRotationField().getSelectedItem();
|
252 |
if (item == null || item.equals(NULL_COMBO_ITEM)) |
253 |
item = null;
|
254 |
l.setLabelRotationField(item); |
255 |
m_FSymbol.setFontColor(m_colorChooser.getColor()); |
256 |
//m_FSymbol.setSymbolType(m_Renderer.getShapeType());
|
257 |
String s=getJTextField().getText().replace(',','.'); |
258 |
float fontSize=0; |
259 |
try {
|
260 |
fontSize = Float.parseFloat(s);
|
261 |
}catch (NumberFormatException e) { |
262 |
fontSize=0;
|
263 |
} |
264 |
fontSize *= FConstant.FONT_HEIGHT_SCALE_FACTOR; |
265 |
if (!getJRadioButton().isSelected())
|
266 |
{ |
267 |
// meters
|
268 |
/*
|
269 |
* Java scales font size by defining the cell diagonal.
|
270 |
* To obtain the right height value we need to apply a
|
271 |
* factor to the diagonal to get a right value for the
|
272 |
* height.
|
273 |
*/
|
274 |
m_FSymbol.setFontSize(fontSize); // Para que se pueda crear correctamente al recuperar del proyecto
|
275 |
m_FSymbol.setFontSizeInPixels(false);
|
276 |
} |
277 |
else
|
278 |
{ |
279 |
// pixels
|
280 |
m_FSymbol.setFont(labelFont); |
281 |
m_FSymbol.setFont(labelFont.deriveFont(fontSize)); |
282 |
m_FSymbol.setFontSize(fontSize); |
283 |
m_FSymbol.setFontSizeInPixels(true);
|
284 |
} |
285 |
m_FSymbol.setShapeVisible(true);
|
286 |
if (getJCheckBoxTextOnly().isSelected())
|
287 |
m_FSymbol.setShapeVisible(false);
|
288 |
|
289 |
l.setDefaultSymbol(m_FSymbol); |
290 |
// System.out.println("Color punto 3 " + m_FSymbol.getColor().toString());
|
291 |
} |
292 |
else
|
293 |
{ |
294 |
// Para que no se dibujen las etiquetas, el campo labelField del Renderer
|
295 |
// ha de ser null
|
296 |
l.setLabelField(null);
|
297 |
} |
298 |
} |
299 |
|
300 |
private void fillFieldNames() { |
301 |
SelectableDataSource rs; |
302 |
try {
|
303 |
// rs = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject().getDataSourceByLayer((FLayer) m_lyr);
|
304 |
rs = ((FLyrVect)m_lyr).getRecordset(); |
305 |
String[] nomFields; |
306 |
ArrayList nomNumericFields = new ArrayList(); |
307 |
|
308 |
// null value
|
309 |
nomNumericFields.add(NULL_COMBO_ITEM); |
310 |
nomFields = new String[rs.getFieldCount()]; |
311 |
for (int i = 0; i < rs.getFieldCount(); i++) { |
312 |
nomFields[i] = rs.getFieldName(i).trim(); |
313 |
if ((rs.getFieldType(i) == Types.FLOAT) |
314 |
|| (rs.getFieldType(i) == Types.BIGINT)
|
315 |
|| (rs.getFieldType(i) == Types.DOUBLE)
|
316 |
|| (rs.getFieldType(i) == Types.INTEGER))
|
317 |
nomNumericFields.add(nomFields[i]); |
318 |
} |
319 |
|
320 |
DefaultComboBoxModel cM_labelField = new DefaultComboBoxModel(nomFields); |
321 |
getJComboBoxTextField().setModel(cM_labelField); |
322 |
DefaultComboBoxModel cM_HeightField = new DefaultComboBoxModel(nomNumericFields.toArray(new String[0])); |
323 |
getJComboBoxHeightField().setModel(cM_HeightField); |
324 |
DefaultComboBoxModel cM_RotationField = new DefaultComboBoxModel(nomNumericFields.toArray(new String[0])); |
325 |
getJComboBoxRotationField().setModel(cM_RotationField); |
326 |
|
327 |
} catch (DriverException e) {
|
328 |
e.printStackTrace(); |
329 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
330 |
e.printStackTrace(); |
331 |
} |
332 |
} |
333 |
|
334 |
/**
|
335 |
* This method initializes jCheckBox
|
336 |
*
|
337 |
* @return javax.swing.JCheckBox
|
338 |
*/
|
339 |
private javax.swing.JCheckBox getJCheckBox() {
|
340 |
if (jCheckBox == null) { |
341 |
jCheckBox = new javax.swing.JCheckBox();
|
342 |
jCheckBox.setText(PluginServices.getText(this,"Habilitar_etiquetado")); |
343 |
jCheckBox.setBounds(2, 1, 152, 23); |
344 |
jCheckBox.addItemListener(new java.awt.event.ItemListener() {
|
345 |
|
346 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
347 |
updateControls(); |
348 |
|
349 |
} |
350 |
}); |
351 |
|
352 |
} |
353 |
return jCheckBox;
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* This method initializes jComboBox
|
358 |
*
|
359 |
* @return javax.swing.JComboBox
|
360 |
*/
|
361 |
private javax.swing.JComboBox getJComboBoxTextField() {
|
362 |
if (jComboBoxTextField == null) { |
363 |
jComboBoxTextField = new javax.swing.JComboBox();
|
364 |
jComboBoxTextField.setEnabled(false);
|
365 |
jComboBoxTextField.addItemListener(new java.awt.event.ItemListener() {
|
366 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
367 |
if (jComboBoxTextField.getSelectedIndex()!=-1){ |
368 |
getJComboBoxHeightField().setEnabled(true);
|
369 |
getJComboBoxRotationField().setEnabled(true);
|
370 |
}else{
|
371 |
getJComboBoxHeightField().setEnabled(false);
|
372 |
getJComboBoxRotationField().setEnabled(false);
|
373 |
} |
374 |
} |
375 |
}); |
376 |
} |
377 |
return jComboBoxTextField;
|
378 |
} |
379 |
|
380 |
/**
|
381 |
* This method initializes jComboBox1
|
382 |
*
|
383 |
* @return javax.swing.JComboBox
|
384 |
*/
|
385 |
private javax.swing.JComboBox getJComboBoxHeightField() {
|
386 |
if (jComboBoxHeightField == null) { |
387 |
jComboBoxHeightField = new javax.swing.JComboBox();
|
388 |
jComboBoxHeightField.setVisible(true);
|
389 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
390 |
jComboBoxHeightField.setEnabled(true);
|
391 |
}else{
|
392 |
jComboBoxHeightField.setEnabled(false);
|
393 |
} |
394 |
|
395 |
} |
396 |
return jComboBoxHeightField;
|
397 |
} |
398 |
|
399 |
/**
|
400 |
* This method initializes jTextField
|
401 |
*
|
402 |
* @return javax.swing.JTextField
|
403 |
*/
|
404 |
private javax.swing.JTextField getJTextField() {
|
405 |
if (jTextField == null) { |
406 |
jTextField = new javax.swing.JTextField();
|
407 |
jTextField.setPreferredSize(new Dimension(76, 21)); |
408 |
jTextField.setBounds(26, 32, 76, 21); |
409 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
410 |
jTextField.setEnabled(true);
|
411 |
}else{
|
412 |
jTextField.setEnabled(false);
|
413 |
} |
414 |
jTextField.setEnabled(false);
|
415 |
jTextField.setText("10");
|
416 |
} |
417 |
return jTextField;
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* This method initializes jRadioButton
|
422 |
*
|
423 |
* @return javax.swing.JRadioButton
|
424 |
*/
|
425 |
private javax.swing.JRadioButton getJRadioButton() {
|
426 |
if (jRadioButton == null) { |
427 |
jRadioButton = new javax.swing.JRadioButton();
|
428 |
jRadioButton.setText(PluginServices.getText(this,"En_pixels")); |
429 |
jRadioButton.setBounds(145, 44, 100, 23); |
430 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
431 |
jRadioButton.setEnabled(true);
|
432 |
}else{
|
433 |
jRadioButton.setEnabled(false);
|
434 |
} |
435 |
jRadioButton.setEnabled(false);
|
436 |
jRadioButton.setSelected(true);
|
437 |
} |
438 |
return jRadioButton;
|
439 |
} |
440 |
|
441 |
/**
|
442 |
* This method initializes jRadioButton1
|
443 |
*
|
444 |
* @return javax.swing.JRadioButton
|
445 |
*/
|
446 |
private javax.swing.JRadioButton getJRadioButton1() {
|
447 |
if (jRadioButton1 == null) { |
448 |
jRadioButton1 = new javax.swing.JRadioButton();
|
449 |
jRadioButton1.setText(PluginServices.getText(this,"En_metros")); |
450 |
jRadioButton1.setBounds(145, 16, 100, 23); |
451 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
452 |
jRadioButton1.setEnabled(true);
|
453 |
}else{
|
454 |
jRadioButton1.setEnabled(false);
|
455 |
} |
456 |
jRadioButton1.setEnabled(false);
|
457 |
} |
458 |
return jRadioButton1;
|
459 |
} |
460 |
|
461 |
/**
|
462 |
* This method initializes fPreviewSymbol
|
463 |
*
|
464 |
* @return com.iver.cit.opensig.gui.Panels.FPreviewSymbol
|
465 |
*/
|
466 |
public FPreviewSymbol getFPreviewSymbol() {
|
467 |
if (fPreviewSymbol == null) { |
468 |
fPreviewSymbol = new FPreviewSymbol();
|
469 |
fPreviewSymbol.setBounds(311, 53, 134, 77); |
470 |
} |
471 |
return fPreviewSymbol;
|
472 |
} |
473 |
|
474 |
/**
|
475 |
* This method initializes jLabel3
|
476 |
*
|
477 |
* @return javax.swing.JLabel
|
478 |
*/
|
479 |
private javax.swing.JLabel getJLabel3() {
|
480 |
if (jLabel3 == null) { |
481 |
jLabel3 = new javax.swing.JLabel();
|
482 |
jLabel3.setBounds(336, 27, 100, 18); |
483 |
jLabel3.setText(PluginServices.getText(this,"Previsualizacion")); |
484 |
jLabel3.setVisible(false);
|
485 |
} |
486 |
return jLabel3;
|
487 |
} |
488 |
|
489 |
/**
|
490 |
* This method initializes jButton
|
491 |
*
|
492 |
* @return javax.swing.JButton
|
493 |
*/
|
494 |
private JButton getJButton() { |
495 |
if (jButton == null) { |
496 |
jButton = new JButton(); |
497 |
jButton.setBounds(338, 53, 111, 29); |
498 |
if (getJComboBoxTextField().getSelectedIndex()!=-1) |
499 |
jButton.setEnabled(true);
|
500 |
else
|
501 |
jButton.setEnabled(false);
|
502 |
jButton.setText(PluginServices.getText(this,"fuente")+"..."); |
503 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
504 |
|
505 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
506 |
//JButton origen = (JButton) e.getSource();
|
507 |
Font newFont;
|
508 |
|
509 |
newFont = FontChooser.showDialog("Choose Font", labelFont);
|
510 |
|
511 |
if (newFont == null) { |
512 |
return;
|
513 |
} |
514 |
|
515 |
labelFont = newFont; |
516 |
updateControls(); |
517 |
|
518 |
|
519 |
} |
520 |
}); |
521 |
|
522 |
} |
523 |
return jButton;
|
524 |
} |
525 |
|
526 |
/**
|
527 |
* This method initializes jLabel4
|
528 |
*
|
529 |
* @return javax.swing.JLabel
|
530 |
*/
|
531 |
private javax.swing.JLabel getJLabel4() {
|
532 |
if (jLabel4 == null) { |
533 |
jLabel4 = new javax.swing.JLabel();
|
534 |
jLabel4.setBounds(335, 87, 115, 23); |
535 |
jLabel4.setText(PluginServices.getText(this,"color_texto")); |
536 |
} |
537 |
return jLabel4;
|
538 |
} |
539 |
|
540 |
public Legend getLegend() {
|
541 |
updateValuesFromControls(m_Renderer); |
542 |
return m_Renderer;
|
543 |
} |
544 |
/**
|
545 |
* This method initializes jComboBox1
|
546 |
*
|
547 |
* @return javax.swing.JComboBox
|
548 |
*/
|
549 |
private JComboBox getJComboBoxRotationField() { |
550 |
if (jComboBoxRotationField == null) { |
551 |
jComboBoxRotationField = new JComboBox(); |
552 |
if (getJComboBoxTextField().getSelectedIndex()!=-1) |
553 |
jComboBoxRotationField.setEnabled(true);
|
554 |
else
|
555 |
jComboBoxRotationField.setEnabled(false);
|
556 |
} |
557 |
return jComboBoxRotationField;
|
558 |
} |
559 |
|
560 |
/**
|
561 |
* This method initializes jCheckBox1
|
562 |
*
|
563 |
* @return javax.swing.JCheckBox
|
564 |
*/
|
565 |
private JCheckBox getJCheckBoxTextOnly() { |
566 |
if (jCheckBoxTextOnly == null) { |
567 |
jCheckBoxTextOnly = new JCheckBox(); |
568 |
jCheckBoxTextOnly.setBounds(315, 171, 200, 22); |
569 |
if (getJComboBoxTextField().getSelectedIndex()!=-1){ |
570 |
jCheckBoxTextOnly.setEnabled(true);
|
571 |
}else{
|
572 |
jCheckBoxTextOnly.setEnabled(false);
|
573 |
} |
574 |
jCheckBoxTextOnly.setText(PluginServices.getText(this, "draw_text_only")); |
575 |
} |
576 |
return jCheckBoxTextOnly;
|
577 |
} |
578 |
/**
|
579 |
* This method initializes gridBagLayoutPanel
|
580 |
*
|
581 |
* @return org.gvsig.gui.beans.swing.GridBagLayoutPanel
|
582 |
*/
|
583 |
private GridBagLayoutPanel getGridBagLayoutPanel() {
|
584 |
if (gridBagLayoutPanel == null) { |
585 |
gridBagLayoutPanel = new GridBagLayoutPanel();
|
586 |
gridBagLayoutPanel.setBounds(new java.awt.Rectangle(14,15,263,274)); |
587 |
gridBagLayoutPanel.addComponent(new JLabel(PluginServices.getText(this,"Campo_de_etiquetado"))); |
588 |
gridBagLayoutPanel.addComponent("", getJComboBoxTextField());
|
589 |
gridBagLayoutPanel.addComponent(new JLabel(PluginServices.getText(this, "rotation_field"))); |
590 |
gridBagLayoutPanel.addComponent("", getJComboBoxRotationField());
|
591 |
|
592 |
gridBagLayoutPanel.addComponent(getRdBtnUseHeightField()); |
593 |
gridBagLayoutPanel.addComponent("", getJComboBoxHeightField());
|
594 |
|
595 |
JPanel aux = new JPanel(new BorderLayout(0, 0)); |
596 |
JPanel aux1 = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
597 |
aux1.add(getJTextField(), BorderLayout.CENTER);
|
598 |
JPanel aux2 = new JPanel(new GridLayout(2,1)); |
599 |
aux2.add(getJRadioButton()); |
600 |
aux2.add(getJRadioButton1()); |
601 |
aux.add(aux1, BorderLayout.WEST);
|
602 |
aux.add(aux2, BorderLayout.CENTER);
|
603 |
gridBagLayoutPanel.addComponent(getRdBtnFixedHeight()); |
604 |
gridBagLayoutPanel.addComponent("", aux);
|
605 |
//gridBagLayoutPanel.addComponent("", getJCheckBoxTextOnly());
|
606 |
|
607 |
} |
608 |
return gridBagLayoutPanel;
|
609 |
} |
610 |
|
611 |
private JRadioButton getRdBtnUseHeightField() { |
612 |
if (rdBtnUseHeightField == null) { |
613 |
rdBtnUseHeightField = new JRadioButton(PluginServices.getText(this,"campo_altura_texto")); |
614 |
rdBtnUseHeightField.addActionListener(new ActionListener() { |
615 |
public void actionPerformed(ActionEvent e) { |
616 |
boolean b = rdBtnUseHeightField.isSelected();
|
617 |
getJTextField().setEnabled(!b); |
618 |
getJComboBoxHeightField().setEnabled(b); |
619 |
getJRadioButton().setEnabled(!b); |
620 |
getJRadioButton1().setEnabled(!b); |
621 |
} |
622 |
}); |
623 |
} |
624 |
return rdBtnUseHeightField;
|
625 |
} |
626 |
|
627 |
private JRadioButton getRdBtnFixedHeight() { |
628 |
if (rdBtnFixedHeight == null) { |
629 |
rdBtnFixedHeight = new JRadioButton(PluginServices.getText(this,"Altura_fija_de_texto")+":"); |
630 |
rdBtnFixedHeight.setSelected(true);
|
631 |
rdBtnFixedHeight.addActionListener(new ActionListener() { |
632 |
|
633 |
public void actionPerformed(ActionEvent e) { |
634 |
boolean b = rdBtnFixedHeight.isSelected();
|
635 |
getJTextField().setEnabled(b); |
636 |
getJComboBoxHeightField().setEnabled(!b); |
637 |
getJRadioButton().setEnabled(b); |
638 |
getJRadioButton1().setEnabled(b); |
639 |
getJComboBoxHeightField().setSelectedItem(NULL_COMBO_ITEM); |
640 |
} |
641 |
|
642 |
}); |
643 |
} |
644 |
return rdBtnFixedHeight;
|
645 |
} |
646 |
|
647 |
public void repaint() { |
648 |
updateControls(); |
649 |
super.repaint();
|
650 |
} |
651 |
} |