Revision 1822 branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameLegend.java

View differences:

FFrameLegend.java
47 47
import com.iver.cit.gvsig.fmap.FMap;
48 48
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
49 49
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
50
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
50 51
import com.iver.cit.gvsig.fmap.layers.FLayer;
51 52
import com.iver.cit.gvsig.fmap.layers.FLayers;
52 53
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
......
54 55
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo;
55 56
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
56 57
import com.iver.cit.gvsig.gui.layout.Layout;
58
import com.iver.cit.gvsig.gui.layout.LayoutEditableFeature;
57 59

  
58 60
import com.iver.utiles.XMLEntity;
59 61

  
......
66 68
import java.awt.geom.Rectangle2D;
67 69
import java.awt.image.BufferedImage;
68 70

  
69
import java.util.ArrayList;
71
import java.io.IOException;
70 72

  
71 73

  
72 74
/**
......
299 301
	}
300 302

  
301 303
	/**
302
	 * A?ade al Layout un nuevo FFrameText a partir de los par?metros de entrada.
304
	 * A?ade al Layout un nuevo FFrameText a partir de los par?metros de
305
	 * entrada.
303 306
	 *
304 307
	 * @param layout Layout sobre el que se crea el nuevo FFrame.
305 308
	 * @param name Texto.
......
308 311
	 * @param x Posici?n X.
309 312
	 * @param y Posici?n Y.
310 313
	 * @param h Altura.
314
	 *
315
	 * @throws DriverIOException
316
	 * @throws IOException
311 317
	 */
312 318
	private void toFFrameText(Layout layout, String name, Rectangle2D re,
313
		int sizefont, int x, int y, double h) {
319
		int sizefont, int x, int y, double h)
320
		throws DriverIOException, IOException {
314 321
		int wl = (int) (re.getWidth() / 1.5);
315 322
		int haux = (int) (sizefont * 0.7);
316
		Rectangle2D rAux = new Rectangle2D.Double((int) x, y, wl,
317
				haux);
323
		Rectangle2D rAux = new Rectangle2D.Double((int) x, y, wl, haux);
318 324
		FFrameText text = new FFrameText();
319 325
		text.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT()));
320 326
		text.addText(name);
321
		layout.addFFrame(text, false);
327
		getEFS(layout).addFFrame(text);
322 328
	}
323 329

  
324 330
	/**
......
354 360
	 * @param sizefont tama?o de la fuente.
355 361
	 * @param type Tipo de s?mbolo.
356 362
	 * @param h Altura.
363
	 *
364
	 * @throws DriverIOException
365
	 * @throws IOException
357 366
	 */
358 367
	private void toFFrameSymbol(Layout layout, Rectangle2D re, int x, int y,
359
		FSymbol fs2d, int sizefont, int type, double h) {
368
		FSymbol fs2d, int sizefont, int type, double h)
369
		throws DriverIOException, IOException {
360 370
		double pW = 5;
361 371
		double pH = m_numLayers;
362 372
		int wl = (int) (re.getWidth() / pW);
......
367 377
		FFrameSymbol symbol = new FFrameSymbol();
368 378
		symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT()));
369 379
		symbol.setSymbol(fs2d, type);
370
		layout.addFFrame(symbol, false);
380
		getEFS(layout).addFFrame(symbol);
371 381
	}
372 382

  
373 383
	/**
......
419 429
	/**
420 430
	 * Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
421 431
	 *
422
	 * @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el que elimnar el FFrameLegend anterior.
432
	 * @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el
433
	 * 		  que elimnar el FFrameLegend anterior.
434
	 * @param index DOCUMENT ME!
435
	 *
436
	 * @throws DriverIOException
437
	 * @throws IOException
423 438
	 */
424
	public void toFFrames(Layout layout) {
439
	public void toFFrames(Layout layout, int index)
440
		throws DriverIOException, IOException {
425 441
		Rectangle2D rectangle = getBoundingBox(null);
426 442
		double h = rectangle.getHeight() / m_numLayers;
427 443
		FLayers lays = layers;
428 444
		toFFrames(layout, lays, rectangle, h, 0);
429
		layout.getFFrames().remove(this);
445
		getEFS(layout).removeFFrame(this, index);
430 446
	}
431 447

  
432 448
	/**
......
439 455
	 * @param n n?mero de Capa a?adida.
440 456
	 *
441 457
	 * @return n?mero de Capa a a?adir.
458
	 *
459
	 * @throws DriverIOException
460
	 * @throws IOException
442 461
	 */
443 462
	public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle,
444
		double h, int n) {
445
		//TODO Falta que implementar.
463
		double h, int n) throws DriverIOException, IOException {
446 464
		//////	Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics	
447 465
		int d = 4;
448 466

  
......
472 490
						} else {
473 491
							sizefont = (int) (rectangle.getWidth() / 8);
474 492
						}
