Revision 365 org.gvsig.legend.quantitybycategory.app.mainplugin/trunk/org.gvsig.legend.quantitybycategory.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/QuantityByCategoryPanel.java

View differences:

QuantityByCategoryPanel.java
61 61
 */
62 62
public class QuantityByCategoryPanel extends JPanel
63 63
implements ILegendPanel, ActionListener {
64
    
64

  
65 65
	private static final long serialVersionUID = 5098346573350040756L;
66 66
	private static final Logger logger =
67 67
	    LoggerFactory.getLogger(QuantityByCategoryPanel.class);
68
	
68

  
69 69
	private JPanel pnlNorth;
70 70
	private JPanel pnlSouth;
71 71
	private JPanel pnlButtons;
......
260 260

  
261 261
		symbolTable = new SymbolTable(
262 262
		    this, SymbolTable.INTERVALS_TYPE, Geometry.TYPES.GEOMETRY);
263
		
263

  
264 264
		pnlSouth.add(symbolTable,BorderLayout.CENTER);
265 265
		fillFieldNames();
266 266

  
......
272 272
			    this.oldLegend.getGraduatedSymbolsLegend()
273 273
			    .getClassifyingFieldNames()[0]);
274 274
			symbolTable.removeAllItems();
275
			
275

  
276 276
			this.fillTableSkipDefault(this.oldLegend);
277 277

  
278 278
		} else {
......
280 280
			String[] fnn = {
281 281
                (String) getCmbColorField().getSelectedItem(),
282 282
                (String) getCmbGraduatedField().getSelectedItem() };
283
			
283

  
284 284
			this.oldLegend.setClassifyingFieldNames(fnn);
285 285

  
286 286
            try {
......
296 296
            }
297 297
		}
298 298
	}
299
	
299

  
300 300
	private void setFieldTypesFromFieldNames(
301 301
	    FLyrVect vect,
302 302
	    QuantityByCategoryLegend leg,
303 303
	    String[] nn) throws DataException {
304
	    
304

  
305 305
        FeatureStore fsto = (FeatureStore) vect.getDataStore();
306 306
        FeatureType fty = fsto.getDefaultFeatureType();
307 307
        int[] fieldTypes  = new int[nn.length];
......
313 313
        }
314 314
        leg.setClassifyingFieldTypes(fieldTypes);
315 315
	}
316
	
317
	
318 316

  
317

  
318

  
319 319
	private void fillSymbolListFromTable() {
320
	    
320

  
321 321
		ISymbol theSymbol;
322 322
		IInterval theInterval = null;
323 323
		// Borramos las anteriores listas:
......
331 331
			    setFieldTypesFromFieldNames(vect, this.oldLegend, fNames);
332 332
			}
