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