493

  
475 494
						toFFrameText(layout, layer.getName(), rectangle,
476 495
							sizefont, xl, yl, h);
477 496
						n++;
......
485 504
							String s = cli.getDescriptions()[j];
486 505
							toFFrameText(layout, s, rectangle, sizefont, xl,
487 506
								yl, h);
507

  
488 508
							FSymbol fs2d = cli.getSymbols()[j];
489 509

  
490 510
							try {
......
510 530
						} else {
511 531
							sizefont = (int) (rectangle.getWidth() / 8);
512 532
						}
533

  
513 534
						toFFrameText(layout, layer.getName(), rectangle,
514 535
							sizefont, xl, yl, h);
536

  
515 537
						FSymbol fs2d = ((Classifiable) cO).getLegend()
516 538
										.getDefaultSymbol();
517 539

  
......
522 544
						} catch (DriverException e) {
523 545
							e.printStackTrace();
524 546
						}
547

  
525 548
						n++;
526 549
					}
527 550
				}
528 551
			}
529 552
		}
553

  
530 554
		return n;
531 555
	}
532 556

  
......
576 600
		///xml.addChild(fframeview.getXMLEntity());
577 601
		LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class);
578 602
		Layout layout = lc.getLayout();
579
		ArrayList fframes = layout.getFFrames();
603
		IFFrame[] fframes = layout.getFFrames1();
580 604

  
581
		for (int i = 0; i < fframes.size(); i++) {
582
			if (fframes.get(i) instanceof FFrameView) {
583
				if (fframeview.getView().getName().equals(((FFrameView) fframes
584
															   .get(i)).getView()
605
		for (int i = 0; i < fframes.length; i++) {
606
			if (fframes[i] instanceof FFrameView) {
607
				if (fframeview.getView().getName().equals(((FFrameView) fframes[i]).getView()
585 608
															   .getName())) {
586 609
					xml.putProperty("index", i);
587 610
				}
588 611
			}
589 612
		}
590 613

  
591
		/*ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
592
		   ArrayList views = pe.getProject().getViews();
593
		   boolean hasIndex = false;
594
		   for (int i = 0; i < views.size(); i++) {
595
		           if (fframeview.getView() == ((ProjectView) views.get(i))) {
596
		                   xml.putProperty("indice", i);
597
		                   hasIndex = true;
598
		           }
599
		   }
600
		   if (!hasIndex) {
601
		           xml.putProperty("indice", -1);
602
		   }
603
		 */
604

  
605
		//De este ?ndice se debe de obtener el arrayList de layers.
606

  
607
		/* ProjectExtension pe = (ProjectExtension) App.instance.getPc()
608
		   .getExtension(ProjectExtension.class);
609
		   ArrayList views = pe.getProject().getViews();
610
		   boolean hasIndex = false;
611
		   for (int i = 0; i < views.size(); i++) {
612
		       if (m_fmap == ((ProjectView) views.get(i)).getMapContext()) {
613
		           xml.putProperty("indice", i);
614
		           hasIndex = true;
615
		       }
616
		   }
617
		   if (!hasIndex) {
618
		       xml.putProperty("indice", -1);
619
		   }
620
		 */
621 614
		return xml;
622 615
	}
623 616

  
......
639 632
		this.m_f = new Font(xml.getStringProperty("fontName"),
640 633
				xml.getIntProperty("fontStyle"), 9);
641 634

  
642
		//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
643
		//		p));
644

  
645
		/*        int indice = xml.getIntProperty("indice");
646
		   if (indice != -1) {
647
		           ProjectView view = (ProjectView) p.getViews().get(indice);
648
		
649
		           fframeview.setView((ProjectView) view);
650
		   }
651
		 */
652
		ArrayList fframes = l.getFFrames();
653
		fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
654

  
655
		/*                LayoutControls lc=(LayoutControls)PluginServices.getExtension(LayoutControls.class);
656
		   Layout layout=lc.getLayout();
657
		   ArrayList fframes=layout.getFFrames();
658
		   fframeview=(FFrameView)fframes.get(xml.getIntProperty("index"));
659
		 */
660

  
661
		//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
662
		//		p));
635
		IFFrame[] fframes = l.getFFrames1();
636
		fframeview = (FFrameView) fframes[xml.getIntProperty("index")];
663 637
	}
664 638

  
665 639
	/**
......
677 651
		throws DriverException {
678 652
		draw(g, at, null, null);
679 653
	}
654

  
655
	/**
656
	 * M?todo privado para acceder al EditableFeatureSource del Layout.
657
	 *
658
	 * @param l Referencia al Layout.
659
	 *
660
	 * @return EditableFeatureSource del Layout.
661
	 */
662
	private LayoutEditableFeature getEFS(Layout l) {
663
		return (LayoutEditableFeature) l.getCadToolAdapter()
664
										.getEditableFeatureSource();
665
	}
680 666
}

Also available in: Unified diff