svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / VectorialUniqueValue.java @ 25074
History | View | Annotate | Download (20.3 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib��ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Color; |
45 |
import java.awt.Component; |
46 |
import java.awt.Dimension; |
47 |
import java.awt.GridLayout; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.event.ActionListener; |
50 |
import java.util.ArrayList; |
51 |
import java.util.Iterator; |
52 |
import java.util.Random; |
53 |
|
54 |
import javax.swing.DefaultComboBoxModel; |
55 |
import javax.swing.ImageIcon; |
56 |
import javax.swing.JCheckBox; |
57 |
import javax.swing.JComboBox; |
58 |
import javax.swing.JLabel; |
59 |
import javax.swing.JOptionPane; |
60 |
import javax.swing.JPanel; |
61 |
|
62 |
import org.apache.log4j.Logger; |
63 |
import org.gvsig.fmap.dal.exception.DataException; |
64 |
import org.gvsig.fmap.dal.exception.ReadException; |
65 |
import org.gvsig.fmap.dal.feature.Feature; |
66 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
67 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
68 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
69 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
70 |
import org.gvsig.fmap.mapcontext.layers.operations.ClassifiableVectorial; |
71 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
72 |
import org.gvsig.fmap.mapcontext.rendering.legend.AbstractClassifiedVectorLegend; |
73 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
74 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
75 |
import org.gvsig.fmap.mapcontext.rendering.legend.NullUniqueValue; |
76 |
import org.gvsig.fmap.mapcontext.rendering.legend.NullValue; |
77 |
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend; |
78 |
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort; |
79 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
80 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
81 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
82 |
import org.gvsig.gui.beans.swing.JBlank; |
83 |
import org.gvsig.gui.beans.swing.JButton; |
84 |
import org.gvsig.raster.datastruct.ColorItem; |
85 |
|
86 |
import com.iver.andami.PluginServices; |
87 |
import com.iver.andami.messages.NotificationManager; |
88 |
import com.iver.cit.gvsig.gui.styling.JComboBoxColorScheme; |
89 |
import com.iver.cit.gvsig.gui.styling.SymbolLevelsWindow; |
90 |
|
91 |
|
92 |
/**
|
93 |
* DOCUMENT ME!
|
94 |
*
|
95 |
* @author fjp To change the template for this generated type comment go to
|
96 |
* Window>Preferences>Java>Code Generation>Code and
|
97 |
* Comments
|
98 |
*/
|
99 |
public class VectorialUniqueValue extends JPanel implements ILegendPanel, ActionListener{ |
100 |
private static Logger logger = Logger.getLogger(VectorialUniqueValue.class.getName()); |
101 |
|
102 |
protected VectorialUniqueValueLegend theLegend;
|
103 |
private ClassifiableVectorial layer;
|
104 |
private SymbolTable symbolTable;
|
105 |
protected JComboBox cmbFields; |
106 |
private JButton btnRemoveAll; |
107 |
private JButton btnRemove; |
108 |
private JCheckBox chbUseDefault = null; |
109 |
private JSymbolPreviewButton defaultSymbolPrev;
|
110 |
private VectorialUniqueValueLegend auxLegend;
|
111 |
private JPanel pnlCenter; |
112 |
private ZSort zSort;
|
113 |
private JButton btnOpenSymbolLevelsEditor; |
114 |
|
115 |
private JComboBoxColorScheme cmbColorScheme;
|
116 |
private GridBagLayoutPanel defaultSymbolPanel = new GridBagLayoutPanel(); |
117 |
/**
|
118 |
*
|
119 |
*/
|
120 |
public VectorialUniqueValue() {
|
121 |
super();
|
122 |
initComponents(); |
123 |
} |
124 |
|
125 |
/**
|
126 |
* DOCUMENT ME!
|
127 |
*/
|
128 |
protected void initComponents() { |
129 |
/* JLabel label = new JLabel();
|
130 |
label.setIcon(new javax.swing.ImageIcon(Abrir.class.getClassLoader()
|
131 |
.getResource("images/ValoresUnicos.png")));
|
132 |
limagen[1] = new JLabel();
|
133 |
limagen[1] = label; */
|
134 |
JPanel pnlButtons = new JPanel(); |
135 |
|
136 |
JButton btnAddAll = new JButton(PluginServices.getText(this, |
137 |
"Anadir_todos"));
|
138 |
btnAddAll.setActionCommand("ADD_ALL_VALUES");
|
139 |
btnAddAll.addActionListener(this);
|
140 |
pnlButtons.add(btnAddAll); |
141 |
|
142 |
JButton btnAdd = new JButton(PluginServices.getText(this, "Anadir")); |
143 |
btnAdd.setActionCommand("ADD_VALUE");
|
144 |
btnAdd.addActionListener(this);
|
145 |
pnlButtons.add(btnAdd); |
146 |
|
147 |
btnRemoveAll = new JButton(PluginServices.getText(this, "Quitar_todos")); |
148 |
btnRemoveAll.setActionCommand("REMOVE_ALL");
|
149 |
btnRemoveAll.addActionListener(this);
|
150 |
pnlButtons.add(btnRemoveAll); |
151 |
|
152 |
btnRemove = new JButton(PluginServices.getText(this, "Quitar")); |
153 |
btnRemove.setActionCommand("REMOVE");
|
154 |
btnRemove.addActionListener(this);
|
155 |
pnlButtons.add(btnRemove); |
156 |
|
157 |
btnOpenSymbolLevelsEditor = new JButton(PluginServices.getText(this, "symbol_levels")); |
158 |
btnOpenSymbolLevelsEditor.addActionListener(this);
|
159 |
btnOpenSymbolLevelsEditor.setActionCommand("OPEN_SYMBOL_LEVEL_EDITOR");
|
160 |
pnlButtons.add(btnOpenSymbolLevelsEditor); |
161 |
|
162 |
pnlCenter = new JPanel(); |
163 |
pnlCenter.setLayout(new BorderLayout()); |
164 |
|
165 |
cmbFields = new JComboBox(); |
166 |
cmbFields.setActionCommand("FIELD_SELECTED");
|
167 |
cmbFields.addActionListener(this);
|
168 |
cmbFields.setVisible(true);
|
169 |
|
170 |
JPanel pnlNorth = new JPanel(); |
171 |
pnlNorth.setLayout(new GridLayout(0,2)); |
172 |
|
173 |
GridBagLayoutPanel auxPanel = new GridBagLayoutPanel();
|
174 |
JLabel lblFieldClassification = new JLabel(PluginServices.getText( |
175 |
this, "Campo_de_clasificacion")+": "); |
176 |
auxPanel.add(lblFieldClassification); |
177 |
auxPanel.add(cmbFields); |
178 |
pnlNorth.add(auxPanel); |
179 |
|
180 |
auxPanel = new GridBagLayoutPanel();
|
181 |
auxPanel.add(new JLabel(PluginServices.getText(this, "color_scheme")+": ")); |
182 |
cmbColorScheme = new JComboBoxColorScheme(false); |
183 |
cmbColorScheme.addActionListener(this);
|
184 |
auxPanel.add(cmbColorScheme); |
185 |
pnlNorth.add(auxPanel); |
186 |
|
187 |
|
188 |
defaultSymbolPanel.add(getChbUseDefault(), null);
|
189 |
pnlNorth.add(defaultSymbolPanel); |
190 |
pnlNorth.add(new JBlank(0,30)); |
191 |
|
192 |
this.setLayout(new BorderLayout()); |
193 |
this.add(pnlNorth, BorderLayout.NORTH); |
194 |
this.add(pnlCenter, BorderLayout.CENTER); |
195 |
this.add(pnlButtons, BorderLayout.SOUTH); |
196 |
|
197 |
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* DOCUMENT ME!
|
202 |
*/
|
203 |
private void fillTableValues() { |
204 |
FeatureStore elRs; |
205 |
|
206 |
try {
|
207 |
elRs = ((FLyrVect) layer).getFeatureStore(); |
208 |
// logger.debug("elRs.start()");
|
209 |
// elRs.start();
|
210 |
|
211 |
// int idField = -1;
|
212 |
String fieldName = (String) cmbFields.getSelectedItem(); |
213 |
if (fieldName==null) { |
214 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"no_hay_campo_seleccionado")); |
215 |
return;
|
216 |
} |
217 |
|
218 |
// idField = elRs.getFieldIndexByName(fieldName);
|
219 |
auxLegend.setClassifyingFieldNames(new String[] {fieldName}); |
220 |
|
221 |
//long numReg = elRs.getRowCount();
|
222 |
// if (idField == -1) {
|
223 |
// NotificationManager.addWarning(
|
224 |
// PluginServices.getText(this, "unrecognized_field_name")+" " + fieldName, null);
|
225 |
//
|
226 |
// return;
|
227 |
// }
|
228 |
|
229 |
symbolTable.removeAllItems(); |
230 |
|
231 |
int numSymbols = 0; |
232 |
ISymbol theSymbol = null;
|
233 |
|
234 |
//auxLegend=(VectorialUniqueValueLegend)m_lyr.getLegend();
|
235 |
auxLegend = LegendFactory.createVectorialUniqueValueLegend(layer.getShapeType()); |
236 |
|
237 |
Object clave=null; |
238 |
|
239 |
//Object resul;
|
240 |
if (chbUseDefault.isSelected()) {
|
241 |
auxLegend.getDefaultSymbol().setDescription("Default");
|
242 |
auxLegend.addSymbol(new NullUniqueValue(),
|
243 |
auxLegend.getDefaultSymbol()); |
244 |
} |
245 |
|
246 |
ColorItem[] colorScheme = cmbColorScheme.getSelectedColors();
|
247 |
|
248 |
Color[] colors = new Color[colorScheme.length]; |
249 |
for (int i = 0; i < colorScheme.length; i++) { |
250 |
colors[i] = colorScheme[i].getColor(); |
251 |
} |
252 |
auxLegend.setColorScheme(colors); |
253 |
|
254 |
Random rand = new Random(System.currentTimeMillis()); |
255 |
|
256 |
FeatureSet set = elRs.getFeatureSet(); |
257 |
|
258 |
if (set.getSize() > 100) { |
259 |
int resp = JOptionPane.showConfirmDialog(this, PluginServices |
260 |
.getText(this, "mas_de_100_simbolos"), PluginServices |
261 |
.getText(this, "quiere_continuar"), |
262 |
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); |
263 |
|
264 |
if ((resp == JOptionPane.NO_OPTION) |
265 |
|| (resp == JOptionPane.DEFAULT_OPTION)) {
|
266 |
set.dispose(); |
267 |
return;
|
268 |
} |
269 |
} |
270 |
|
271 |
Iterator iterator = set.iterator();
|
272 |
while (iterator.hasNext()) {
|
273 |
Feature feature = (Feature) iterator.next(); |
274 |
clave = feature.get(fieldName); |
275 |
// }
|
276 |
// for (int j = 0; j < elRs.getRowCount(); j++) {
|
277 |
// clave = elRs.getFieldValue(j, idField);
|
278 |
|
279 |
if (clave instanceof NullValue) { |
280 |
continue;
|
281 |
} |
282 |
|
283 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo.
|
284 |
if (auxLegend.getSymbolByValue(clave) == null) { |
285 |
//si no esta creado el simbolo se crea
|
286 |
// jaume (moved to ISymbol); theSymbol = new FSymbol(layer.getShapeType());
|
287 |
theSymbol = SymbologyFactory. |
288 |
createDefaultSymbolByShapeType(layer.getShapeType(), |
289 |
colorScheme[rand.nextInt(colorScheme.length)].getColor()); |
290 |
theSymbol.setDescription(clave.toString()); |
291 |
auxLegend.addSymbol(clave, theSymbol); |
292 |
|
293 |
|
294 |
} |
295 |
} // for
|
296 |
|
297 |
symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
298 |
auxLegend.getValues(), auxLegend.getDescriptions()); |
299 |
// elRs.stop();
|
300 |
set.dispose(); |
301 |
} catch (DataException e) {
|
302 |
NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
303 |
} |
304 |
|
305 |
btnRemoveAll.setEnabled(true);
|
306 |
btnRemove.setEnabled(true);
|
307 |
|
308 |
//m_bCacheDirty = false;
|
309 |
} |
310 |
|
311 |
/**
|
312 |
* A partir de los registros de la tabla, regenera el FRenderer. (No solo
|
313 |
* el symbolList, si no tambi�n el arrayKeys y el defaultRenderer
|
314 |
*/
|
315 |
private void fillSymbolListFromTable() { |
316 |
Object clave=null; |
317 |
ISymbol theSymbol; |
318 |
|
319 |
String fieldName = (String) cmbFields.getSelectedItem(); |
320 |
auxLegend.setClassifyingFieldNames(new String[] {fieldName} ); |
321 |
FLyrVect m = (FLyrVect) layer; |
322 |
|
323 |
try {
|
324 |
int fieldType = m.getFeatureStore().getDefaultFeatureType()
|
325 |
.getAttributeDescriptor(cmbFields.getSelectedIndex()) |
326 |
.getDataType(); |
327 |
// int fieldType = m.getSource().getRecordset().getFieldType((int)cmbFields.getSelectedIndex());
|
328 |
auxLegend.setClassifyingFieldTypes(new int[] { fieldType }); |
329 |
} catch (DataException e) {
|
330 |
NotificationManager.addError(PluginServices.getText(this, "could_not_setup_legend"), e); |
331 |
} |
332 |
|
333 |
auxLegend.clear(); |
334 |
|
335 |
for (int row = 0; row < symbolTable.getRowCount(); row++) { |
336 |
clave = symbolTable.getFieldValue(row, 1);
|
337 |
theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
|
338 |
theSymbol.setDescription((String) symbolTable.getFieldValue(row, 2)); |
339 |
auxLegend.addSymbol(clave, theSymbol); |
340 |
} |
341 |
|
342 |
if(chbUseDefault.isSelected()){
|
343 |
if(defaultSymbolPrev.getSymbol() != null){ |
344 |
String description = PluginServices.getText(this,"default"); |
345 |
defaultSymbolPrev.getSymbol().setDescription(description); |
346 |
auxLegend.addSymbol(new NullUniqueValue(), defaultSymbolPrev.getSymbol());
|
347 |
} |
348 |
} |
349 |
} |
350 |
|
351 |
/**
|
352 |
* DOCUMENT ME!
|
353 |
*/
|
354 |
private void fillFieldNames() { |
355 |
FeatureStore rs; |
356 |
|
357 |
try {
|
358 |
rs = ((FLyrVect) layer).getFeatureStore(); |
359 |
// logger.debug("rs.start()");
|
360 |
// rs.start();
|
361 |
|
362 |
ArrayList names=new ArrayList(); |
363 |
Iterator iterator=rs.getDefaultFeatureType().iterator();
|
364 |
while (iterator.hasNext()) {
|
365 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next(); |
366 |
names.add(descriptor.getName()); |
367 |
} |
368 |
// String[] nomFields = new String[rs.getFieldCount()];
|
369 |
//
|
370 |
// for (int i = 0; i < rs.getFieldCount(); i++) {
|
371 |
// nomFields[i] = rs.getFieldName(i).trim();
|
372 |
// }
|
373 |
//
|
374 |
// rs.stop();
|
375 |
|
376 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(names.toArray(new String[0])); |
377 |
cmbFields.setModel(cM); |
378 |
|
379 |
// fieldsListValor.setSelectedIndex(0);
|
380 |
} catch (DataException e) {
|
381 |
NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
382 |
} |
383 |
} |
384 |
|
385 |
public void setData(FLayer layer, ILegend legend) { |
386 |
this.layer = (ClassifiableVectorial) layer;
|
387 |
int shapeType = 0; |
388 |
try {
|
389 |
shapeType = this.layer.getShapeType();
|
390 |
} catch (ReadException e) {
|
391 |
NotificationManager.addError(PluginServices.getText(this, "generating_intervals"), e); |
392 |
} |
393 |
|
394 |
getDefaultSymbolPrev(shapeType); |
395 |
|
396 |
if (symbolTable != null) { |
397 |
pnlCenter.remove(symbolTable); |
398 |
} |
399 |
symbolTable = new SymbolTable(this, SymbolTable.VALUES_TYPE, shapeType); |
400 |
pnlCenter.add(symbolTable, BorderLayout.CENTER);
|
401 |
|
402 |
fillFieldNames(); |
403 |
|
404 |
symbolTable.removeAllItems(); |
405 |
|
406 |
if (VectorialUniqueValueLegend.class.equals(legend.getClass())) {
|
407 |
auxLegend = (VectorialUniqueValueLegend) legend; |
408 |
getChbUseDefault().setSelected(auxLegend.isUseDefaultSymbol()); |
409 |
cmbFields.getModel().setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
|
410 |
setColorScheme(); |
411 |
symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
412 |
auxLegend.getValues(),auxLegend.getDescriptions()); |
413 |
zSort = auxLegend.getZSort(); |
414 |
chbUseDefault.setSelected(auxLegend.isUseDefaultSymbol()); |
415 |
} else {
|
416 |
auxLegend = new VectorialUniqueValueLegend(shapeType);
|
417 |
} |
418 |
defaultSymbolPrev.setSymbol(auxLegend.getDefaultSymbol()); |
419 |
} |
420 |
|
421 |
|
422 |
private void setColorScheme(){ |
423 |
|
424 |
if(auxLegend.getColorScheme() != null) { |
425 |
ColorItem[] colors = new ColorItem[auxLegend.getColorScheme().length]; |
426 |
for (int i = 0; i < auxLegend.getColorScheme().length; i++) { |
427 |
colors[i] = new ColorItem();
|
428 |
colors[i].setColor(auxLegend.getColorScheme()[i]); |
429 |
} |
430 |
cmbColorScheme.setSelectedColors(colors); |
431 |
} |
432 |
} |
433 |
|
434 |
private void getDefaultSymbolPrev(int shapeType) { |
435 |
if(defaultSymbolPrev == null){ |
436 |
defaultSymbolPrev = new JSymbolPreviewButton(shapeType);
|
437 |
defaultSymbolPrev.setPreferredSize(new Dimension(110,20)); |
438 |
defaultSymbolPrev.addActionListener(this);
|
439 |
defaultSymbolPanel.add(defaultSymbolPrev,null);
|
440 |
} |
441 |
} |
442 |
|
443 |
/* (non-Javadoc)
|
444 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend()
|
445 |
*/
|
446 |
public ILegend getLegend() {
|
447 |
fillSymbolListFromTable(); |
448 |
|
449 |
if (auxLegend != null) { |
450 |
// your settings that are not the set of symbols must be located here
|
451 |
auxLegend.setClassifyingFieldNames( |
452 |
new String[] {(String) cmbFields.getSelectedItem()}); |
453 |
|
454 |
if(defaultSymbolPrev.getSymbol() != null) { |
455 |
auxLegend.setDefaultSymbol(defaultSymbolPrev.getSymbol()); |
456 |
} |
457 |
|
458 |
auxLegend.useDefaultSymbol(chbUseDefault.isSelected()); |
459 |
|
460 |
theLegend = auxLegend; |
461 |
} |
462 |
theLegend.setZSort(zSort); |
463 |
|
464 |
return theLegend;
|
465 |
} |
466 |
|
467 |
private JCheckBox getChbUseDefault() { |
468 |
if (chbUseDefault == null) { |
469 |
chbUseDefault = new JCheckBox(); |
470 |
chbUseDefault.setSelected(false);
|
471 |
chbUseDefault.addActionListener(new java.awt.event.ActionListener() {
|
472 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
473 |
if (chbUseDefault.isSelected()) {
|
474 |
auxLegend.useDefaultSymbol(true);
|
475 |
} else {
|
476 |
auxLegend.useDefaultSymbol(false);
|
477 |
} |
478 |
} |
479 |
}); |
480 |
chbUseDefault.setText(PluginServices.getText(this, "resto_valores")+ ": "); |
481 |
} |
482 |
|
483 |
return chbUseDefault;
|
484 |
} |
485 |
|
486 |
/**
|
487 |
* A�ade el resto de valores.
|
488 |
*/
|
489 |
private void addDefault() { |
490 |
auxLegend.getDefaultSymbol().setDescription("Default");
|
491 |
auxLegend.addSymbol(new NullUniqueValue(), auxLegend.getDefaultSymbol());
|
492 |
symbolTable.addTableRecord(auxLegend.getDefaultSymbol(), |
493 |
new NullUniqueValue(), auxLegend.getDefaultSymbol().getDescription());
|
494 |
symbolTable.repaint(); |
495 |
} |
496 |
|
497 |
/**
|
498 |
* Elimina el resto de valores que no estan representados por ning�n otro s�mbolo..
|
499 |
*/
|
500 |
private void delDefault() { |
501 |
auxLegend.delSymbol(new NullUniqueValue());
|
502 |
symbolTable.removeRow(new NullUniqueValue());
|
503 |
symbolTable.repaint(); |
504 |
} |
505 |
|
506 |
|
507 |
public void actionPerformed(ActionEvent e) { |
508 |
|
509 |
//modificar el combobox de valor
|
510 |
if (e.getActionCommand() == "FIELD_SELECTED") { |
511 |
JComboBox cb = (JComboBox) e.getSource(); |
512 |
String fieldName = (String) cb.getSelectedItem(); |
513 |
symbolTable.removeAllItems(); |
514 |
|
515 |
// if (theLegend.getClassifyingFieldNames()!=null && fieldName != theLegend.getClassifyingFieldNames()[0]) {
|
516 |
// //m_bCacheDirty = true;
|
517 |
// theLegend.setClassifyingFieldNames(new String[] {fieldName});
|
518 |
// }
|
519 |
//
|
520 |
// //////////////////////////////////////////PEPE
|
521 |
// FLyrVect m = (FLyrVect) layer;
|
522 |
// try {
|
523 |
// int fieldType = m.getSource().getRecordset().getFieldType((int)cb.getSelectedIndex());
|
524 |
// if (theLegend.getClassifyingFieldTypes()!=null && fieldType != theLegend.getClassifyingFieldTypes()[0]) {
|
525 |
// //m_bCacheDirty = true;
|
526 |
// theLegend.setClassifyingFieldTypes(new int[] {fieldType});
|
527 |
// }
|
528 |
// } catch (ReadDriverException e1) {
|
529 |
// NotificationManager.addError(PluginServices.getText(this, "could_not_setup_legend"), e1);
|
530 |
// }
|
531 |
// /////////////////////////////////////////PEPE
|
532 |
} |
533 |
|
534 |
// add all elements by value
|
535 |
if (e.getActionCommand() == "ADD_ALL_VALUES") { |
536 |
fillTableValues(); |
537 |
} |
538 |
|
539 |
// add only one value
|
540 |
if (e.getActionCommand() == "ADD_VALUE") { |
541 |
try {
|
542 |
symbolTable.addTableRecord(SymbologyFactory. |
543 |
createDefaultSymbolByShapeType(layer.getShapeType()), |
544 |
new Double(0.0), "0 - 0"); |
545 |
} catch (ReadException ex) {
|
546 |
NotificationManager.addError(PluginServices.getText(this, "getting_shape_type"), ex); |
547 |
} |
548 |
} |
549 |
|
550 |
//Vacia la tabla
|
551 |
if (e.getActionCommand() == "REMOVE_ALL") { |
552 |
symbolTable.removeAllItems(); |
553 |
auxLegend.setZSort(null);
|
554 |
zSort = null;
|
555 |
} |
556 |
|
557 |
//Quitar solo el elemento seleccionado
|
558 |
if (e.getActionCommand() == "REMOVE") { |
559 |
symbolTable.removeSelectedRows(); |
560 |
} |
561 |
|
562 |
if (e.getActionCommand() == "OPEN_SYMBOL_LEVEL_EDITOR") { |
563 |
|
564 |
if (auxLegend != null) { |
565 |
ZSort myZSort = ((AbstractClassifiedVectorLegend) getLegend()).getZSort(); |
566 |
if (myZSort == null && theLegend != null) { |
567 |
myZSort = new ZSort(theLegend);
|
568 |
} |
569 |
SymbolLevelsWindow sl = new SymbolLevelsWindow(myZSort);
|
570 |
PluginServices.getMDIManager().addWindow(sl); |
571 |
zSort = sl.getZSort(); |
572 |
auxLegend.setZSort(zSort); |
573 |
} |
574 |
|
575 |
} |
576 |
} |
577 |
|
578 |
public String getDescription() { |
579 |
return PluginServices.getText(this,"Dado_un_campo_de_atributos") + "," + PluginServices.getText(this,"muestra_los_elementos_de_la_capa_usando_un_simbolo_por_cada_valor_unico") + "."; |
580 |
} |
581 |
|
582 |
public ImageIcon getIcon() { |
583 |
return new ImageIcon(this.getClass().getClassLoader(). |
584 |
getResource("images/ValoresUnicos.png"));
|
585 |
} |
586 |
|
587 |
public Class getParentClass() { |
588 |
return Categories.class;
|
589 |
} |
590 |
|
591 |
public String getTitle() { |
592 |
return PluginServices.getText(this,"Valores_unicos"); |
593 |
} |
594 |
|
595 |
public JPanel getPanel() { |
596 |
return this; |
597 |
} |
598 |
|
599 |
public Class getLegendClass() { |
600 |
return VectorialUniqueValueLegend.class;
|
601 |
} |
602 |
|
603 |
|
604 |
public boolean isSuitableFor(FLayer layer) { |
605 |
return (layer instanceof FLyrVect); |
606 |
} |
607 |
} |