Statistics
| Revision:

root / branches / gvSIG_GisPlanet / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameLegend.java @ 2188

History | View | Annotate | Download (21.2 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.gui.layout.fframes;
42

    
43
import com.iver.andami.PluginServices;
44

    
45
import com.iver.cit.gvsig.LayoutControls;
46
import com.iver.cit.gvsig.fmap.DriverException;
47
import com.iver.cit.gvsig.fmap.FMap;
48
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
49
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
50
import com.iver.cit.gvsig.fmap.layers.FLayer;
51
import com.iver.cit.gvsig.fmap.layers.FLayers;
52
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
53
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable;
54
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo;
55
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
56
import com.iver.cit.gvsig.gui.layout.Layout;
57

    
58
import com.iver.utiles.XMLEntity;
59

    
60
import java.awt.Color;
61
import java.awt.Font;
62
import java.awt.Graphics2D;
63
import java.awt.Rectangle;
64
import java.awt.font.FontRenderContext;
65
import java.awt.geom.AffineTransform;
66
import java.awt.geom.Rectangle2D;
67
import java.awt.image.BufferedImage;
68

    
69
import java.util.ArrayList;
70

    
71

    
72
/**
73
 * FFrame para introducir una leyenda en el Layout.
74
 *
75
 * @author Vicente Caballero Navarro
76
 */
77
public class FFrameLegend extends FFrame {
78
        private static final int PRESENTACION = 0;
79
        private static final int BORRADOR = 1;
80
        private int m_quality = 0;
81
        private int m_viewing = 0;
82
        private FontRenderContext m_frc = null;
83
        private FMap m_fmap = null;
84
        private Font m_f = new Font("Monospaced", Font.PLAIN, 9);
85
        private FFrameView fframeview = null;
86
        private int num = 0;
87
        private int m_max;
88
        private int m_numLayers;
89
        private FLayers layers = null;
90

    
91
        /**
92
         * Rellena la calidad que se quiere aplicar.
93
         *
94
         * @param q entero que representa la calidad a aplicar.
95
         */
96
        public void setQuality(int q) {
97
                m_quality = q;
98
        }
99

    
100
        /**
101
         * Devuelve un entero que representa la calidad que est? seleccionada.
102
         *
103
         * @return tipo de calidad selccionada.
104
         */
105
        public int getQuality() {
106
                return m_quality;
107
        }
108

    
109
        /**
110
         * Devuelve un entero que representa la forma en que se actualiza la vista.
111
         *
112
         * @return forma que se actualiza la vista.
113
         */
114
        public int getViewing() {
115
                return m_viewing;
116
        }
117

    
118
        /**
119
         * Inserta una FFrameView de donde se obtiene la informaci?n de las capas
120
         * para generar la leyenda.
121
         *
122
         * @param f FFrameView para obtener los nombres de las capas.
123
         */
124
        public void setFFrameView(FFrameView f) {
125
                fframeview = f;
126
        }
127

    
128
        /**
129
         * Devuelve el FFrameView utilizado para obtener la leyenda.
130
         *
131
         * @return FFrameView utilizado.
132
         */
133
        public FFrameView getFFrameView() {
134
                return fframeview;
135
        }
136

    
137
        /**
138
         * Rellena la forma de actualizar la vista.
139
         *
140
         * @param v entero que representa la forma de actualizar la vista.
141
         */
142
        public void setViewing(int v) {
143
                m_viewing = v;
144
        }
145

    
146
        /**
147
         * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
148
         * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
149
         * de dibujar.
150
         *
151
         * @param g Graphics
152
         * @param at Transformada afin.
153
         * @param rv rect?ngulo sobre el que hacer un clip.
154
         * @param imgBase Imagen para acelerar el dibujado.
155
         *
156
         * @throws DriverException
157
         */
158
        public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
159
                BufferedImage imgBase) throws DriverException {
160
                Rectangle2D.Double re = getBoundingBox(at);
161

    
162
                if ((fframeview != null) && (fframeview.getFMap() != null)) {
163
                        layers = fframeview.getFMap().getLayers();
164
                }
165

    
166
                m_max = 0;
167
                m_numLayers = 0;
168

    
169
                if (intersects(rv, re)) {
170
                        if (layers == null) { //Si no se ha seleccionado ninguna vista para crear la leyenda.
171
                                drawEmpty(g);
172
                        } else if ((rv == null) || (getQuality() == PRESENTACION)) {
173
                                m_numLayers = getSizeNum(layers);
174
                                m_frc = g.getFontRenderContext();
175

    
176
                                double h = re.getHeight() / m_numLayers;
177
                                int n = 0;
178
                                drawTheme(g, re, h, layers, n);
179
                        } else if (getQuality() == BORRADOR) { //Si se selecciona la calidad BORRADOR.
180
                                drawDraft(g);
181
                        }
182
                }
183
        }
184

    
185
        /**
186
         * Dibuja el nombre u s?mbolo de la capa que se pasa como par?metro.
187
         *
188
         * @param g Graphics2D sobre el que se dibuja.
189
         * @param re Rectangle a rellenar.
190
         * @param h Altura en pixels.
191
         * @param layers Capa a representar.
192
         * @param n ?ndice de la capa a dibujar.
193
         *
194
         * @return ?ndice de la capa siguiente.
195
         *
196
         * @throws DriverException
197
         */
198
        private int drawTheme(Graphics2D g, Rectangle2D re, double h,
199
                FLayers layers, int n) throws DriverException {
200
                //////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics        
201
                for (int i = 0; i < layers.getLayersCount(); i++) {
202
                        FLayer layer = (FLayer) layers.getLayer(i);
203

    
204
                        if (layer.isVisible()) {
205
                                if (layer instanceof FLayers) {
206
                                        n += drawTheme(g, re, h, layers, n);
207
                                } else if (layer instanceof AlphanumericData) {
208
                                        AlphanumericData cO = (AlphanumericData) layer;
209

    
210
                                        if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) {
211
                                                ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend();
212
                                                double dX = 0;
213
                                                double dY = n * h;
214

    
215
                                                int xl = (int) (re.getX() + dX);
216
                                                int yl = (int) (re.getY() + dY);
217
                                                int sizefont = 0;
218

    
219
                                                if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) {
220
                                                        sizefont = (int) (re.getHeight() / m_numLayers);
221
                                                } else {
222
                                                        sizefont = (int) (re.getWidth() / 8);
223
                                                }
224

    
225
                                                drawNameLegend(g, layer.getName(), re, sizefont,
226
                                                        (int) (xl - (re.getWidth() / 5)), yl, h);
227
                                                n++;
228

    
229
                                                for (int j = 0; j < cli.getValues().length; j++) {
230
                                                        dY = n * h;
231

    
232
                                                        xl = (int) (re.getX() + dX);
233
                                                        yl = (int) (re.getY() + dY);
234

    
235
                                                        String s = cli.getDescriptions()[j];
236
                                                        drawNameLegend(g, s, re, sizefont, xl, yl, h);
237

    
238
                                                        FSymbol fs2d = cli.getSymbols()[j];
239
                                                        drawSymbolLegend(g, re, xl, yl, fs2d, sizefont,
240
                                                                ((Classifiable) cO).getShapeType(), h);
241

    
242
                                                        n++;
243
                                                }
244
                                        } else {
245
                                                double dX = 0;
246
                                                double dY = n * h;
247

    
248
                                                int xl = (int) (re.getX() + dX);
249
                                                int yl = (int) (re.getY() + dY);
250
                                                int sizefont = 0;
251

    
252
                                                if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) {
253
                                                        sizefont = (int) (re.getHeight() / m_numLayers);
254
                                                } else {
255
                                                        sizefont = (int) (re.getWidth() / 8);
256
                                                }
257

    
258
                                                drawNameLegend(g, layer.getName(), re, sizefont, xl,
259
                                                        yl, h);
260

    
261
                                                //FStyle2D fs2d = cO.getLegendInfo().getSymbol();
262
                                                //drawSymbolLegend(g, re, xl, yl, fs2d,sizefont,cO.getShapeType());
263
                                                FSymbol fs2d = ((Classifiable) cO).getLegend()
264
                                                                                .getDefaultSymbol();
265

    
266
                                                //System.out.println("sizefont = " + sizefont);
267
                                                drawSymbolLegend(g, re, xl, yl, fs2d, sizefont,
268
                                                        ((Classifiable) cO).getShapeType(), h);
269

    
270
                                                //System.out.println("cO.getShapeType()= " +
271
                                                //    cO.getShapeType());
272
                                                n++;
273
                                        }
274
                                }
275
                        }
