Revision 3035 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FPanelLegendLabels.java

View differences:

FPanelLegendLabels.java
46 46

  
47 47
import java.awt.Font;
48 48
import java.awt.event.ActionEvent;
49
import java.sql.Types;
50
import java.util.ArrayList;
49 51

  
50 52
import javax.swing.ButtonGroup;
51 53
import javax.swing.DefaultComboBoxModel;
......
63 65
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
64 66
import com.iver.cit.gvsig.gui.Dialogs.FontChooser;
65 67
import com.iver.cit.gvsig.gui.Panels.ColorChooserPanel;
68
import javax.swing.JComboBox;
69
import javax.swing.JLabel;
70
import javax.swing.JCheckBox;
66 71

  
67 72
/**
68 73
 * @author fjp
......
84 89
	//private javax.swing.JLabel jLabel = null;
85 90
	private javax.swing.JCheckBox jCheckBox = null;
86 91
	private javax.swing.JLabel jLabel1 = null;
87
	private javax.swing.JComboBox jComboBox = null;
92
	private javax.swing.JComboBox jComboBoxTextField = null;
88 93
	private javax.swing.JLabel jLabel2 = null;
89
	private javax.swing.JComboBox jComboBox1 = null;
94
	private javax.swing.JComboBox jComboBoxHeightField = null;
90 95
	private javax.swing.JPanel jPanel = null;
91 96
	private javax.swing.JTextField jTextField = null;
92 97
	private javax.swing.JRadioButton jRadioButton = null;
......
98 103
	private Font labelFont = DEFAULT_FONT;
99 104
	//private JPanel parent;
100 105
	private javax.swing.JLabel jLabel4 = null;
106

  
107

  
108
    private JComboBox jComboBoxRotationField = null;
109

  
110

  
111
    private JLabel jLabel = null;
112

  
113

  
114
    private JCheckBox jCheckBoxTextOnly = null;
101 115
	/**
102 116
	 * This is the default constructor
103 117
	 */
......
112 126
	 * @return void
113 127
	 */
