Revision 25074 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/AttrInTableLabeling.java
AttrInTableLabeling.java | ||
---|---|---|
57 | 57 |
|
58 | 58 |
import org.gvsig.fmap.dal.DataTypes; |
59 | 59 |
import org.gvsig.fmap.dal.exception.DataException; |
60 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
61 | 60 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
62 | 61 |
import org.gvsig.fmap.dal.feature.FeatureType; |
63 | 62 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
... | ... | |
67 | 66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
68 | 67 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
69 | 68 |
import org.gvsig.gui.beans.swing.JBlank; |
70 |
import org.gvsig.gui.beans.swing.JComboBoxFonts; |
|
71 | 69 |
|
72 | 70 |
import com.iver.andami.PluginServices; |
73 | 71 |
import com.iver.andami.messages.NotificationManager; |
74 | 72 |
import com.iver.cit.gvsig.gui.JComboBoxUnits; |
75 | 73 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
74 |
import com.iver.cit.gvsig.gui.styling.JComboBoxUnitsReferenceSystem; |
|
76 | 75 |
import com.iver.cit.gvsig.gui.utils.FontChooser; |
77 | 76 |
import com.iver.cit.gvsig.project.Project; |
78 | 77 |
import com.iver.utiles.swing.JComboBox; |
... | ... | |
93 | 92 |
private JComboBox cmbHeightField; |
94 | 93 |
private JComboBox cmbRotationField; |
95 | 94 |
private JComboBoxUnits cmbUnits; |
95 |
private JComboBoxUnitsReferenceSystem cmbReferenceSystem; |
|
96 | 96 |
private JTextField txtHeightField; |
97 | 97 |
private FLyrVect layer; |
98 |
private JComboBoxFonts cmbFonts; |
|
98 |
|
|
99 | 99 |
private ColorChooserPanel colorChooser; |
100 | 100 |
private JComboBox cmbColorField; |
101 | 101 |
private JButton chooseFontBut; |
... | ... | |
115 | 115 |
aux.addComponent(getRdBtnFixedHeight(), getTxtHeightField()); |
116 | 116 |
aux.addComponent(PluginServices.getText(this, "rotation_height") + ":", getCmbRotationField()); |
117 | 117 |
aux.addComponent(PluginServices.getText(this, "units") + ":", getCmbUnits()); |
118 |
aux.addComponent(PluginServices.getText(this,""),getCmbReferenceSystem()); |
|
118 | 119 |
panel.add(aux); |
119 | 120 |
|
120 | 121 |
aux = new GridBagLayoutPanel(); |
... | ... | |
215 | 216 |
return cmbUnits; |
216 | 217 |
} |
217 | 218 |
|
219 |
private JComboBoxUnitsReferenceSystem getCmbReferenceSystem(){ |
|
220 |
if(cmbReferenceSystem == null){ |
|
221 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem(); |
|
222 |
cmbReferenceSystem.setName("CMBREFSYST"); |
|
223 |
} |
|
224 |
return cmbReferenceSystem; |
|
225 |
} |
|
226 |
|
|
218 | 227 |
private JComboBox getCmbColorField() { |
219 | 228 |
if (cmbColorField == null) { |
220 | 229 |
cmbColorField = new JComboBox(); |
... | ... | |
238 | 247 |
// the text size unit name |
239 | 248 |
refreshCmbUnits(); |
240 | 249 |
|
250 |
refreshCmbRefSystem(); |
|
241 | 251 |
// the font for the text |
242 | 252 |
refreshFont(); |
243 |
// |
|
244 | 253 |
// the color for the font |
245 | 254 |
refreshColorFont(); |
246 | 255 |
} |
... | ... | |
326 | 335 |
if(getCmbUnits().getItemCount() > 0) { |
327 | 336 |
strategy.setUnit(getCmbUnits().getSelectedUnitIndex()); |
328 | 337 |
} |
338 |
if(getCmbReferenceSystem().getItemCount() > 0) { |
|
339 |
strategy.setReferenceSystem(getCmbReferenceSystem().getSelectedIndex()); |
|
340 |
} |
|
329 | 341 |
|
330 | 342 |
strategy.setUsesFixedColor(getRdBtnFixedColor().isSelected()); |
331 | 343 |
strategy.setFixedColor(colorChooser.getColor()); |
... | ... | |
345 | 357 |
if (layer instanceof FLyrVect) { |
346 | 358 |
FLyrVect lv = (FLyrVect) layer; |
347 | 359 |
try { |
348 |
FeatureType featureType=(FeatureType)lv.getFeatureStore().getFeatureTypes().get(0); |
|
349 |
fieldNames = featureType.getFields(); |
|
350 |
|
|
351 |
Iterator iterator=featureType.iterator(); |
|
360 |
FeatureType featureType = lv.getFeatureStore() |
|
361 |
.getDefaultFeatureType(); |
|
362 |
fieldNames = new String[featureType.size()]; |
|
363 |
Iterator<FeatureAttributeDescriptor> iterator = featureType |
|
364 |
.iterator(); |
|
352 | 365 |
ArrayList<String> l = new ArrayList<String>(); |
353 | 366 |
ArrayList<String> lColors = new ArrayList<String>(); |
367 |
String name; |
|
368 |
FeatureAttributeDescriptor descriptor; |
|
354 | 369 |
while (iterator.hasNext()) { |
355 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next(); |
|
356 |
if (descriptor.getDataType() == DataTypes.DOUBLE || |
|
357 |
descriptor.getDataType() == DataTypes.FLOAT || |
|
358 |
descriptor.getDataType() == DataTypes.LONG)/*|| |
|
359 |
descriptor.getDataType().equals(FeatureAttributeDescriptor.TYPE_INT))*/{ |
|
360 |
l.add(descriptor.getName()); |
|
370 |
descriptor = iterator.next(); |
|
371 |
|
|
372 |
name = descriptor.getName(); |
|
373 |
fieldNames[descriptor.getIndex()] = name; |
|
374 |
switch (descriptor.getDataType()) { |
|
375 |
// case DataTypes.DECIMAL: |
|
376 |
// case DataTypes.NUMERIC: |
|
377 |
case DataTypes.FLOAT: |
|
378 |
// case DataTypes.REAL: |
|
379 |
case DataTypes.DOUBLE: |
|
380 |
l.add(name); |
|
381 |
break; |
|
382 |
case DataTypes.INT: |
|
383 |
// case DataTypes.SMALLINT: |
|
384 |
// case DataTypes.TINYINT: |
|
385 |
case DataTypes.LONG: |
|
386 |
lColors.add(name); |
|
387 |
l.add(name); |
|
388 |
break; |
|
361 | 389 |
} |
362 |
if (descriptor.getDataType() == DataTypes.INT) { |
|
363 |
l.add(descriptor.getName()); |
|
364 |
lColors.add(descriptor.getName()); |
|
365 |
} |
|
366 |
|
|
367 |
|
|
368 |
// detect the numeric fields |
|
369 |
|
|
370 |
// for (int i = 0; i < fieldNames.length; i++) { |
|
371 |
// switch (lv.getRecordset().getFieldType(i)) { |
|
372 |
// case Types.DECIMAL: |
|
373 |
// case Types.NUMERIC: |
|
374 |
// case Types.FLOAT: |
|
375 |
// case Types.DOUBLE: |
|
376 |
// case Types.INTEGER: |
|
377 |
// case Types.REAL: |
|
378 |
// case Types.SMALLINT: |
|
379 |
// case Types.TINYINT: |
|
380 |
// case Types.BIGINT: |
|
381 |
// l.add(fieldNames[i]); |
|
382 |
// break; |
|
383 |
// } |
|
384 | 390 |
} |
385 | 391 |
numericFieldNames = l.toArray(new String[l.size()]); |
386 | 392 |
integerFieldNames = lColors.toArray(new String[lColors.size()]); |
387 |
} catch (ReadException e) {
|
|
393 |
} catch (DataException e) {
|
|
388 | 394 |
NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e); |
389 | 395 |
} |
390 | 396 |
refreshControls(); |
391 | 397 |
} |
392 | 398 |
} |
393 |
private void refreshCmbFont(){ |
|
394 | 399 |
|
395 |
if (layer.getLabelingStrategy() instanceof AttrInTableLabelingStrategy) { |
|
396 |
AttrInTableLabelingStrategy aux = (AttrInTableLabelingStrategy) layer.getLabelingStrategy(); |
|
397 |
cmbFonts.setFont(aux.getFont()); |
|
398 |
} |
|
399 |
} |
|
400 |
|
|
401 | 400 |
private void refreshColorFont(){ |
402 | 401 |
|
403 | 402 |
getCmbColorField().removeAllItems(); |
... | ... | |
425 | 424 |
getCmbColorField().setSelectedItem(item); |
426 | 425 |
colorChooser.setColor(aux.getFixedColor()); |
427 | 426 |
|
428 |
} catch (ReadException e) {
|
|
427 |
} catch (DataException e) {
|
|
429 | 428 |
// should never happen |
430 | 429 |
NotificationManager.addWarning(PluginServices.getText(this, "could_not_restore_color_field"), e); |
431 | 430 |
} |
... | ... | |
441 | 440 |
} |
442 | 441 |
|
443 | 442 |
private void refreshCmbUnits() { |
444 |
getCmbUnits().setSelectedUnitIndex(Project.getDefaultDistanceUnits()); |
|
445 | 443 |
|
446 | 444 |
if (layer.getLabelingStrategy() instanceof AttrInTableLabelingStrategy) { |
447 | 445 |
AttrInTableLabelingStrategy aux = (AttrInTableLabelingStrategy) layer.getLabelingStrategy(); |
... | ... | |
449 | 447 |
} |
450 | 448 |
} |
451 | 449 |
|
450 |
private void refreshCmbRefSystem() { |
|
451 |
|
|
452 |
if (layer.getLabelingStrategy() instanceof AttrInTableLabelingStrategy) { |
|
453 |
AttrInTableLabelingStrategy aux = (AttrInTableLabelingStrategy) layer.getLabelingStrategy(); |
|
454 |
getCmbReferenceSystem().setSelectedIndex(aux.getReferenceSystem()); |
|
455 |
} |
|
456 |
} |
|
452 | 457 |
|
453 | 458 |
private void refreshTextHeight() { |
454 | 459 |
getCmbHeightField().removeAllItems(); |
... | ... | |
525 | 530 |
} |
526 | 531 |
|
527 | 532 |
public Class getLabelingStrategyClass() { |
528 |
return AttrInTableLabeling.class;
|
|
533 |
return AttrInTableLabelingStrategy.class;
|
|
529 | 534 |
} |
530 | 535 |
|
531 | 536 |
} |
Also available in: Unified diff