276
                }
277

    
278
                return n;
279
        }
280

    
281
        /**
282
         * Dibuja sobre el graphics el nombre de la capa que se pasa como
283
         * par?metro.
284
         *
285
         * @param g Graphics2D sobre el que dibujar.
286
         * @param name Nombre de la capa.
287
         * @param re Rect?ngulo a ocupar por el nombre.
288
         * @param sizefont tama?o de la fuente.
289
         * @param x Posici?n X.
290
         * @param y Posici?n Y.
291
         * @param h Altura.
292
         */
293
        private void drawNameLegend(Graphics2D g, String name, Rectangle2D re,
294
                int sizefont, int x, int y, double h) {
295
                Font f = new Font("SansSerif", Font.PLAIN, sizefont);
296
                g.setFont(f);
297
                g.setColor(Color.black);
298
                g.drawString(name, (int) (x + (re.getWidth() / 4)), (int) (y + (h / 2)));
299
        }
300

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

    
325
        /**
326
         * Dibuja sobre el Graphics2D el s?mbolo.
327
         *
328
         * @param g Graphics2D.
329
         * @param re Rect?ngulo a cubrir por el s?mbolo.
330
         * @param x Posici?n X.
331
         * @param y Posici?n Y.
332
         * @param fs2d S?mbolo a dibujar.
333
         * @param sizefont Tama?o de la fuente.
334
         * @param type Tipo de s?mbolo.
335
         * @param h Altura.
336
         */