114 128
	private  void initialize() {
129
		jLabel = new JLabel();
130
		jLabel.setBounds(30, 110, 138, 18);
131
		jLabel.setText("Campo de rotaci?n");
115 132
		this.setLayout(null);
116 133
		this.setSize(454, 230);
134
		this.add(getJCheckBoxTextOnly(), null);
135
		this.add(jLabel, null);
136
		this.add(getJComboBoxRotationField(), null);
117 137
		this.add(getJCheckBox(), null);
118 138
		this.add(getJLabel1(), null);
119
		this.add(getJComboBox(), null);
139
		this.add(getJComboBoxTextField(), null);
120 140
		this.add(getJLabel2(), null);
121
		this.add(getJComboBox1(), null);
141
		this.add(getJComboBoxHeightField(), null);
122 142
		this.add(getJPanel(), null);
123 143
		this.add(getFPreviewSymbol(), null);
124 144
		this.add(getJLabel3(), null);
......
127 147
		// m_colorChooser = new ColorChooserPanel();
128 148
		// m_colorChooser.setColor(Color.RED);
129 149
		m_colorChooser.setAlpha(255);
130
		m_colorChooser.setBounds(190, 103, 99, 34);
150
		m_colorChooser.setBounds(312, 115, 99, 34);
131 151
		m_colorChooser.addActionListener(new java.awt.event.ActionListener() {
132 152
			public void actionPerformed(ActionEvent e) {
133 153
				updateControls();
......
143 163
		m_Renderer = (VectorialLegend)r;		
144 164

  
145 165
		fillFieldNames();		
146
		getJComboBox().getModel().setSelectedItem(m_Renderer.getLabelField());
166
		getJComboBoxTextField().getModel().setSelectedItem(m_Renderer.getLabelField());
167
        getJComboBoxHeightField().getModel().setSelectedItem(m_Renderer.getLabelHeightField());
168
        getJComboBoxRotationField().getModel().setSelectedItem(m_Renderer.getLabelRotationField());
147 169
		setFSymbol(r.getDefaultSymbol());
148 170
		
149 171
		if (m_Renderer.getLabelField() != null)
......
170 192
		fPreviewSymbol.setSymbol(m_FSymbol);
171 193
		
172 194
		getJRadioButton1().setSelected(!m_FSymbol.isFontSizeInPixels());
195
        getJCheckBoxTextOnly().setSelected(!m_FSymbol.isShapeVisible());
173 196
		getJTextField().setText("" + 
174 197
				m_FSymbol.getFontSize());
175 198

  
......
177 200
	}
178 201

  
179 202
	private void updateControls() {
180
		getJComboBox().setEnabled(getJCheckBox().isSelected());
181
		getJComboBox1().setEnabled(getJCheckBox().isSelected());
203
		getJComboBoxTextField().setEnabled(getJCheckBox().isSelected());
204
		getJComboBoxHeightField().setEnabled(getJCheckBox().isSelected());
205
        getJComboBoxRotationField().setEnabled(getJCheckBox().isSelected());
182 206
		getJRadioButton().setEnabled(getJCheckBox().isSelected());
183 207
		getJRadioButton1().setEnabled(getJCheckBox().isSelected());
184 208
		getJTextField().setEnabled(getJCheckBox().isSelected());
......
195 219
		{
196 220
            m_FSymbol = l.getDefaultSymbol();
197 221
            m_FSymbol.setFont(labelFont);
198
			l.setLabelField((String) getJComboBox().getSelectedItem());
199
			///m_Renderer.setLabelHeightField((String) getJComboBox1().getSelectedItem());
222
			l.setLabelField((String) getJComboBoxTextField().getSelectedItem());
223
			l.setLabelHeightField((String) getJComboBoxHeightField().getSelectedItem());
224
            l.setLabelRotationField((String) getJComboBoxRotationField().getSelectedItem());
200 225
			m_FSymbol.setFontColor(m_colorChooser.getColor());
201 226
			//m_FSymbol.setSymbolType(m_Renderer.getShapeType());
202 227
			if (!getJRadioButton().isSelected())
......
212 237
				m_FSymbol.setFont(labelFont.deriveFont(sizePoints));
213 238
				m_FSymbol.setFontSize(sizePoints);
214 239
				m_FSymbol.setFontSizeInPixels(true);
215
			}		
240
			}
241
            m_FSymbol.setShapeVisible(true);
242
            if (getJCheckBoxTextOnly().isSelected())
243
                m_FSymbol.setShapeVisible(false);
244
            
216 245
			l.setDefaultSymbol(m_FSymbol);
217 246
            // System.out.println("Color punto 3 " + m_FSymbol.getColor().toString());
218 247
		}
......
233 262
		try {
234 263
			rs = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject().getDataSourceByLayer((FLayer) m_lyr);
235 264
			String[] nomFields;
265
            ArrayList nomNumericFields = new ArrayList();
236 266
			nomFields = new String[rs.getFieldCount()];
237 267
			for (int i = 0; i < rs.getFieldCount(); i++) {
238 268
				nomFields[i] = rs.getFieldName(i).trim();
269
                if ((rs.getFieldType(i) == Types.FLOAT)
270
                   || (rs.getFieldType(i) == Types.BIGINT)
271
                   || (rs.getFieldType(i) == Types.DOUBLE)
272
                   || (rs.getFieldType(i) == Types.INTEGER))
273
                    nomNumericFields.add(nomFields[i]);
239 274
			}
240 275

  
241 276
			DefaultComboBoxModel cM_labelField = new DefaultComboBoxModel(nomFields);
242
			getJComboBox().setModel(cM_labelField);
243
			DefaultComboBoxModel cM_heightField = new DefaultComboBoxModel(nomFields);
244
			getJComboBox1().setModel(cM_heightField);
277
			getJComboBoxTextField().setModel(cM_labelField);
278
			DefaultComboBoxModel cM_HeightField = new DefaultComboBoxModel(nomNumericFields.toArray(new String[0]));
279
			getJComboBoxHeightField().setModel(cM_HeightField);
280
            DefaultComboBoxModel cM_RotationField = new DefaultComboBoxModel(nomNumericFields.toArray(new String[0]));
281
            getJComboBoxRotationField().setModel(cM_RotationField);
245 282
	
246 283
		} catch (DriverException e) {
247 284
			e.printStackTrace();
......
304 341
	 * @return javax.swing.JComboBox	
305 342

  
306 343
	 */    
307
	private javax.swing.JComboBox getJComboBox() {
308
		if (jComboBox == null) {
309
			jComboBox = new javax.swing.JComboBox();
310
			jComboBox.setBounds(175, 52, 110, 19);
311
			jComboBox.setEnabled(false);
344
	private javax.swing.JComboBox getJComboBoxTextField() {
345
		if (jComboBoxTextField == null) {
346
			jComboBoxTextField = new javax.swing.JComboBox();
347
			jComboBoxTextField.setBounds(175, 52, 110, 19);
348
			jComboBoxTextField.setEnabled(false);
312 349
		}
313
		return jComboBox;
350
		return jComboBoxTextField;
314 351
	}
315 352

  
316 353
	/**
......
325 362
	private javax.swing.JLabel getJLabel2() {
326 363
		if (jLabel2 == null) {
327 364
			jLabel2 = new javax.swing.JLabel();
328
			jLabel2.setBounds(298, 190, 137, 21);
365
			jLabel2.setBounds(29, 81, 137, 21);
329 366
			jLabel2.setText(PluginServices.getText(this,"campo_altura_texto"));
330
			jLabel2.setVisible(false);
367
			jLabel2.setVisible(true);
331 368
		}
332 369
		return jLabel2;
333 370
	}
......
341 378
	 * @return javax.swing.JComboBox	
342 379

  
343 380
	 */    
344
	private javax.swing.JComboBox getJComboBox1() {
345
		if (jComboBox1 == null) {
346
			jComboBox1 = new javax.swing.JComboBox();
347
			jComboBox1.setBounds(175, 82, 110, 18);
348
			jComboBox1.setEnabled(false);
349
			jComboBox1.setVisible(false);
381
	private javax.swing.JComboBox getJComboBoxHeightField() {
382
		if (jComboBoxHeightField == null) {
383
			jComboBoxHeightField = new javax.swing.JComboBox();
384
			jComboBoxHeightField.setBounds(175, 82, 110, 18);
385
			jComboBoxHeightField.setEnabled(true);
386
			jComboBoxHeightField.setVisible(true);
350 387
		}
351
		return jComboBox1;
388
		return jComboBoxHeightField;
352 389
	}
353 390

  
354 391
	/**
......
482 519
	private javax.swing.JButton getJButton() {
483 520
		if (jButton == null) {
484 521
			jButton = new javax.swing.JButton();
485
			jButton.setBounds(29, 77, 111, 29);
522
			jButton.setBounds(314, 54, 111, 29);
486 523
			jButton.setText(PluginServices.getText(this,"fuente")+"...");
487 524
			jButton.addActionListener(new java.awt.event.ActionListener() { 
488 525

  
......
519 556
	private javax.swing.JLabel getJLabel4() {
520 557
		if (jLabel4 == null) {
521 558
			jLabel4 = new javax.swing.JLabel();
522
			jLabel4.setBounds(29, 109, 133, 23);
559
			jLabel4.setBounds(311, 88, 133, 23);
523 560
			jLabel4.setText(PluginServices.getText(this,"color_texto"));
524 561
		}
525 562
		return jLabel4;
......
531 568
		updateValuesFromControls(m_Renderer);
532 569
		return m_Renderer;
533 570
	}
571
    /**
572
     * This method initializes jComboBox1	
573
     * 	
574
     * @return javax.swing.JComboBox	
575
     */    
576
    private JComboBox getJComboBoxRotationField() {
577
    	if (jComboBoxRotationField == null) {
578
    		jComboBoxRotationField = new JComboBox();
579
    		jComboBoxRotationField.setBounds(175, 111, 110, 19);
580
    	}
581
    	return jComboBoxRotationField;
582
    }
583
    /**
584
     * This method initializes jCheckBox1	
585
     * 	
586
     * @return javax.swing.JCheckBox	
587
     */    
588
    private JCheckBox getJCheckBoxTextOnly() {
589
    	if (jCheckBoxTextOnly == null) {
590
    		jCheckBoxTextOnly = new JCheckBox();
591
    		jCheckBoxTextOnly.setBounds(315, 171, 133, 22);
592
    		jCheckBoxTextOnly.setText("Dibujar solo el texto");
593
    	}
594
    	return jCheckBoxTextOnly;
595
    }
534 596

  
535 597
        }  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"

Also available in: Unified diff