Revision 10293 branches/simbologia/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/VectorialUniqueValue.java
VectorialUniqueValue.java | ||
---|---|---|
70 | 70 |
import com.hardcode.gdbms.engine.values.Value; |
71 | 71 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
72 | 72 |
import com.iver.andami.PluginServices; |
73 |
import com.iver.andami.messages.NotificationManager; |
|
73 | 74 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
74 | 75 |
import com.iver.cit.gvsig.fmap.core.symbols.PictureMarkerSymbol; |
75 | 76 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
... | ... | |
96 | 97 |
|
97 | 98 |
// private TOC m_TOC; |
98 | 99 |
private VectorialUniqueValueLegend m_Renderer; |
99 |
private ClassifiableVectorial m_lyr;
|
|
100 |
private ClassifiableVectorial layer;
|
|
100 | 101 |
|
101 | 102 |
//private boolean m_bCacheDirty = true; |
102 |
private FSymbolTable m_symbolTable = new FSymbolTable("values");
|
|
103 |
private JComboBox m_cboFields;
|
|
103 |
private FSymbolTable symbolTable;
|
|
104 |
private JComboBox cmbFields;
|
|
104 | 105 |
private JButton quitartodo; |
105 | 106 |
private JButton quitar; |
106 | 107 |
private JCheckBox chbUseDefault = null; |
107 | 108 |
private VectorialUniqueValueLegend auxLegend; |
108 | 109 |
private PictureMarkerSymbol previewSymbol; |
110 |
private JPanel pnlCenter; |
|
109 | 111 |
|
110 | 112 |
/** |
111 | 113 |
* |
... | ... | |
147 | 149 |
quitar.addActionListener(listener); |
148 | 150 |
botonestabla.add(quitar); |
149 | 151 |
|
150 |
JPanel ptabla = new JPanel();
|
|
151 |
ptabla.setLayout(new BorderLayout());
|
|
152 |
pnlCenter = new JPanel();
|
|
153 |
pnlCenter.setLayout(new BorderLayout());
|
|
152 | 154 |
|
153 |
m_cboFields = new JComboBox();
|
|
154 |
m_cboFields.setActionCommand("FIELD_SELECTED");
|
|
155 |
m_cboFields.addActionListener(listener);
|
|
156 |
m_cboFields.setVisible(true);
|
|
155 |
cmbFields = new JComboBox();
|
|
156 |
cmbFields.setActionCommand("FIELD_SELECTED");
|
|
157 |
cmbFields.addActionListener(listener);
|
|
158 |
cmbFields.setVisible(true);
|
|
157 | 159 |
|
158 | 160 |
JPanel pAux1 = new JPanel(); |
159 | 161 |
|
... | ... | |
166 | 168 |
JLabel lblFieldClassification = new JLabel(PluginServices.getText( |
167 | 169 |
this, "Campo_de_clasificacion")); |
168 | 170 |
pAux1.add(lblFieldClassification); |
169 |
pAux1.add(m_cboFields);
|
|
171 |
pAux1.add(cmbFields);
|
|
170 | 172 |
|
171 |
ptabla.add(m_symbolTable, BorderLayout.CENTER); |
|
172 |
m_symbolTable.setPreferredSize(new Dimension(400, 200)); |
|
173 | 173 |
this.setLayout(new BorderLayout()); |
174 | 174 |
this.add(pAux1, BorderLayout.NORTH); |
175 |
this.add(ptabla, BorderLayout.CENTER);
|
|
175 |
this.add(pnlCenter, BorderLayout.CENTER);
|
|
176 | 176 |
this.add(botonestabla, BorderLayout.SOUTH); |
177 | 177 |
pAux1.add(getChbUseDefault(), null); |
178 | 178 |
} |
... | ... | |
184 | 184 |
DataSource elRs; |
185 | 185 |
|
186 | 186 |
try { |
187 |
elRs = ((FLyrVect) m_lyr).getRecordset();
|
|
187 |
elRs = ((FLyrVect) layer).getRecordset();
|
|
188 | 188 |
logger.debug("elRs.start()"); |
189 | 189 |
elRs.start(); |
190 | 190 |
|
191 | 191 |
int idField = -1; |
192 |
String fieldName = (String) m_cboFields.getSelectedItem();
|
|
192 |
String fieldName = (String) cmbFields.getSelectedItem();
|
|
193 | 193 |
if (fieldName==null) { |
194 | 194 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"no_hay_campo_seleccionado")); |
195 | 195 |
return; |
... | ... | |
206 | 206 |
return; |
207 | 207 |
} |
208 | 208 |
|
209 |
m_symbolTable.removeAllItems();
|
|
209 |
symbolTable.removeAllItems(); |
|
210 | 210 |
|
211 | 211 |
int numSymbols = 0; |
212 | 212 |
FSymbol theSymbol = null; |
213 | 213 |
|
214 | 214 |
//auxLegend=(VectorialUniqueValueLegend)m_lyr.getLegend(); |
215 |
auxLegend = LegendFactory.createVectorialUniqueValueLegend(m_lyr.getShapeType());
|
|
215 |
auxLegend = LegendFactory.createVectorialUniqueValueLegend(layer.getShapeType());
|
|
216 | 216 |
|
217 | 217 |
Value clave; |
218 | 218 |
|
... | ... | |
233 | 233 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo. |
234 | 234 |
if (auxLegend.getSymbolByValue(clave) == null) { |
235 | 235 |
//si no esta creado el simbolo se crea |
236 |
theSymbol = new FSymbol(m_lyr.getShapeType());
|
|
236 |
theSymbol = new FSymbol(layer.getShapeType());
|
|
237 | 237 |
|
238 | 238 |
theSymbol.setDescription(clave.toString()); |
239 | 239 |
auxLegend.addSymbol(clave, theSymbol); |
... | ... | |
256 | 256 |
} |
257 | 257 |
} // for |
258 | 258 |
|
259 |
m_symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(),
|
|
259 |
symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
|
260 | 260 |
auxLegend.getValues(), auxLegend.getDescriptions()); |
261 | 261 |
elRs.stop(); |
262 | 262 |
} catch (DriverException e) { |
... | ... | |
285 | 285 |
|
286 | 286 |
boolean bRestoValores = false; // PONERLO EN UN CHECKBOX |
287 | 287 |
int hasta; |
288 |
String fieldName = (String) m_cboFields.getSelectedItem();
|
|
288 |
String fieldName = (String) cmbFields.getSelectedItem();
|
|
289 | 289 |
m_Renderer.setFieldName(fieldName); |
290 | 290 |
|
291 | 291 |
if (bRestoValores) { |
292 |
hasta = m_symbolTable.getRowCount() - 1;
|
|
292 |
hasta = symbolTable.getRowCount() - 1; |
|
293 | 293 |
} else { |
294 |
hasta = m_symbolTable.getRowCount();
|
|
294 |
hasta = symbolTable.getRowCount(); |
|
295 | 295 |
} |
296 | 296 |
|
297 |
for (int row = 0; row < m_symbolTable.getRowCount(); row++) {
|
|
298 |
clave = (Value) m_symbolTable.getFieldValue(row, 1);
|
|
299 |
theSymbol = (FSymbol) m_symbolTable.getFieldValue(row, 0);
|
|
300 |
theSymbol.setDescription((String) m_symbolTable.getFieldValue(row, 2));
|
|
297 |
for (int row = 0; row < symbolTable.getRowCount(); row++) { |
|
298 |
clave = (Value) symbolTable.getFieldValue(row, 1); |
|
299 |
theSymbol = (FSymbol) symbolTable.getFieldValue(row, 0); |
|
300 |
theSymbol.setDescription((String) symbolTable.getFieldValue(row, 2)); |
|
301 | 301 |
m_Renderer.addSymbol(clave, theSymbol); |
302 | 302 |
System.out.println(clave); |
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
if (bRestoValores) { |
306 |
theSymbol = (FSymbol) m_symbolTable.getFieldValue(hasta, 0);
|
|
306 |
theSymbol = (FSymbol) symbolTable.getFieldValue(hasta, 0); |
|
307 | 307 |
m_Renderer.setDefaultSymbol(theSymbol); |
308 | 308 |
} |
309 | 309 |
} |
... | ... | |
315 | 315 |
DataSource rs; |
316 | 316 |
|
317 | 317 |
try { |
318 |
rs = ((AlphanumericData) m_lyr).getRecordset();
|
|
318 |
rs = ((AlphanumericData) layer).getRecordset();
|
|
319 | 319 |
logger.debug("rs.start()"); |
320 | 320 |
rs.start(); |
321 | 321 |
|
... | ... | |
328 | 328 |
rs.stop(); |
329 | 329 |
|
330 | 330 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields); |
331 |
m_cboFields.setModel(cM);
|
|
331 |
cmbFields.setModel(cM);
|
|
332 | 332 |
|
333 | 333 |
// fieldsListValor.setSelectedIndex(0); |
334 | 334 |
} catch (DriverException e) { |
... | ... | |
337 | 337 |
e.printStackTrace(); |
338 | 338 |
} |
339 | 339 |
|
340 |
m_symbolTable.removeAllItems();
|
|
340 |
symbolTable.removeAllItems(); |
|
341 | 341 |
} |
342 | 342 |
|
343 | 343 |
/** |
... | ... | |
346 | 346 |
* @param lyr DOCUMENT ME! |
347 | 347 |
* @param r DOCUMENT ME! |
348 | 348 |
*/ |
349 |
public void setData(FLayer lyr, Legend r) { |
|
350 |
// OJO, COMPROBAR ANTES SI ES DE TIPO VECTORIAL |
|
351 |
m_lyr = (ClassifiableVectorial) lyr; |
|
349 |
public void setData(FLayer layer, Legend legend) { |
|
350 |
this.layer = (ClassifiableVectorial) layer; |
|
351 |
int shapeType = 0; |
|
352 |
try { |
|
353 |
shapeType = this.layer.getShapeType(); |
|
354 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) { |
|
355 |
NotificationManager.addError(PluginServices.getText(this, "generating_intervals"), e); |
|
356 |
} |
|
357 |
|
|
358 |
if (symbolTable != null) |
|
359 |
pnlCenter.remove(symbolTable); |
|
360 |
symbolTable = new FSymbolTable("values", shapeType); |
|
361 |
pnlCenter.add(symbolTable, BorderLayout.CENTER); |
|
362 |
|
|
352 | 363 |
fillFieldNames(); |
353 | 364 |
|
354 | 365 |
// Si es de valor ?nico, rellenamos la tabla |
355 | 366 |
// y seleccionamos el campo que estamos usando |
356 |
m_symbolTable.removeAllItems();
|
|
367 |
symbolTable.removeAllItems(); |
|
357 | 368 |
|
358 |
if (r instanceof VectorialUniqueValueLegend) {
|
|
359 |
m_Renderer = (VectorialUniqueValueLegend) r;
|
|
369 |
if (legend instanceof VectorialUniqueValueLegend) {
|
|
370 |
m_Renderer = (VectorialUniqueValueLegend) legend;
|
|
360 | 371 |
getChbUseDefault().setSelected(m_Renderer.isUseDefaultSymbol()); |
361 |
m_cboFields.getModel().setSelectedItem(m_Renderer.getFieldName());
|
|
362 |
m_symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(),
|
|
372 |
cmbFields.getModel().setSelectedItem(m_Renderer.getFieldName());
|
|
373 |
symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(), |
|
363 | 374 |
m_Renderer.getValues(), m_Renderer.getDescriptions()); |
364 | 375 |
} else { |
365 |
try { |
|
366 |
// Si la capa viene con otro tipo de leyenda, creamos |
|
367 |
// una nueva del tipo que maneja este panel |
|
368 |
m_Renderer = new VectorialUniqueValueLegend(m_lyr.getShapeType()); |
|
369 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) { |
|
370 |
// TODO Auto-generated catch block |
|
371 |
e.printStackTrace(); |
|
372 |
} |
|
376 |
m_Renderer = new VectorialUniqueValueLegend(shapeType); |
|
373 | 377 |
} |
374 | 378 |
} |
375 | 379 |
|
... | ... | |
418 | 422 |
private void addDefault() { |
419 | 423 |
auxLegend.getDefaultSymbol().setDescription("Default"); |
420 | 424 |
auxLegend.addSymbol(new NullUniqueValue(), auxLegend.getDefaultSymbol()); |
421 |
m_symbolTable.addTableRecord(auxLegend.getDefaultSymbol(),
|
|
425 |
symbolTable.addTableRecord(auxLegend.getDefaultSymbol(), |
|
422 | 426 |
new NullUniqueValue(), auxLegend.getDefaultSymbol().getDescription()); |
423 |
m_symbolTable.repaint();
|
|
427 |
symbolTable.repaint(); |
|
424 | 428 |
} |
425 | 429 |
|
426 | 430 |
/** |
... | ... | |
428 | 432 |
*/ |
429 | 433 |
private void delDefault() { |
430 | 434 |
auxLegend.delSymbol(new NullUniqueValue()); |
431 |
m_symbolTable.removeRow(new NullUniqueValue());
|
|
432 |
m_symbolTable.repaint();
|
|
435 |
symbolTable.removeRow(new NullUniqueValue()); |
|
436 |
symbolTable.repaint(); |
|
433 | 437 |
} |
434 | 438 |
|
435 | 439 |
/** |
... | ... | |
459 | 463 |
JComboBox cb = (JComboBox) e.getSource(); |
460 | 464 |
String fieldName = (String) cb.getSelectedItem(); |
461 | 465 |
System.out.println("Nombre del campo: " + fieldName); |
462 |
m_symbolTable.removeAllItems();
|
|
466 |
symbolTable.removeAllItems(); |
|
463 | 467 |
|
464 | 468 |
if (fieldName != m_Renderer.getFieldName()) { |
465 | 469 |
//m_bCacheDirty = true; |
... | ... | |
475 | 479 |
//A?adir un ?nico elemento |
476 | 480 |
if (e.getActionCommand() == "ADD_VALUE") { |
477 | 481 |
try { |
478 |
m_symbolTable.addTableRecord(new FSymbol(
|
|
479 |
m_lyr.getShapeType()),
|
|
482 |
symbolTable.addTableRecord(new FSymbol( |
|
483 |
layer.getShapeType()),
|
|
480 | 484 |
ValueFactory.createValue(0.0), "0 - 0"); |
481 | 485 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) { |
482 | 486 |
e1.printStackTrace(); |
... | ... | |
490 | 494 |
|
491 | 495 |
//Vacia la tabla |
492 | 496 |
if (e.getActionCommand() == "REMOVE_ALL") { |
493 |
m_symbolTable.removeAllItems();
|
|
497 |
symbolTable.removeAllItems(); |
|
494 | 498 |
|
495 | 499 |
// aceptar.setEnabled(false); |
496 | 500 |
} |
497 | 501 |
|
498 | 502 |
//Quitar solo el elemento seleccionado |
499 | 503 |
if (e.getActionCommand() == "REMOVE") { |
500 |
m_symbolTable.removeSelectedRows();
|
|
504 |
symbolTable.removeSelectedRows(); |
|
501 | 505 |
} |
502 | 506 |
} |
503 | 507 |
} |
Also available in: Unified diff