337
        private void drawSymbolLegend(Graphics2D g, Rectangle2D re, int x, int y,
338
                FSymbol fs2d, int sizefont, int type, double h) {
339
                double pW = 5;
340
                double pH = m_numLayers;
341
                int wl = (int) (re.getWidth() / pW);
342
                int haux = (int) (sizefont * 0.7);
343
                FGraphicUtilities.DrawSymbol(g, new AffineTransform(),
344
                        new Rectangle(x, (int) ((y + (h / 2)) - haux), wl, haux), fs2d);
345
        }
346

    
347
        /**
348
         * A?ade al Layout un nuevo FFrameSymbol.
349
         *
350
         * @param layout Layout sobe el que se a?ade el FFrame.
351
         * @param re Rect?ngulo del FFrame.
352
         * @param x Posici?n X.
353
         * @param y Posici?n Y.
354
         * @param fs2d S?mbolo a a?adir.
355
         * @param sizefont tama?o de la fuente.
356
         * @param type Tipo de s?mbolo.
357
         * @param h Altura.
358
         */
359
        private void toFFrameSymbol(Layout layout, Rectangle2D re, int x, int y,
360
                FSymbol fs2d, int sizefont, int type, double h) {
361
                double pW = 5;
362
                double pH = m_numLayers;
363
                int wl = (int) (re.getWidth() / pW);
364

    
365
                int haux = (int) (sizefont * 0.7);
366
                Rectangle2D rAux3 = new Rectangle2D.Double(x,
367
                                (int) ((y + (h / 2)) - haux), wl, haux);
368
                FFrameSymbol symbol = new FFrameSymbol();
369
                symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT()));