333 333
		} catch (DataException e) {
334
		    
334

  
335 335
            logger.info("Error while fillSymbolListFromTablel", e);
336 336
            ApplicationLocator.getManager().messageDialog(
337 337
                Messages.getText("could_not_setup_legend"),
......
410 410
			VectorialInterval legPanel = new VectorialInterval();
411 411
			legPanel.setData(layer, colorRamp);
412 412
			InnerWindow window = new InnerWindow(legPanel);
413
			
413

  
414 414
			ApplicationLocator.getManager().getUIManager().addWindow(window);
415
			
415

  
416 416
			cmbColorField.setSelectedItem(colorRamp.getClassifyingFieldNames()[0].toString());
417 417
			ILegend newLegend = window.getLegend();
418 418
			if (newLegend != null) {
......
430 430
			}
431 431
			symbolTable.removeAllItems();
432 432
			this.fillTableSkipDefault(this.oldLegend);
433
			
433

  
434 434
		} else if (c.equals(getBtnSymbol())) {
435
		    
435

  
436 436
			GraduatedSymbolsLegend graduatedSymbol =
437 437
			    this.oldLegend.getGraduatedSymbolsLegend();
438 438
			String fieldName = (String) getCmbGraduatedField().getSelectedItem();
439 439
			if (!fieldName.equals(graduatedSymbol.getClassifyingFieldNames()[0])) {
440 440
				// if classification field has changed, clear the legend
441 441
				graduatedSymbol.setClassifyingFieldNames(new String[] {fieldName});
442
				
442

  
443 443
		        ISymbol def = MapContextLocator.getSymbolManager().
444 444
		            createSymbol(Geometry.TYPES.POINT);
445 445
				graduatedSymbol.setDefaultSymbol(def);
446
				
446

  
447 447
				graduatedSymbol.setMinSymbolSize(1);
448 448
				graduatedSymbol.setMaxSymbolSize(14);
449 449
				graduatedSymbol.clear();
......
452 452
			GraduatedSymbolsPanel legPanel = new GraduatedSymbolsPanel(false);
453 453
			legPanel.setData(layer, graduatedSymbol);
454 454
			InnerWindow window = new InnerWindow(legPanel);
455
			
455

  
456 456
			ApplicationLocator.getManager().getUIManager().addWindow(window);
457
			
457

  
458 458
			cmbGraduatedSymbolField.setSelectedItem(graduatedSymbol.getClassifyingFieldNames()[0].toString());
459 459
			ILegend newLegend = window.getLegend();
460 460
			if(newLegend != null) {
461
			    
461

  
462 462
			    if (newLegend instanceof GraduatedSymbolsLegend) {
463 463
	                this.oldLegend.getGraduatedSymbolsLegend().clear();
464 464
	                this.oldLegend.setGraduateSymbolLegend(
......
476 476

  
477 477
		else if (c.equals(getCmbColorField())) {
478 478
			symbolTable.removeAllItems();
479
			
479

  
480 480
			this.fillTableSkipDefault(
481 481
			    this.oldLegend.getGraduatedSymbolsLegend().getSymbols(),
482 482
			    this.oldLegend.getGraduatedSymbolsLegend().getValues(),
......
485 485

  
486 486
		else if (c.equals(getCmbGraduatedField())) {
487 487
			symbolTable.removeAllItems();
488
			
488

  
489 489
			this.fillTableSkipDefault(
490 490
			    this.oldLegend.getColorRampLegend().getSymbols(),
491 491
			    this.oldLegend.getColorRampLegend().getValues(),
......
501 501
//		}
502 502
	}
503 503
	private class InnerWindow extends JPanel implements IWindow {
504
	    
504

  
505 505
		private ActionListener okAction = new ActionListener() {
506 506
			public void actionPerformed(ActionEvent e) {
507 507
				legend = panel.getLegend();
......
535 535
				JComponent c = (JComponent) panel;
536 536
				wi.setWidth(c.getWidth());
537 537
				wi.setHeight(c.getHeight());
538
				wi.setTitle(panel.getDescription());
538
				wi.setTitle(panel.getTitle());
539 539
			}
540 540
			return wi;
541 541
		}
......
557 557
		FLyrVect vect = null;
558 558

  
559 559
		try {
560
		   
560

  
561 561
            FeatureStore fsto = null;
562 562
            FeatureType fty = null;
563 563
            FeatureAttributeDescriptor[] atts = null;
......
597 597

  
598 598
		symbolTable.removeAllItems();
599 599
	}
600
	
601 600

  
601

  
602 602
	public boolean isSuitableFor(FLayer layer) {
603 603
		if (layer instanceof FLyrVect) {
604 604
			try {
605 605
				FLyrVect vect = (FLyrVect) layer;
606 606
				int shpt = vect.getGeometryType().getType();
607
				
607

  
608 608
				if (!QuantityByCategoryLegend.isPolygonal(shpt)) {
609 609
				    return false;
610 610
				}
......
628 628
		}
629 629
		return false;
630 630
	}
631
	
632 631

  
632

  
633 633
	// reemplazar esto por arriba
634 634
    private void fillTableSkipDefault(
635 635
        IClassifiedLegend leg) {
636
        
636

  
637 637
        Object[] src_expr = leg.getValues();
638 638
        ISymbol[] src_syms = leg.getSymbols();
639 639
        String[] src_descs = leg.getDescriptions();
640
        
640

  
641 641
        List syms = new ArrayList();
642 642
        List vals = new ArrayList();
643 643
        List descs = new ArrayList();
......
653 653
            (Object[]) vals.toArray(new Object[0]),
654 654
            (String[]) descs.toArray(new String[0]));
655 655
    }
656
    
656

  
657 657
    private void fillTableSkipDefault(
658 658
        ISymbol[] src_syms,
659 659
        Object[] src_expr,
660 660
        String[] src_descs) {
661
        
661

  
662 662
        List syms = new ArrayList();
663 663
        List vals = new ArrayList();
664 664
        List descs = new ArrayList();

Also available in: Unified diff