root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / VectorialUniqueValue.java @ 24306
History | View | Annotate | Download (17.8 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.Random; |
51 |
|
52 |
import javax.swing.BoxLayout; |
53 |
import javax.swing.DefaultComboBoxModel; |
54 |
import javax.swing.ImageIcon; |
55 |
import javax.swing.JCheckBox; |
56 |
import javax.swing.JComboBox; |
57 |
import javax.swing.JLabel; |
58 |
import javax.swing.JOptionPane; |
59 |
import javax.swing.JPanel; |
60 |
|
61 |
import org.apache.log4j.Logger; |
62 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
63 |
import org.gvsig.gui.beans.swing.JBlank; |
64 |
import org.gvsig.gui.beans.swing.JButton; |
65 |
import org.gvsig.raster.datastruct.ColorItem; |
66 |
|
67 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
68 |
import com.hardcode.gdbms.engine.data.DataSource; |
69 |
import com.hardcode.gdbms.engine.values.NullValue; |
70 |
import com.hardcode.gdbms.engine.values.Value; |
71 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
72 |
import com.iver.andami.PluginServices; |
73 |
import com.iver.andami.messages.NotificationManager; |
74 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
75 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
76 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
77 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
78 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
79 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
80 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
81 |
import com.iver.cit.gvsig.fmap.rendering.AbstractClassifiedVectorLegend; |
82 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
83 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
84 |
import com.iver.cit.gvsig.fmap.rendering.NullUniqueValue; |
85 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
86 |
import com.iver.cit.gvsig.fmap.rendering.ZSort; |
87 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass; |
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 JButton moveUp; |
109 |
private JButton moveDown; |
110 |
private JCheckBox chbUseDefault = null; |
111 |
private JSymbolPreviewButton defaultSymbolPrev;
|
112 |
private VectorialUniqueValueLegend auxLegend;
|
113 |
private JPanel pnlCenter; |
114 |
private JPanel pnlMovBut; |
115 |
private ZSort zSort;
|
116 |
private JButton btnOpenSymbolLevelsEditor; |
117 |
private GridBagLayoutPanel defaultSymbolPanel = new GridBagLayoutPanel(); |
118 |
|
119 |
private JComboBoxColorScheme cmbColorScheme;
|
120 |
|
121 |
/**
|
122 |
*
|
123 |
*/
|
124 |
public VectorialUniqueValue() {
|
125 |
super();
|
126 |
initComponents(); |
127 |
} |
128 |
|
129 |
/**
|
130 |
* DOCUMENT ME!
|
131 |
*/
|
132 |
protected void initComponents() { |
133 |
|
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 |
* DOCUMENT ME!
|
201 |
*/
|
202 |
private void fillTableValues() { |
203 |
DataSource elRs;
|
204 |
|
205 |
try {
|
206 |
elRs = ((FLyrVect) layer).getRecordset(); |
207 |
logger.debug("elRs.start()");
|
208 |
elRs.start(); |
209 |
|
210 |
int idField = -1; |
211 |
String fieldName = (String) cmbFields.getSelectedItem(); |
212 |
if (fieldName==null) { |
213 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"no_hay_campo_seleccionado")); |
214 |
return;
|
215 |
} |
216 |
|
217 |
idField = elRs.getFieldIndexByName(fieldName); |
218 |
auxLegend.setClassifyingFieldNames(new String[] {fieldName}); |
219 |
|
220 |
//long numReg = elRs.getRowCount();
|
221 |
if (idField == -1) { |
222 |
NotificationManager.addWarning( |
223 |
PluginServices.getText(this, "unrecognized_field_name")+" " + fieldName, null); |
224 |
|
225 |
return;
|
226 |
} |
227 |
|
228 |
symbolTable.removeAllItems(); |
229 |
|
230 |
int numSymbols = 0; |
231 |
ISymbol theSymbol = null;
|
232 |
|
233 |
//auxLegend=(VectorialUniqueValueLegend)m_lyr.getLegend();
|
234 |
auxLegend = LegendFactory.createVectorialUniqueValueLegend(layer.getShapeType()); |
235 |
|
236 |
Value clave; |
237 |
|
238 |
ColorItem[] colorScheme = cmbColorScheme.getSelectedColors();
|
239 |
|
240 |
Color[] colors = new Color[colorScheme.length]; |
241 |
for (int i = 0; i < colorScheme.length; i++) { |
242 |
colors[i] = colorScheme[i].getColor(); |
243 |
} |
244 |
auxLegend.setColorScheme(colors); |
245 |
|
246 |
|
247 |
Random rand = new Random(System.currentTimeMillis()); |
248 |
|
249 |
for (int j = 0; j < elRs.getRowCount(); j++) { |
250 |
clave = elRs.getFieldValue(j, idField); |
251 |
|
252 |
if (clave instanceof NullValue) { |
253 |
continue;
|
254 |
} |
255 |
|
256 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo.
|
257 |
if (auxLegend.getSymbolByValue(clave) == null) { |
258 |
//si no esta creado el simbolo se crea
|
259 |
// jaume (moved to ISymbol); theSymbol = new FSymbol(layer.getShapeType());
|
260 |
theSymbol = SymbologyFactory. |
261 |
createDefaultSymbolByShapeType(layer.getShapeType(), |
262 |
colorScheme[rand.nextInt(colorScheme.length)].getColor()); |
263 |
theSymbol.setDescription(clave.toString()); |
264 |
auxLegend.addSymbol(clave, theSymbol); |
265 |
|
266 |
numSymbols++; |
267 |
|
268 |
if (numSymbols == 100) { |
269 |
int resp = JOptionPane.showConfirmDialog(this, |
270 |
PluginServices.getText(this,
|
271 |
"mas_de_100_simbolos"),
|
272 |
PluginServices.getText(this, "quiere_continuar"), |
273 |
JOptionPane.YES_NO_OPTION,
|
274 |
JOptionPane.WARNING_MESSAGE);
|
275 |
|
276 |
if ((resp == JOptionPane.NO_OPTION) || |
277 |
(resp == JOptionPane.DEFAULT_OPTION)) {
|
278 |
return;
|
279 |
} |
280 |
} |
281 |
} |
282 |
} // for
|
283 |
|
284 |
symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
285 |
auxLegend.getValues(),auxLegend.getDescriptions()); |
286 |
elRs.stop(); |
287 |
} catch (ReadDriverException e) {
|
288 |
NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
289 |
} |
290 |
|
291 |
btnRemoveAll.setEnabled(true);
|
292 |
btnRemove.setEnabled(true);
|
293 |
|
294 |
//m_bCacheDirty = false;
|
295 |
} |
296 |
|
297 |
/**
|
298 |
* A partir de los registros de la tabla, regenera el FRenderer. (No solo
|
299 |
* el symbolList, si no tambi�n el arrayKeys y el defaultRenderer
|
300 |
*/
|
301 |
private void fillSymbolListFromTable() { |
302 |
Value clave; |
303 |
ISymbol theSymbol; |
304 |
|
305 |
// Borramos las anteriores listas:
|
306 |
|
307 |
String fieldName = (String) cmbFields.getSelectedItem(); |
308 |
auxLegend.setClassifyingFieldNames(new String[] {fieldName} ); |
309 |
|
310 |
FLyrVect m = (FLyrVect) layer; |
311 |
try {
|
312 |
int fieldType = m.getSource().getRecordset().getFieldType((int)cmbFields.getSelectedIndex()); |
313 |
auxLegend.setClassifyingFieldTypes(new int[] {fieldType}); |
314 |
} catch (ReadDriverException e) {
|
315 |
NotificationManager.addError(PluginServices.getText(this, "could_not_setup_legend"), e); |
316 |
} |
317 |
|
318 |
|
319 |
auxLegend.clear(); |
320 |
|
321 |
for (int row = 0; row < symbolTable.getRowCount(); row++) { |
322 |
clave = (Value) symbolTable.getFieldValue(row, 1);
|
323 |
theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
|
324 |
theSymbol.setDescription((String) symbolTable.getFieldValue(row, 2)); |
325 |
auxLegend.addSymbol(clave, theSymbol); |
326 |
} |
327 |
|
328 |
if(chbUseDefault.isSelected()){
|
329 |
if(defaultSymbolPrev.getSymbol() != null){ |
330 |
String description = PluginServices.getText(this,"default"); |
331 |
defaultSymbolPrev.getSymbol().setDescription(description); |
332 |
auxLegend.addSymbol(new NullUniqueValue(), defaultSymbolPrev.getSymbol());
|
333 |
} |
334 |
} |
335 |
|
336 |
} |
337 |
|
338 |
/**
|
339 |
* DOCUMENT ME!
|
340 |
*/
|
341 |
private void fillFieldNames() { |
342 |
DataSource rs;
|
343 |
|
344 |
try {
|
345 |
rs = ((AlphanumericData) layer).getRecordset(); |
346 |
logger.debug("rs.start()");
|
347 |
rs.start(); |
348 |
|
349 |
String[] nomFields = new String[rs.getFieldCount()]; |
350 |
|
351 |
for (int i = 0; i < rs.getFieldCount(); i++) { |
352 |
nomFields[i] = rs.getFieldName(i).trim(); |
353 |
} |
354 |
|
355 |
rs.stop(); |
356 |
|
357 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields); |
358 |
cmbFields.setModel(cM); |
359 |
|
360 |
// fieldsListValor.setSelectedIndex(0);
|
361 |
} catch (ReadDriverException e) {
|
362 |
NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
363 |
} |
364 |
} |
365 |
|
366 |
public void setData(FLayer layer, ILegend legend) { |
367 |
this.layer = (ClassifiableVectorial) layer;
|
368 |
int shapeType = 0; |
369 |
try {
|
370 |
shapeType = this.layer.getShapeType();
|
371 |
} catch (ReadDriverException e) {
|
372 |
NotificationManager.addError(PluginServices.getText(this, "accessing_to_the_layer"), e); |
373 |
} |
374 |
|
375 |
getDefaultSymbolPrev(shapeType); |
376 |
|
377 |
|
378 |
if (symbolTable != null) |
379 |
pnlCenter.remove(symbolTable); |
380 |
//if(pnlMovBut != null)
|
381 |
// pnlCenter.remove(pnlMovBut);
|
382 |
|
383 |
symbolTable = new SymbolTable(this, SymbolTable.VALUES_TYPE, shapeType); |
384 |
pnlCenter.add(symbolTable, BorderLayout.CENTER);
|
385 |
//pnlCenter.add(getPnlMovBut(),BorderLayout.EAST);
|
386 |
|
387 |
fillFieldNames(); |
388 |
|
389 |
symbolTable.removeAllItems(); |
390 |
|
391 |
if (VectorialUniqueValueLegend.class.equals(legend.getClass())) {
|
392 |
try {
|
393 |
auxLegend = (VectorialUniqueValueLegend) legend.cloneLegend(); |
394 |
} catch (XMLException e) {
|
395 |
// TODO Auto-generated catch block
|
396 |
e.printStackTrace(); |
397 |
} |
398 |
getChbUseDefault().setSelected(auxLegend.isUseDefaultSymbol()); |
399 |
cmbFields.getModel().setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
|
400 |
setColorScheme(); |
401 |
symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
402 |
auxLegend.getValues(),auxLegend.getDescriptions()); |
403 |
zSort = auxLegend.getZSort(); |
404 |
chbUseDefault.setSelected(auxLegend.isUseDefaultSymbol()); |
405 |
} else {
|
406 |
auxLegend = new VectorialUniqueValueLegend(shapeType);
|
407 |
} |
408 |
defaultSymbolPrev.setSymbol(auxLegend.getDefaultSymbol()); |
409 |
} |
410 |
|
411 |
|
412 |
// private JPanel getPnlMovBut() {
|
413 |
// if(pnlMovBut == null){
|
414 |
// pnlMovBut = new JPanel();
|
415 |
// pnlMovBut.setLayout(new BoxLayout(pnlMovBut, BoxLayout.Y_AXIS));
|
416 |
// pnlMovBut.add(new JBlank(1, 70));
|
417 |
// pnlMovBut.add(moveUp = new JButton(PluginServices.getIconTheme().get("up-arrow")));
|
418 |
// moveUp.setSize(new Dimension(15,15));
|
419 |
// pnlMovBut.add(new JBlank(1,10));
|
420 |
// pnlMovBut.add(moveDown = new JButton(PluginServices.getIconTheme().get("down-arrow")));
|
421 |
// pnlMovBut.add(new JBlank(1, 70));
|
422 |
// moveDown.setActionCommand("MOVE-DOWN");
|
423 |
// moveUp.setActionCommand("MOVE-UP");
|
424 |
// moveDown.addActionListener(this);
|
425 |
// moveUp.addActionListener(this);
|
426 |
// }
|
427 |
// return pnlMovBut;
|
428 |
// }
|
429 |
|
430 |
private void setColorScheme(){ |
431 |
|
432 |
if(auxLegend.getColorScheme() != null) { |
433 |
ColorItem[] colors = new ColorItem[auxLegend.getColorScheme().length]; |
434 |
for (int i = 0; i < auxLegend.getColorScheme().length; i++) { |
435 |
colors[i] = new ColorItem();
|
436 |
colors[i].setColor(auxLegend.getColorScheme()[i]); |
437 |
} |
438 |
cmbColorScheme.setSelectedColors(colors); |
439 |
} |
440 |
} |
441 |
|
442 |
|
443 |
|
444 |
private void getDefaultSymbolPrev(int shapeType) { |
445 |
if(defaultSymbolPrev == null){ |
446 |
defaultSymbolPrev = new JSymbolPreviewButton(shapeType);
|
447 |
defaultSymbolPrev.setPreferredSize(new Dimension(110,20)); |
448 |
defaultSymbolPrev.addActionListener(this);
|
449 |
defaultSymbolPanel.add(defaultSymbolPrev,null);
|
450 |
} |
451 |
} |
452 |
|
453 |
/* (non-Javadoc)
|
454 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend()
|
455 |
*/
|
456 |
public ILegend getLegend() {
|
457 |
fillSymbolListFromTable(); |
458 |
|
459 |
if (auxLegend != null) { |
460 |
// your settings that are not the set of symbols must be located here
|
461 |
auxLegend.setClassifyingFieldNames( |
462 |
new String[] {(String) cmbFields.getSelectedItem()}); |
463 |
|
464 |
if(defaultSymbolPrev.getSymbol() != null) |
465 |
auxLegend.setDefaultSymbol(defaultSymbolPrev.getSymbol()); |
466 |
|
467 |
auxLegend.useDefaultSymbol(chbUseDefault.isSelected()); |
468 |
|
469 |
theLegend = auxLegend; |
470 |
} |
471 |
theLegend.setZSort(zSort); |
472 |
|
473 |
return theLegend;
|
474 |
} |
475 |
|
476 |
private JCheckBox getChbUseDefault() { |
477 |
if (chbUseDefault == null) { |
478 |
chbUseDefault = new JCheckBox(); |
479 |
chbUseDefault.setSelected(false);
|
480 |
chbUseDefault.addActionListener(new java.awt.event.ActionListener() {
|
481 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
482 |
if (chbUseDefault.isSelected()) {
|
483 |
auxLegend.useDefaultSymbol(true);
|
484 |
} else {
|
485 |
auxLegend.useDefaultSymbol(false);
|
486 |
} |
487 |
} |
488 |
}); |
489 |
chbUseDefault.setText(PluginServices.getText(this, "resto_valores")+ ": "); |
490 |
} |
491 |
|
492 |
return chbUseDefault;
|
493 |
} |
494 |
|
495 |
public void actionPerformed(ActionEvent e) { |
496 |
|
497 |
|
498 |
// if(e.getActionCommand() == "MOVE-UP"){
|
499 |
// int[] indices = symbolTable.getTable().getSelectedRows();
|
500 |
// if (indices.length>0) {
|
501 |
// int classIndex = indices[0];
|
502 |
// int targetPos = Math.max(0, classIndex-1);
|
503 |
// symbolTable.swapClass(classIndex, targetPos,indices.length);
|
504 |
// }
|
505 |
// }
|
506 |
//
|
507 |
// if(e.getActionCommand() == "MOVE-DOWN"){
|
508 |
// int[] indices = symbolTable.getTable().getSelectedRows();
|
509 |
// if (indices.length>0) {
|
510 |
// int classIndex = indices[indices.length-1];
|
511 |
// int targetPos = Math.min(symbolTable.getRowCount()-1, classIndex+1);
|
512 |
// symbolTable.swapClass(classIndex, targetPos,indices.length);
|
513 |
// }
|
514 |
// }
|
515 |
|
516 |
//modificar el combobox de valor
|
517 |
if (e.getActionCommand() == "FIELD_SELECTED") { |
518 |
JComboBox cb = (JComboBox) e.getSource(); |
519 |
String fieldName = (String) cb.getSelectedItem(); |
520 |
symbolTable.removeAllItems(); |
521 |
|
522 |
} |
523 |
|
524 |
// add all elements by value
|
525 |
if (e.getActionCommand() == "ADD_ALL_VALUES") { |
526 |
fillTableValues(); |
527 |
} |
528 |
|
529 |
// add only one value
|
530 |
if (e.getActionCommand() == "ADD_VALUE") { |
531 |
try {
|
532 |
symbolTable.addTableRecord(SymbologyFactory. |
533 |
createDefaultSymbolByShapeType(layer.getShapeType()), |
534 |
ValueFactory.createValue(0.0),"0 - 0"); |
535 |
} catch (ReadDriverException ex) {
|
536 |
NotificationManager.addError(PluginServices.getText(this, "getting_shape_type"), ex); |
537 |
} |
538 |
} |
539 |
|
540 |
//Vacia la tabla
|
541 |
if (e.getActionCommand() == "REMOVE_ALL") { |
542 |
symbolTable.removeAllItems(); |
543 |
auxLegend.setZSort(null);
|
544 |
zSort = null;
|
545 |
} |
546 |
|
547 |
//Quitar solo el elemento seleccionado
|
548 |
if (e.getActionCommand() == "REMOVE") { |
549 |
symbolTable.removeSelectedRows(); |
550 |
} |
551 |
|
552 |
if (e.getActionCommand() == "OPEN_SYMBOL_LEVEL_EDITOR") { |
553 |
|
554 |
if (auxLegend != null) { |
555 |
ZSort myZSort = ((AbstractClassifiedVectorLegend) getLegend()).getZSort(); |
556 |
if (myZSort == null && theLegend != null) { |
557 |
myZSort = new ZSort(theLegend);
|
558 |
} |
559 |
SymbolLevelsWindow sl = new SymbolLevelsWindow(myZSort);
|
560 |
PluginServices.getMDIManager().addWindow(sl); |
561 |
zSort = sl.getZSort(); |
562 |
auxLegend.setZSort(zSort); |
563 |
} |
564 |
|
565 |
} |
566 |
|
567 |
} |
568 |
|
569 |
public String getDescription() { |
570 |
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") + "."; |
571 |
} |
572 |
|
573 |
public ImageIcon getIcon() { |
574 |
return new ImageIcon(this.getClass().getClassLoader(). |
575 |
getResource("images/ValoresUnicos.png"));
|
576 |
} |
577 |
|
578 |
public Class getParentClass() { |
579 |
return Categories.class;
|
580 |
} |
581 |
|
582 |
public String getTitle() { |
583 |
return PluginServices.getText(this,"Valores_unicos"); |
584 |
} |
585 |
|
586 |
public JPanel getPanel() { |
587 |
return this; |
588 |
} |
589 |
|
590 |
public Class getLegendClass() { |
591 |
return VectorialUniqueValueLegend.class;
|
592 |
} |
593 |
|
594 |
|
595 |
public boolean isSuitableFor(FLayer layer) { |
596 |
return (layer instanceof FLyrVect); |
597 |
} |
598 |
} |