370
                symbol.setSymbol(fs2d, type);
371
                layout.addFFrame(symbol, false);
372
        }
373

    
374
        /**
375
         * Devuelve el n?mero total de capas incluyendo las subcapas.
376
         *
377
         * @param layers Capa a contar.
378
         *
379
         * @return N?mero de capas y subcapas.
380
         */
381
        private int getSizeNum(FLayers layers) {
382
                int n = 0;
383

    
384
                /////Aqu? hay que calcular cuantos layers y sublayers hay, para saber que distancias dejar entre uno y otro.
385
                ///y adem?s el tama?o de cada uno de ellos para saber que anchura dejar.
386
                for (int i = 0; i < layers.getLayersCount(); i++) {
387
                        FLayer layer = (FLayer) layers.getLayer(i);
388

    
389
                        if (layer.isVisible()) {
390
                                if (layer.getName().length() > m_max) {
391
                                        m_max = layer.getName().length();
392
                                }
393

    
394
                                if (layer instanceof FLayers) {
395
                                        n += getSizeNum((FLayers) layer); //m_numLayers += getNumInLyrGroup((FLayers) layer);
396
                                } else if (layer instanceof AlphanumericData) {
397
                                        AlphanumericData cO = (AlphanumericData) layer;
398
                                        n++;
399

    
400
                                        if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) {
401
                                                ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend();
402

    
403
                                                for (int j = 0; j < cli.getValues().length; j++) {
404
                                                        String s = cli.getDescriptions()[j];
405

    
406
                                                        if (s.length() > m_max) {
407
                                                                m_max = s.length();
408
                                                        }
409

    
410
                                                        n++;
411
                                                }
412
                                        }
413
                                }
414
                        }
415
                }
416

    
417
                return n;
418
        }
419

    
420
        /**
421
         * Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
422
         *
423
         * @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el que elimnar el FFrameLegend anterior.
424
         */
425
        public void toFFrames(Layout layout) {
426
                Rectangle2D rectangle = getBoundingBox(null);
427
                double h = rectangle.getHeight() / m_numLayers;
428
                FLayers lays = layers;
429
                toFFrames(layout, lays, rectangle, h, 0);
430
                layout.getFFrames().remove(this);
431
        }
432

    
433
        /**
434
         * Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
435
         *
436
         * @param layout Referencia al Layout.
437
         * @param lays Layers a a?adir
438
         * @param rectangle Rect?ngulo del FFrameLegend.
439
         * @param h Altura
440
         * @param n n?mero de Capa a?adida.
441
         *
442
         * @return n?mero de Capa a a?adir.
443
         */
444
        public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle,
