gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.commons / src / main / java / org / gvsig / gvsig3d / app / gui / panels / ExtrusionLegendPanel.java @ 385
History | View | Annotate | Download (21.3 KB)
1 |
/* gvSIG 3D extension for gvSIG
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2012 Prodevelop.
|
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 |
* Prodevelop, S.L.
|
22 |
* Pza. Don Juan de Villarrasa, 14 - 5
|
23 |
* 46001 Valencia
|
24 |
* Spain
|
25 |
*
|
26 |
* +34 963 510 612
|
27 |
* +34 963 510 968
|
28 |
* prode@prodevelop.es
|
29 |
* http://www.prodevelop.es
|
30 |
*/
|
31 |
/*
|
32 |
* AUTHORS:
|
33 |
* 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
|
34 |
* Universitat Politecnica de Valencia (UPV)
|
35 |
* http://www.ai2.upv.es
|
36 |
*/
|
37 |
|
38 |
|
39 |
package org.gvsig.gvsig3d.app.gui.panels; |
40 |
|
41 |
import java.awt.BorderLayout; |
42 |
import java.awt.Color; |
43 |
import java.awt.Component; |
44 |
import java.awt.Dimension; |
45 |
import java.awt.FlowLayout; |
46 |
import java.awt.event.ActionEvent; |
47 |
import java.awt.event.ActionListener; |
48 |
import java.awt.event.ItemEvent; |
49 |
import java.awt.event.ItemListener; |
50 |
import java.awt.event.KeyEvent; |
51 |
import java.awt.event.KeyListener; |
52 |
import java.util.ArrayList; |
53 |
import java.util.Iterator; |
54 |
import java.util.Random; |
55 |
|
56 |
import javax.swing.DefaultComboBoxModel; |
57 |
import javax.swing.ImageIcon; |
58 |
import javax.swing.JButton; |
59 |
import javax.swing.JCheckBox; |
60 |
import javax.swing.JComboBox; |
61 |
import javax.swing.JLabel; |
62 |
import javax.swing.JOptionPane; |
63 |
import javax.swing.JPanel; |
64 |
import javax.swing.JTextField; |
65 |
|
66 |
import org.gvsig.andami.PluginServices; |
67 |
import org.gvsig.andami.messages.NotificationManager; |
68 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
69 |
import org.gvsig.app.ApplicationLocator; |
70 |
import org.gvsig.app.ApplicationManager; |
71 |
import org.gvsig.app.gui.styling.JComboBoxColorScheme; |
72 |
import org.gvsig.app.gui.styling.SymbolLevelsWindow; |
73 |
import org.gvsig.app.project.documents.view.ViewDocument; |
74 |
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel; |
75 |
import org.gvsig.app.project.documents.view.legend.gui.JSymbolPreviewButton; |
76 |
import org.gvsig.app.project.documents.view.legend.gui.SymbolTable; |
77 |
import org.gvsig.fmap.dal.DataTypes; |
78 |
import org.gvsig.fmap.dal.exception.DataException; |
79 |
import org.gvsig.fmap.dal.exception.ReadException; |
80 |
import org.gvsig.fmap.dal.feature.Feature; |
81 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
82 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
83 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
84 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
85 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
86 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
87 |
import org.gvsig.fmap.mapcontext.layers.operations.ClassifiableVectorial; |
88 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
89 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
90 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
91 |
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort; |
92 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener; |
93 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
94 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
95 |
import org.gvsig.gvsig3d.app.extension.DefaultView3DPanel; |
96 |
import org.gvsig.gvsig3d.app.extrusion.SymbolTableExtrusion; |
97 |
import org.gvsig.gvsig3d.impl.legend3d.ExtrusionLegend; |
98 |
import org.gvsig.gvsig3d.impl.symbology3d.extrusion.impl.BaseExtrusionSymbol; |
99 |
import org.gvsig.gvsig3d.impl.symbology3d.extrusion.impl.ExtrusionPolygonSymbol; |
100 |
import org.gvsig.gvsig3d.map3d.Layer3DProps; |
101 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
102 |
import org.gvsig.osgvp.terrain.Terrain; |
103 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractClassifiedVectorLegend; |
104 |
import org.gvsig.tools.dispose.DisposableIterator; |
105 |
|
106 |
/**
|
107 |
* @author Jesus Zarzoso- jzarzoso@ai2.upv.es
|
108 |
* @version $Id$
|
109 |
*
|
110 |
*/
|
111 |
public class ExtrusionLegendPanel extends JPanel implements ILegendPanel, |
112 |
ItemListener, ActionListener, KeyListener { |
113 |
/**
|
114 |
*
|
115 |
*/
|
116 |
private static final long serialVersionUID = 6470946030927461473L; |
117 |
|
118 |
private ExtrusionLegend theLegend;
|
119 |
private ClassifiableVectorial layer;
|
120 |
private SymbolTableExtrusion symbolTable;
|
121 |
private JComboBox cmbFields; |
122 |
private JButton btnRemoveAll; |
123 |
private JButton btnRemove; |
124 |
private JCheckBox chbUseDefault = null; |
125 |
private ExtrusionLegend auxLegend;
|
126 |
private JPanel pnlCenter; |
127 |
private ZSort zSort;
|
128 |
private JButton btnOpenSymbolLevelsEditor; |
129 |
private JTextField jtvariable; |
130 |
private JComboBoxColorScheme cmbColorScheme;
|
131 |
private double extrusionValue = 1.0; |
132 |
private JTextField jtfija; |
133 |
private JCheckBox fixedOption; |
134 |
private double extrusionFixedValue = 1; |
135 |
private JSymbolPreviewButton defaultSymbolPrev;
|
136 |
private GridBagLayoutPanel defaultSymbolPanel = new GridBagLayoutPanel(); |
137 |
|
138 |
private ApplicationManager application = ApplicationLocator.getManager();
|
139 |
private MapContextManager mapContextManager = MapContextLocator
|
140 |
.getMapContextManager(); |
141 |
|
142 |
private int coordType; |
143 |
|
144 |
// private Value aux;
|
145 |
|
146 |
/**
|
147 |
*
|
148 |
*/
|
149 |
public ExtrusionLegendPanel() {
|
150 |
super();
|
151 |
initialize(); |
152 |
} |
153 |
|
154 |
/**
|
155 |
* DOCUMENT ME!
|
156 |
*/
|
157 |
protected void initialize() { |
158 |
|
159 |
JPanel pnlButtons = new JPanel(); |
160 |
|
161 |
JButton btnAddAll = new JButton(PluginServices.getText(this, |
162 |
"Anadir_todos"));
|
163 |
btnAddAll.setActionCommand("ADD_ALL_VALUES");
|
164 |
btnAddAll.addActionListener(this);
|
165 |
pnlButtons.add(btnAddAll); |
166 |
|
167 |
JButton btnAdd = new JButton(PluginServices.getText(this, "Anadir")); |
168 |
btnAdd.setActionCommand("ADD_VALUE");
|
169 |
btnAdd.addActionListener(this);
|
170 |
pnlButtons.add(btnAdd); |
171 |
|
172 |
btnRemoveAll = new JButton(PluginServices.getText(this, "Quitar_todos")); |
173 |
btnRemoveAll.setActionCommand("REMOVE_ALL");
|
174 |
btnRemoveAll.addActionListener(this);
|
175 |
pnlButtons.add(btnRemoveAll); |
176 |
|
177 |
btnRemove = new JButton(PluginServices.getText(this, "Quitar")); |
178 |
btnRemove.setActionCommand("REMOVE");
|
179 |
btnRemove.addActionListener(this);
|
180 |
pnlButtons.add(btnRemove); |
181 |
|
182 |
pnlCenter = new JPanel(); |
183 |
pnlCenter.setLayout(new BorderLayout()); |
184 |
|
185 |
cmbFields = new JComboBox(); |
186 |
cmbFields.setActionCommand("FIELD_SELECTED");
|
187 |
cmbFields.addActionListener(this);
|
188 |
cmbFields.setVisible(true);
|
189 |
|
190 |
JPanel pnlNorth = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0)); |
191 |
JPanel pAux1 = new JPanel(); |
192 |
|
193 |
JLabel lblFieldClassification = new JLabel(PluginServices.getText(this, |
194 |
"Campo_de_clasificacion"));
|
195 |
pAux1.add(lblFieldClassification); |
196 |
pAux1.add(cmbFields); |
197 |
pAux1.add(getChbUseDefault(), null);
|
198 |
pnlNorth.add(pAux1); |
199 |
|
200 |
pAux1 = new JPanel(); |
201 |
pAux1.add(new JLabel(PluginServices.getText(this, "Nivel_de_extrusion") |
202 |
+ ":"));
|
203 |
jtvariable = new JTextField(PluginServices.getText(this, "" |
204 |
+ this.extrusionValue), 3); |
205 |
jtvariable.setColumns(3);
|
206 |
jtvariable.setHorizontalAlignment(JTextField.RIGHT);
|
207 |
jtvariable.setToolTipText(PluginServices.getText(this, "Valor_inicial") |
208 |
+ " * " + PluginServices.getText(this, "Nivel_de_extrusion")); |
209 |
jtvariable.addKeyListener(this);
|
210 |
pAux1.add(jtvariable); |
211 |
|
212 |
pnlNorth.add(pAux1); |
213 |
|
214 |
pAux1 = new JPanel(); |
215 |
fixedOption = new JCheckBox(PluginServices.getText(this, "Altura_fija") |
216 |
+ ":", false); |
217 |
fixedOption.setHorizontalAlignment(JTextField.RIGHT);
|
218 |
fixedOption.setEnabled(true);
|
219 |
fixedOption.setSelected(false);
|
220 |
pAux1.add(fixedOption); |
221 |
|
222 |
jtfija = new JTextField(PluginServices.getText(this, "1"), 3); |
223 |
jtfija.setColumns(10);
|
224 |
jtfija.setHorizontalAlignment(JTextField.RIGHT);
|
225 |
jtfija.addKeyListener(this);
|
226 |
jtfija.setToolTipText(PluginServices.getText(this, "Valor_inicial") |
227 |
+ " = " + PluginServices.getText(this, "Altura_fija")); |
228 |
jtfija.setEnabled(false);
|
229 |
pAux1.add(jtfija); |
230 |
|
231 |
pnlNorth.add(pAux1); |
232 |
|
233 |
pAux1 = new JPanel(); |
234 |
pAux1.add(new JLabel(PluginServices.getText(this, "color_scheme") + ":")); |
235 |
cmbColorScheme = new JComboBoxColorScheme(false); |
236 |
|
237 |
fixedOption.addItemListener(this);
|
238 |
this.setLayout(new BorderLayout()); |
239 |
this.add(pnlNorth, BorderLayout.NORTH); |
240 |
this.add(pnlCenter, BorderLayout.CENTER); |
241 |
this.add(pnlButtons, BorderLayout.SOUTH); |
242 |
|
243 |
} |
244 |
|
245 |
private void fillTableValues() { |
246 |
|
247 |
FeatureStore elRs; |
248 |
|
249 |
try {
|
250 |
elRs = ((FLyrVect) layer).getFeatureStore(); |
251 |
|
252 |
String fieldName = (String) cmbFields.getSelectedItem(); |
253 |
if (fieldName == null) { |
254 |
JOptionPane.showMessageDialog((Component) PluginServices |
255 |
.getMainFrame(), PluginServices.getText(this,
|
256 |
"no_hay_campo_seleccionado"));
|
257 |
return;
|
258 |
} |
259 |
|
260 |
theLegend.setClassifyingFieldNames(new String[] { fieldName }); |
261 |
symbolTable.removeAllItems(); |
262 |
|
263 |
int numSymbols = 0; |
264 |
ISymbol theSymbol = null;
|
265 |
|
266 |
// auxLegend = (ExtrusionLegend) MapContextLocator
|
267 |
// .getMapContextManager().createLegend(
|
268 |
// IVectorialUniqueValueLegend.LEGEND_NAME);
|
269 |
|
270 |
auxLegend = new ExtrusionLegend(layer.getShapeType());
|
271 |
coordType = Terrain.CoordinateSystemType.PROJECTED; |
272 |
IWindow view = PluginServices.getMDIManager().getActiveWindow(); |
273 |
if (view instanceof DefaultView3DPanel) { |
274 |
|
275 |
DefaultView3DPanel vista3D = (DefaultView3DPanel) view; |
276 |
ViewDocument model = vista3D.getModel(); |
277 |
MapContext3D mapa = (MapContext3D) model.getMapContext(); |
278 |
coordType = mapa.getTerrain().getCoordinateSystemType(); |
279 |
|
280 |
} |
281 |
auxLegend.setExtrusionFactor(extrusionValue); |
282 |
// auxLegend.setDomain(application.getActiveDocument().getTypeName());
|
283 |
auxLegend.setShapeType(layer.getShapeType()); |
284 |
auxLegend.setCoordinateSystemType(coordType); |
285 |
|
286 |
Object clave = null; |
287 |
|
288 |
if (chbUseDefault.isSelected()) {
|
289 |
auxLegend.getDefaultSymbol().setDescription("Default");
|
290 |
auxLegend.addSymbol(null, auxLegend.getDefaultSymbol());
|
291 |
} |
292 |
|
293 |
Color[] colorScheme = cmbColorScheme.getSelectedColors(); |
294 |
|
295 |
Color[] colors = new Color[colorScheme.length]; |
296 |
for (int i = 0; i < colorScheme.length; i++) { |
297 |
colors[i] = colorScheme[i]; |
298 |
} |
299 |
auxLegend.setColorScheme(colors); |
300 |
|
301 |
Random rand = new Random(System.currentTimeMillis()); |
302 |
|
303 |
FeatureSet set = null;
|
304 |
DisposableIterator iterator = null;
|
305 |
|
306 |
try {
|
307 |
set = elRs.getFeatureSet(); |
308 |
|
309 |
long six = set.getSize();
|
310 |
|
311 |
int count = 0; |
312 |
Double extrudedVal = 0.0; |
313 |
|
314 |
iterator = set.fastIterator(); |
315 |
int contador = 0; |
316 |
while (iterator.hasNext()) {
|
317 |
Feature feature = (Feature) iterator.next(); |
318 |
clave = feature.get(fieldName); |
319 |
|
320 |
if (clave == null) { |
321 |
continue;
|
322 |
} |
323 |
|
324 |
// //Comprobar que no esta repetido y no hace falta
|
325 |
// introducir en el hashtable el campo junto con el simbolo.
|
326 |
if (auxLegend.getSymbolByValue(clave) == null) { |
327 |
|
328 |
if (count == 100) { |
329 |
int resp = JOptionPane.showConfirmDialog(this, |
330 |
PluginServices.getText(this,
|
331 |
"mas_de_100_simbolos"),
|
332 |
PluginServices.getText(this,
|
333 |
"quiere_continuar"),
|
334 |
JOptionPane.YES_NO_OPTION,
|
335 |
JOptionPane.WARNING_MESSAGE);
|
336 |
|
337 |
if ((resp == JOptionPane.NO_OPTION) |
338 |
|| (resp == JOptionPane.DEFAULT_OPTION)) {
|
339 |
break;
|
340 |
} |
341 |
} |
342 |
|
343 |
// si no esta creado el simbolo se crea
|
344 |
// theSymbol = mapContextManager.getSymbolManager()
|
345 |
// .createSymbol(
|
346 |
// layer.getShapeType(),
|
347 |
// colorScheme[rand
|
348 |
// .nextInt(colorScheme.length)],
|
349 |
// application.getActiveDocument()
|
350 |
// .getTypeName());
|
351 |
|
352 |
extrudedVal = ((Number) clave).doubleValue()
|
353 |
* extrusionValue; |
354 |
|
355 |
theSymbol.setDescription(extrudedVal.toString()); |
356 |
|
357 |
auxLegend.addSymbol(clave, theSymbol); |
358 |
count++; |
359 |
} |
360 |
|
361 |
} // for
|
362 |
} finally {
|
363 |
if (iterator != null) { |
364 |
iterator.dispose(); |
365 |
} |
366 |
if (set != null) { |
367 |
set.dispose(); |
368 |
} |
369 |
} |
370 |
|
371 |
Object[] values = auxLegend.getValues(); |
372 |
String[] descriptions = new String[values.length]; |
373 |
ISymbol[] symbols = new ISymbol[values.length]; |
374 |
|
375 |
for (int i = 0; i < values.length; i++) { |
376 |
Object value = values[i];
|
377 |
symbols[i] = auxLegend.getSymbolByValue(value); |
378 |
descriptions[i] = symbols[i].getDescription(); |
379 |
} |
380 |
|
381 |
symbolTable.fillTableFromSymbolList(symbols, values, descriptions); |
382 |
|
383 |
} catch (DataException e) {
|
384 |
NotificationManager.addError( |
385 |
PluginServices.getText(this, "recovering_recordset"), e); |
386 |
} |
387 |
|
388 |
btnRemoveAll.setEnabled(true);
|
389 |
btnRemove.setEnabled(true);
|
390 |
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* A partir de los registros de la tabla, regenera el FRenderer. (No solo el
|
395 |
* symbolList, si no tambien el arrayKeys y el defaultRenderer
|
396 |
*/
|
397 |
private void fillSymbolListFromTable() { |
398 |
Object clave;
|
399 |
ISymbol theSymbol; |
400 |
|
401 |
// Borramos las anteriores listas:
|
402 |
|
403 |
boolean bRestoValores = false; // PONERLO EN UN CHECKBOX |
404 |
int hasta;
|
405 |
String fieldName = (String) cmbFields.getSelectedItem(); |
406 |
|
407 |
theLegend.clear(); |
408 |
|
409 |
theLegend.setClassifyingFieldNames(new String[] { fieldName }); |
410 |
|
411 |
FLyrVect m = (FLyrVect) layer; |
412 |
try {
|
413 |
int fieldType = m.getFeatureStore().getDefaultFeatureType()
|
414 |
.getAttributeDescriptor(cmbFields.getSelectedIndex()) |
415 |
.getType(); |
416 |
theLegend.setClassifyingFieldTypes(new int[] { fieldType }); |
417 |
theLegend.setExtrusionFactor(auxLegend.getExtrusionFactor()); |
418 |
} catch (DataException e) {
|
419 |
NotificationManager.addError( |
420 |
PluginServices.getText(this, "could_not_setup_legend"), e); |
421 |
} |
422 |
|
423 |
if (bRestoValores) {
|
424 |
hasta = symbolTable.getRowCount() - 1;
|
425 |
} else {
|
426 |
hasta = symbolTable.getRowCount(); |
427 |
} |
428 |
|
429 |
for (int row = 0; row < symbolTable.getRowCount(); row++) { |
430 |
clave = symbolTable.getFieldValue(row, 1);
|
431 |
Double extrusion = null; |
432 |
try {
|
433 |
// extrusion = Double.parseDouble((String) (symbolTable
|
434 |
// .getFieldValue(row, 2)));
|
435 |
// theSymbol = new
|
436 |
// ExtrusionPolygonSymbol(extrusion.floatValue());
|
437 |
// theSymbol.setDescription(extrusion.toString());
|
438 |
// ((ExtrusionPolygonSymbol)
|
439 |
// theSymbol).setCoordinateSystemType(coordType);
|
440 |
theSymbol = auxLegend.getSymbolByValue(clave); |
441 |
|
442 |
} catch (Exception e) { |
443 |
theSymbol = new ExtrusionPolygonSymbol(1); |
444 |
theSymbol.setDescription("1");
|
445 |
} |
446 |
|
447 |
theLegend.addSymbol(clave, theSymbol); |
448 |
} |
449 |
|
450 |
if (bRestoValores) {
|
451 |
theSymbol = (ISymbol) symbolTable.getFieldValue(hasta, 0);
|
452 |
theLegend.setDefaultSymbol(theSymbol); |
453 |
} |
454 |
} |
455 |
|
456 |
/**
|
457 |
* DOCUMENT ME!
|
458 |
*/
|
459 |
protected void fillFieldNames() { |
460 |
FeatureStore fStore = null;
|
461 |
ArrayList<String> nomFields = null; |
462 |
|
463 |
try {
|
464 |
int type;
|
465 |
fStore = ((FLyrVect) layer).getFeatureStore(); |
466 |
|
467 |
nomFields = new ArrayList<String>(); |
468 |
|
469 |
Iterator<FeatureAttributeDescriptor> iterator = fStore
|
470 |
.getDefaultFeatureType().iterator(); |
471 |
|
472 |
while (iterator.hasNext()) {
|
473 |
|
474 |
FeatureAttributeDescriptor descriptor = iterator.next(); |
475 |
type = descriptor.getType(); |
476 |
|
477 |
if ((type == DataTypes.INT) || (type == DataTypes.DOUBLE)
|
478 |
|| (type == DataTypes.FLOAT) |
479 |
|| (type == DataTypes.LONG)) { |
480 |
nomFields.add(descriptor.getName()); |
481 |
} |
482 |
} |
483 |
|
484 |
} catch (DataException e) {
|
485 |
NotificationManager.addError( |
486 |
PluginServices.getText(this, "recovering_recordset"), e); |
487 |
} |
488 |
|
489 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields.toArray()); |
490 |
cmbFields.setModel(cM); |
491 |
|
492 |
symbolTable.removeAllItems(); |
493 |
} |
494 |
|
495 |
public void setData(FLayer layer, ILegend legend) { |
496 |
this.layer = (ClassifiableVectorial) layer;
|
497 |
int shapeType = 0; |
498 |
try {
|
499 |
shapeType = this.layer.getShapeType();
|
500 |
} catch (ReadException e) {
|
501 |
NotificationManager.addError( |
502 |
PluginServices.getText(this, "generating_intervals"), e); |
503 |
} |
504 |
|
505 |
if (symbolTable != null) |
506 |
pnlCenter.remove(symbolTable); |
507 |
symbolTable = new SymbolTableExtrusion(this, SymbolTable.VALUES_TYPE, |
508 |
shapeType); |
509 |
pnlCenter.add(symbolTable, BorderLayout.CENTER);
|
510 |
|
511 |
fillFieldNames(); |
512 |
|
513 |
symbolTable.removeAllItems(); |
514 |
|
515 |
if (legend instanceof ExtrusionLegend) { |
516 |
theLegend = (ExtrusionLegend) legend; |
517 |
getChbUseDefault().setSelected(theLegend.isUseDefaultSymbol()); |
518 |
cmbFields.getModel().setSelectedItem( |
519 |
theLegend.getClassifyingFieldNames()[0]);
|
520 |
symbolTable.fillTableFromSymbolList(theLegend.getSymbols(), |
521 |
theLegend.getValues(), theLegend.getDescriptions()); |
522 |
zSort = theLegend.getZSort(); |
523 |
jtvariable.setText(Double.toString(theLegend.getExtrusionFactor()));
|
524 |
} else {
|
525 |
theLegend = new ExtrusionLegend(shapeType);
|
526 |
} |
527 |
if (theLegend != null) { |
528 |
this.extrusionValue = ((ExtrusionLegend) this.theLegend) |
529 |
.getExtrusionFactor(); |
530 |
jtvariable.setText(Double.toString(this.extrusionValue)); |
531 |
} |
532 |
} |
533 |
|
534 |
/*
|
535 |
* (non-Javadoc)
|
536 |
*
|
537 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend()
|
538 |
*/
|
539 |
public ILegend getLegend() {
|
540 |
fillSymbolListFromTable(); |
541 |
// fillTableValues();
|
542 |
// if (auxLegend != null) {
|
543 |
// // your settings that are not the set of symbols must be located
|
544 |
// // here
|
545 |
// auxLegend
|
546 |
// .setClassifyingFieldNames(new String[] { (String) cmbFields
|
547 |
// .getSelectedItem() });
|
548 |
// auxLegend.setClassifyingFieldTypes(theLegend
|
549 |
// .getClassifyingFieldTypes());
|
550 |
//
|
551 |
// LegendContentsChangedListener[] l = theLegend.getListeners();
|
552 |
// for (int i = 0; i < l.length; i++) {
|
553 |
// auxLegend.addLegendListener(l[i]);
|
554 |
// }
|
555 |
// ;
|
556 |
//
|
557 |
// theLegend = auxLegend;
|
558 |
// }
|
559 |
// theLegend.setZSort(zSort);
|
560 |
|
561 |
return theLegend;
|
562 |
|
563 |
} |
564 |
|
565 |
private JCheckBox getChbUseDefault() { |
566 |
if (chbUseDefault == null) { |
567 |
chbUseDefault = new JCheckBox(); |
568 |
chbUseDefault.setSelected(true);
|
569 |
chbUseDefault |
570 |
.addActionListener(new java.awt.event.ActionListener() {
|
571 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
572 |
if (auxLegend == null) |
573 |
auxLegend = theLegend; |
574 |
if (chbUseDefault.isSelected()) {
|
575 |
addDefault(); |
576 |
} else {
|
577 |
delDefault(); |
578 |
} |
579 |
} |
580 |
}); |
581 |
chbUseDefault |
582 |
.setText(PluginServices.getText(this, "resto_valores")); |
583 |
} |
584 |
|
585 |
return chbUseDefault;
|
586 |
} |
587 |
|
588 |
/**
|
589 |
* A?ade el resto de valores.
|
590 |
*/
|
591 |
private void addDefault() { |
592 |
auxLegend.getDefaultSymbol().setDescription("Default");
|
593 |
auxLegend.addSymbol(null, auxLegend.getDefaultSymbol());
|
594 |
symbolTable.addTableRecord(auxLegend.getDefaultSymbol(), null,
|
595 |
auxLegend.getDefaultSymbol().getDescription()); |
596 |
symbolTable.repaint(); |
597 |
} |
598 |
|
599 |
/**
|
600 |
* Elimina el resto de valores que no estan representados por ningun otro
|
601 |
* simbolo..
|
602 |
*/
|
603 |
private void delDefault() { |
604 |
auxLegend.delSymbol(null);
|
605 |
symbolTable.removeRow(null);
|
606 |
symbolTable.repaint(); |
607 |
} |
608 |
|
609 |
public void actionPerformed(ActionEvent e) { |
610 |
|
611 |
// modificar el combobox de valor
|
612 |
if (e.getActionCommand() == "FIELD_SELECTED") { |
613 |
JComboBox cb = (JComboBox) e.getSource(); |
614 |
String fieldName = (String) cb.getSelectedItem(); |
615 |
symbolTable.removeAllItems(); |
616 |
|
617 |
} |
618 |
|
619 |
// add all elements by value
|
620 |
if (e.getActionCommand() == "ADD_ALL_VALUES") { |
621 |
fillTableValues(); |
622 |
} |
623 |
|
624 |
// add only one value
|
625 |
if (e.getActionCommand() == "ADD_VALUE") { |
626 |
try {
|
627 |
symbolTable.addTableRecord(mapContextManager.getSymbolManager() |
628 |
.createSymbol(layer.getShapeType()), 0.0, "0 - 0"); |
629 |
} catch (DataException ex) {
|
630 |
NotificationManager.addError( |
631 |
PluginServices.getText(this, "getting_shape_type"), ex); |
632 |
} |
633 |
} |
634 |
|
635 |
// Vacia la tabla
|
636 |
if (e.getActionCommand() == "REMOVE_ALL") { |
637 |
symbolTable.removeAllItems(); |
638 |
theLegend.setZSort(null);
|
639 |
zSort = null;
|
640 |
} |
641 |
|
642 |
// Quitar solo el elemento seleccionado
|
643 |
if (e.getActionCommand() == "REMOVE") { |
644 |
symbolTable.removeSelectedRows(); |
645 |
} |
646 |
|
647 |
if (e.getActionCommand() == "OPEN_SYMBOL_LEVEL_EDITOR") { |
648 |
|
649 |
if (theLegend != null) { |
650 |
ZSort myZSort = ((AbstractClassifiedVectorLegend) getLegend()) |
651 |
.getZSort(); |
652 |
if (myZSort == null) { |
653 |
myZSort = new ZSort(theLegend);
|
654 |
} |
655 |
SymbolLevelsWindow sl = new SymbolLevelsWindow(myZSort);
|
656 |
PluginServices.getMDIManager().addWindow(sl); |
657 |
zSort = sl.getZSort(); |
658 |
if (auxLegend != null) |
659 |
auxLegend.setZSort(zSort); |
660 |
} |
661 |
|
662 |
} |
663 |
} |
664 |
|
665 |
public String getDescription() { |
666 |
return PluginServices.getText(this, |
667 |
PluginServices.getText(this, "info_extrusion")); |
668 |
} |
669 |
|
670 |
public ImageIcon getIcon() { |
671 |
return null; |
672 |
} |
673 |
|
674 |
public Class getParentClass() { |
675 |
return null; |
676 |
} |
677 |
|
678 |
public String getTitle() { |
679 |
return ("<html><b>" + PluginServices.getText(this, "Extrusion") + "</b></html>"); |
680 |
} |
681 |
|
682 |
public JPanel getPanel() { |
683 |
return this; |
684 |
} |
685 |
|
686 |
public Class getLegendClass() { |
687 |
return ExtrusionLegend.class;
|
688 |
|
689 |
} |
690 |
|
691 |
public boolean isSuitableFor(FLayer layer) { |
692 |
|
693 |
try {
|
694 |
Layer3DProps props3D = ((MapContext3D) layer.getMapContext()) |
695 |
.getLayer3DProps(layer); |
696 |
int type = ((FLyrVect) layer).getShapeType();
|
697 |
return ((props3D != null) && (props3D.getType() == Layer3DProps.layer3DVector) && |
698 |
((type == 3) || (type==9))); |
699 |
} catch (ClassCastException e) { |
700 |
return false; |
701 |
|
702 |
} catch (ReadException e) {
|
703 |
return false; |
704 |
} |
705 |
} |
706 |
|
707 |
public void keyPressed(KeyEvent e) { |
708 |
// TODO Auto-generated method stub
|
709 |
|
710 |
} |
711 |
|
712 |
public void keyReleased(KeyEvent e) { |
713 |
|
714 |
try {
|
715 |
extrusionValue = new Double(this.jtvariable.getText()) |
716 |
.doubleValue(); |
717 |
extrusionFixedValue = new Double(this.jtfija.getText()) |
718 |
.doubleValue(); |
719 |
} catch (Exception e2) { |
720 |
// String s = " ";
|
721 |
// if(!this.jtvariable.getText().equals(s)) {
|
722 |
// JOptionPane.showMessageDialog(null, PluginServices.getText(this,
|
723 |
// "Introduce un dato numerico"),
|
724 |
// PluginServices.getText(this, "Dato incorrecto"),
|
725 |
// JOptionPane.WARNING_MESSAGE);
|
726 |
//
|
727 |
// jtvariable.setText(Double.toString(extrusionValue));
|
728 |
// jtfija.setText(Double.toString(extrusionFixedValue));
|
729 |
// }
|
730 |
} |
731 |
} |
732 |
|
733 |
public void keyTyped(KeyEvent e) { |
734 |
// TODO Auto-generated method stub
|
735 |
|
736 |
} |
737 |
|
738 |
public void itemStateChanged(ItemEvent e) { |
739 |
jtfija.setEnabled(fixedOption.isSelected()); |
740 |
jtvariable.setEnabled(!fixedOption.isSelected()); |
741 |
|
742 |
} |
743 |
|
744 |
} |