Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameLegend.java @ 2183

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.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT()));
320
                text.addText(name);
321
                layout.addFFrame(text, false);
322
        }
323

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

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

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

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

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

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

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

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

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

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

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

    
416
                return n;
417
        }
418

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
552
                return null;
553
        }
554

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

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

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

    
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
                return xml;
622
        }
623

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

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

    
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));
663
        }
664

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

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

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

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

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

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

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