445
                double h, int n) {
446
                //TODO Falta que implementar.
447
                //////        Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics        
448
                int d = 4;
449

    
450
                for (int i = 0; i < lays.getLayersCount(); i++) {
451
                        FLayer layer = (FLayer) lays.getLayer(i);
452

    
453
                        if (layer.isVisible()) {
454
                                if (layer instanceof FLayers) {
455
                                        rectangle.setRect(rectangle.getX(),
456
                                                rectangle.getY() + (h * n), rectangle.getWidth(),
457
                                                rectangle.getHeight());
458
                                        n += toFFrames(layout, lays, rectangle, h, n); //drawTheme(g, re, h, layers, n);
459
                                } else if (layer instanceof AlphanumericData) {
460
                                        AlphanumericData cO = (AlphanumericData) layer;
461

    
462
                                        if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) {
463
                                                ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend();
464
                                                double dX = rectangle.getWidth() / 4;
465
                                                double dY = n * h;
466

    
467
                                                int xl = (int) (rectangle.getX() + dX);
468
                                                int yl = (int) (rectangle.getY() + dY);
469
                                                int sizefont = 0;
470

    
471
                                                if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) {
472
                                                        sizefont = (int) (rectangle.getHeight() / m_numLayers);
473
                                                } else {
474
                                                        sizefont = (int) (rectangle.getWidth() / 8);
475
                                                }
476
                                                toFFrameText(layout, layer.getName(), rectangle,
477
                                                        sizefont, xl, yl, h);
478
                                                n++;
479

    
480
                                                for (int j = 0; j < cli.getValues().length; j++) {
481
                                                        dY = n * h;
482

    
483
                                                        xl = (int) (rectangle.getX() + dX);
484
                                                        yl = (int) (rectangle.getY() + dY);
485

    
486
                                                        String s = cli.getDescriptions()[j];
487
                                                        toFFrameText(layout, s, rectangle, sizefont, xl,
488
                                                                yl, h);
489
                                                        FSymbol fs2d = cli.getSymbols()[j];
490

    
491
                                                        try {
492
                                                                toFFrameSymbol(layout, rectangle,
493
                                                                        (int) rectangle.getX(), yl, fs2d, sizefont,
494
                                                                        ((Classifiable) cO).getShapeType(), h);
495
                                                        } catch (DriverException e) {
496
                                                                e.printStackTrace();
497
                                                        }
498

    
499
                                                        n++;
500
                                                }
501
                                        } else {
502
                                                double dX = rectangle.getWidth() / 4;
503
                                                double dY = n * h;
504

    
505
                                                int xl = (int) (rectangle.getX() + dX);
506
                                                int yl = (int) (rectangle.getY() + dY);
507
                                                int sizefont = 0;
508

    
509
                                                if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) {
510
                                                        sizefont = (int) (rectangle.getHeight() / m_numLayers);
511
                                                } else {
512
                                                        sizefont = (int) (rectangle.getWidth() / 8);
513
                                                }
514
                                                toFFrameText(layout, layer.getName(), rectangle,
515
                                                        sizefont, xl, yl, h);
516
                                                FSymbol fs2d = ((Classifiable) cO).getLegend()
517
                                                                                .getDefaultSymbol();
518

    
519
                                                try {
520
                                                        toFFrameSymbol(layout, rectangle,
521
                                                                (int) rectangle.getX(), yl, fs2d, sizefont,
522
                                                                ((Classifiable) cO).getShapeType(), h);
523
                                                } catch (DriverException e) {
524
                                                        e.printStackTrace();
525
                                                }
526
                                                n++;
527
                                        }
528
                                }
529
                        }
530
                }
531
                return n;
532
        }
533

    
534
        /**
535
         * Rellena la fuente a utilizar al dibujar los String sobre el graphics.
536
         *
537
         * @param f Font.
538
         */
539
        public void setFont(Font f) {
540
                m_f = f;
541
        }
542

    
543
        /**
544
         * Devuelve la fuente que esta utilizando.
545
         *
546
         * @return Font.
547
         */
548
        public Font getFont() {
549
                if (m_f != null) {
550
                        return new Font(m_f.getFontName(), m_f.getStyle(), 9);
551
                }
552

    
553
                return null;
554
        }
555

    
556
        /**
557
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
558
         */
559
        public XMLEntity getXMLEntity() {
560
                XMLEntity xml = new XMLEntity();
561
                xml.putProperty("className", this.getClass().getName());
562
                xml.putProperty("m_name", m_name);
563
                xml.putProperty("x", getBoundBox().x);
564
                xml.putProperty("y", getBoundBox().y);
565
                xml.putProperty("w", getBoundBox().width);
566
                xml.putProperty("h", getBoundBox().height);
567
                xml.putProperty("m_Selected", m_Selected);
568
                xml.putProperty("type", Layout.RECTANGLELEGEND);
569
                xml.putProperty("m_numLayers", m_numLayers);
570
                xml.putProperty("m_max", m_max);
571
                xml.putProperty("m_quality", m_quality);
572
                xml.putProperty("m_viewing", m_viewing);
573
                xml.putProperty("fontName", m_f.getFontName());
574
                xml.putProperty("fontStyle", m_f.getStyle());
575
                xml.putProperty("tag", getTag());
576

    
577
                ///xml.addChild(fframeview.getXMLEntity());
578
                LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class);
579
                Layout layout = lc.getLayout();
580
                ArrayList fframes = layout.getFFrames();
581

    
582
                for (int i = 0; i < fframes.size(); i++) {
583
                        if (fframes.get(i) instanceof FFrameView) {
584
                                if (fframeview != null && fframeview.getView().getName().equals(((FFrameView) fframes
585
                                                                                                                           .get(i)).getView()
586
                                                                                                                           .getName())) {
587
                                        xml.putProperty("index", i);
588
                                }
589
                        }
590
                }
591

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

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

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

    
625
        /**
626
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
627
         *                 com.iver.cit.gvsig.project.Project)
628
         */
629
        public void setXMLEntity03(XMLEntity xml, Layout l) {
630
                if (xml.getIntProperty("m_Selected") != 0) {
631
                        this.setSelected(true);
632
                } else {
633
                        this.setSelected(false);
634
                }
635

    
636
                this.m_numLayers = xml.getIntProperty("m_numLayers");
637
                this.m_max = xml.getIntProperty("m_max");
638
                this.m_quality = xml.getIntProperty("m_quality");
639
                this.m_viewing = xml.getIntProperty("m_viewing");
640
                this.m_f = new Font(xml.getStringProperty("fontName"),
641
                                xml.getIntProperty("fontStyle"), 9);
642

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

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

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

    
662
                //this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
663
                //                p));
664
        }
665

    
666
        /**
667
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
668
         *                 com.iver.cit.gvsig.project.Project)
669
         */
670
        public void setXMLEntity(XMLEntity xml, Layout l) {
671
                if (xml.getIntProperty("m_Selected") != 0) {
672
                        this.setSelected(true);
673
                } else {
674
                        this.setSelected(false);
675
                }
676

    
677
                this.m_numLayers = xml.getIntProperty("m_numLayers");
678
                this.m_max = xml.getIntProperty("m_max");
679
                this.m_quality = xml.getIntProperty("m_quality");
680
                this.m_viewing = xml.getIntProperty("m_viewing");
681
                this.m_f = new Font(xml.getStringProperty("fontName"),
682
                                xml.getIntProperty("fontStyle"), 9);
683

    
684
                //this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
685
                //                p));
686

    
687
                /*        int indice = xml.getIntProperty("indice");
688
                   if (indice != -1) {
689
                           ProjectView view = (ProjectView) p.getViews().get(indice);
690
                
691
                           fframeview.setView((ProjectView) view);
692
                   }
693
                 */
694
                ArrayList fframes = l.getFFrames();
695
                if (xml.contains("index")){
696
                        fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
697
                }
698
                /*                LayoutControls lc=(LayoutControls)PluginServices.getExtension(LayoutControls.class);
699
                   Layout layout=lc.getLayout();
700
                   ArrayList fframes=layout.getFFrames();
701
                   fframeview=(FFrameView)fframes.get(xml.getIntProperty("index"));
702
                 */
703

    
704
                //this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
705
                //                p));
706
        }
707

    
708
        /**
709
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
710
         */
711
        public String getNameFFrame() {
712
                return PluginServices.getText(this, "leyenda") + num;
713
        }
714

    
715
        /**
716
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
717
         *                 java.awt.geom.AffineTransform)
718
         */
719
        public void print(Graphics2D g, AffineTransform at)
720
                throws DriverException {
721
                draw(g, at, null, null);
722
        }
723
}