Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrVect.java @ 2759

History | View | Annotate | Download (20.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.fmap.layers;
42

    
43
import java.awt.Graphics2D;
44
import java.awt.geom.Point2D;
45
import java.awt.geom.Rectangle2D;
46
import java.awt.image.BufferedImage;
47
import java.util.ArrayList;
48
import java.util.BitSet;
49

    
50
import org.apache.log4j.Logger;
51
import org.cresques.cts.ICoordTrans;
52

    
53
import com.hardcode.driverManager.DriverLoadException;
54
import com.hardcode.gdbms.engine.data.DataSource;
55
import com.hardcode.gdbms.engine.data.DataSourceFactory;
56
import com.hardcode.gdbms.engine.data.NoSuchTableException;
57
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
58
import com.hardcode.gdbms.engine.values.DoubleValue;
59
import com.hardcode.gdbms.engine.values.FloatValue;
60
import com.hardcode.gdbms.engine.values.NullValue;
61
import com.hardcode.gdbms.engine.values.Value;
62
import com.iver.cit.gvsig.fmap.DriverException;
63
import com.iver.cit.gvsig.fmap.ViewPort;
64
import com.iver.cit.gvsig.fmap.core.IGeometry;
65
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
66
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
67
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
68
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
69
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
70
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
71
import com.iver.cit.gvsig.fmap.layers.layerOperations.Labelable;
72
import com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData;
73
import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable;
74
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer;
75
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData;
76
import com.iver.cit.gvsig.fmap.operations.Cancellable;
77
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
78
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
79
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
80
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
81
import com.iver.cit.gvsig.fmap.rendering.Legend;
82
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
83
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
84
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
85
import com.iver.utiles.PostProcessSupport;
86
import com.iver.utiles.XMLEntity;
87

    
88

    
89
/**
90
 * Capa b?sica Vectorial.
91
 *
92
 * @author Fernando Gonz?lez Cort?s
93
 */
94

    
95
//TODO Cuando no sea para pruebas debe no ser public
96
public class FLyrVect extends FLyrDefault implements Labelable, Selectable,
97
        AlphanumericData, ClassifiableVectorial, SingleLayer, VectorialData,
98
        RandomVectorialData {
99
        private static Logger logger = Logger.getLogger(FLyrVect.class.getName());
100

    
101
        /** Leyenda de la capa vectorial */
102
        private VectorialLegend legend;
103
        private int typeShape = -1;
104
        private SelectionSupport selectionSupport = new SelectionSupport();
105
        private LayerChangeSupport layerChangeSupport = new LayerChangeSupport();
106
        private VectorialAdapter source;
107
        private SelectableDataSource sds;
108
    
109
    private boolean bHasJoin = false;
110

    
111
        /**
112
         * A?ade un SelectionListener a la lista de listeners.
113
         *
114
         * @param listener SelectionListener.
115
         */
116
        public void addSelectionListener(SelectionListener listener) {
117
                selectionSupport.addSelectionListener(listener);
118
        }
119

    
120
        /**
121
         * Borra un selectionListener de la lista de listeners.
122
         *
123
         * @param listener SelectionListener
124
         */
125
        public void removeSelectionListener(SelectionListener listener) {
126
                selectionSupport.removeSelectionListener(listener);
127
        }
128

    
129
        /**
130
         * Cuando ocurre un evento de cambio en la selecci?n, ?ste puede ser uno de
131
         * una gran cantidad de eventos. Con el fin de no propagar todos estos
132
         * eventos, se realiza la propagaci?n de manera manual al final de la
133
         * "r?faga" de eventos
134
         */
135
        public void fireSelectionEvents() {
136
                selectionSupport.fireSelectionEvents();
137
        }
138

    
139
        /**
140
         * Devuelve el VectorialAdapater de la capa.
141
         *
142
         * @return VectorialAdapter.
143
         */
144
        public VectorialAdapter getSource() {
145
                return source;
146
        }
147

    
148
        /**
149
         * Inserta el VectorialAdapter a la capa.
150
         *
151
         * @param va VectorialAdapter.
152
         */
153
        public void setSource(VectorialAdapter va) {
154
                source = va;
155
        }
156

    
157
        /**
158
         * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#getFullExtent()
159
         */
160
        public Rectangle2D getFullExtent() throws DriverException {
161
                try {
162
                        Rectangle2D rAux;
163
                        logger.debug("source.start()");
164
                        source.start();
165
                        rAux = source.getFullExtent();
166
                        logger.debug("source.stop()");
167
                        source.stop();
168

    
169
                        // Si existe reproyecci?n, reproyectar el extent
170
                        ICoordTrans ct = getCoordTrans();
171

    
172
                        if (ct != null) {
173
                                Point2D pt1 = new Point2D.Double(rAux.getMinX(), rAux.getMinY());
174
                                Point2D pt2 = new Point2D.Double(rAux.getMaxX(), rAux.getMaxY());
175
                                pt1 = ct.convert(pt1, null);
176
                                pt2 = ct.convert(pt2, null);
177
                                rAux = new Rectangle2D.Double();
178
                                rAux.setFrameFromDiagonal(pt1, pt2);
179
                        }
180

    
181
                        return rAux;
182
                } catch (DriverIOException e) {
183
                        throw new DriverException(e);
184
                }
185
        }
186

    
187
        /**
188
         * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage,
189
         *                 java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
190
         */
191
        public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
192
                Cancellable cancel,double scale) throws DriverException {
193
            
194
                if (isWithinScale(scale)){        
195
            
196
                Strategy strategy = StrategyManager.getStrategy(this);
197

    
198
                strategy.draw(image, g, viewPort, cancel);
199

    
200
                if (getVirtualLayers() != null) {
201
                        getVirtualLayers().draw(image, g, viewPort, cancel,scale);
202
                }
203

    
204
                if (getLayerText() != null) {
205
                        getLayerText().draw(image, g, viewPort, cancel,scale);
206
                }
207
                }
208
        }
209

    
210
        /**
211
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
212
         *                 com.iver.cit.gvsig.fmap.ViewPort,
213
         *                 com.iver.cit.gvsig.fmap.operations.Cancellable)
214
         */
215
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
216
                throws DriverException {
217
                if (isVisible() && isWithinScale(scale)){        
218
                Strategy strategy = StrategyManager.getStrategy(this);
219

    
220
                strategy.print(g, viewPort, cancel);
221

    
222
                if (getLayerText() != null) {
223
                        getLayerText().draw(null, g, viewPort, cancel,scale);
224
                }
225
                }
226
        }
227

    
228
        /**
229
         * @see com.iver.cit.gvsig.fmap.layers.VectorialOperations#createLabelLayer(int)
230
         */
231
        // public FLayer createLabelLayer(int fieldId) {
232
    public FLayer createLabelLayer(SelectableDataSource ds) {
233
                ArrayList labels = new ArrayList();
234

    
235
                try {
236
                        VectorialAdapter adapter = getSource();
237
                        logger.debug("adapter.start()");
238
                        adapter.start();
239
                        ds.start();
240

    
241
                        //VectorialDriver driver = (VectorialDriver) adapter.getDriver();
242
            long sc;
243

    
244
            sc = ds.getRowCount();
245
            
246
            int fieldId = ds.getFieldIndexByName(legend.getLabelField());
247

    
248
            DriverAttributes attr = adapter.getDriverAttributes();
249
            boolean bMustClone = false;
250
            if (attr != null)
251
            {
252
                if (attr.isLoadedInMemory())
253
                {
254
                    bMustClone = attr.isLoadedInMemory();               
255
                }
256
            }
257
            ICoordTrans ct = getCoordTrans();
258
            
259
                        VectorialLegend l = (VectorialLegend) getLegend();
260
                        int idFieldHeightText = -1;
261
                        int idFieldRotationText = -1;
262
                        
263

    
264
                        if (l.getLabelHeightField() != null) {
265
                                l.setBWithHeightText(true);
266
                                idFieldHeightText = ds.getFieldIndexByName(l.getLabelHeightField());
267
                        }else{
268
                                l.setBWithHeightText(false);
269
                        }
270

    
271
                        boolean bWithRotationText = false;
272

    
273
                        if (l.getLabelRotationField() != null) {
274
                                bWithRotationText = true;
275
                                idFieldRotationText = ds.getFieldIndexByName(l.getLabelRotationField());
276
                        }
277

    
278
                        for (int i = 0; i < sc; i++) {
279
                                Value val = ds.getFieldValue(i, fieldId);
280

    
281
                                if ((val instanceof NullValue) || (val == null)) {
282
                                        continue;
283
                                }
284

    
285
                                IGeometry geom = adapter.getShape(i);
286

    
287
                                if (geom == null) {
288
                                        continue;
289
                                }
290
                if (ct != null) {
291
                    if (bMustClone)
292
                        geom = geom.cloneGeometry();
293
                    geom.reProject(ct);
294
                }
295
                
296
                                FSymbol symbol = l.getSymbol(i);
297

    
298
                                // TODO: El m?todo contenedor (createLabelLayer) debe recoger
299
                                // los par?metros de posicionamiento y de allowDuplicates
300
                                // if (i >= 328)
301
                                //         System.out.println("i= " + i + " " + val.toString());
302
                                FLabel[] lbls = geom.createLabels(0, true);
303

    
304
                                for (int j = 0; j < lbls.length; j++) {
305
                                        if (lbls[j] != null) {
306
                                                lbls[j].setString(val.toString());
307

    
308
                                                if (l.isBWithHeightText()) {
309
                                                        FloatValue height = (FloatValue) ds.getFieldValue(i,
310
                                                                        idFieldHeightText);
311
                                                        lbls[j].setHeight(height.getValue());
312
                                                } else {
313
                            // El tama?o del texto va siempre en el simbolo por defecto
314
                            // cuando no hay un campo de altura de texto
315
                            // TODO: Todo esto cambiar? con el nuevo sistema de leyendas...
316
                                                        if (l.getDefaultSymbol()!=null)
317
                                                        lbls[j].setHeight(l.getDefaultSymbol().getFontSize());
318
                                                }
319

    
320
                                                if (bWithRotationText) {
321
                                                        DoubleValue rotation = (DoubleValue) ds.getFieldValue(i,
322
                                                                        idFieldRotationText);
323
                                                        lbls[j].setRotation(rotation.getValue());
324
                                                }
325
                                                labels.add(lbls[j]);        
326
                                        }
327

    
328
                                        
329
                                }
330
                        }
331

    
332
                        //long t2 = System.currentTimeMillis();
333
                        logger.debug("adapter.stop()");
334
                        ds.stop();
335
                        adapter.stop();
336
                } catch (DriverIOException e) {
337
                        e.printStackTrace();
338
                } catch (DriverException e) {
339
                        e.printStackTrace();
340
                } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
341
                        // TODO Auto-generated catch block
342
                        e.printStackTrace();
343
                }
344

    
345
                FLyrText layerText = new FLyrText(labels);
346

    
347
                try {
348
                        layerText.setLegend((VectorialLegend) getLegend());
349
                } catch (FieldNotFoundException e1) {
350
                        // TODO Auto-generated catch block
351
                        e1.printStackTrace();
352
                } catch (DriverException e1) {
353
                        // TODO Auto-generated catch block
354
                        e1.printStackTrace();
355
                }
356

    
357
                setLayerText(layerText);
358

    
359
                return layerText;
360
        }
361

    
362
        /**
363
         * @see com.iver.cit.gvsig.fmap.layers.VectorialOperations#removeLabels()
364
         */
365
        public void removeLabels() {
366
                setLayerText(null);
367
        }
368

    
369
        /**
370
         * @see com.iver.cit.gvsig.fmap.layers.VectorialOperations#createIndex()
371
         */
372
        public void createIndex() {
373
        }
374

    
375
        /**
376
         * @see com.iver.cit.gvsig.fmap.layers.VectorialOperations#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor,
377
         *                 com.iver.cit.gvsig.fmap.operations.selection.VectorialSubSet)
378
         */
379
        public void process(FeatureVisitor visitor, BitSet subset)
380
                throws DriverException, VisitException {
381
                Strategy s = StrategyManager.getStrategy(this);
382
                s.process(visitor, subset);
383
        }
384

    
385
        /**
386
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor)
387
         */
388
        public void process(FeatureVisitor visitor)
389
                throws DriverException, VisitException {
390
                Strategy s = StrategyManager.getStrategy(this);
391
                s.process(visitor);
392
        }
393

    
394
        /**
395
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#setSelection(com.iver.cit.gvsig.fmap.operations.selection.VectorialSubSet)
396
         */
397
        public void setSelection(FBitSet selection) {
398
                selectionSupport.setSelection(selection);
399
                fireSelectionEvents();
400
        }
401

    
402
        /**
403
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#isSelected(int)
404
         */
405
        public boolean isSelected(int index) {
406
                return selectionSupport.isSelected(index);
407
        }
408

    
409
        /**
410
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#getSelection()
411
         */
412
        public FBitSet getSelection() {
413
                return selectionSupport.getSelection();
414
        }
415

    
416
        /**
417
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#clearSelection()
418
         */
419
        public void clearSelection() {
420
                selectionSupport.clearSelection();
421
        }
422

    
423
        /**
424
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#queryByRect(java.awt.geom.Rectangle2D)
425
         */
426
        public BitSet queryByRect(Rectangle2D rect) throws DriverException {
427
                Strategy s = StrategyManager.getStrategy(this);
428

    
429
                return s.queryByRect(rect);
430
        }
431

    
432
        /**
433
         * @throws DriverException
434
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#getRecordset()
435
         */
436
        public SelectableDataSource getRecordset() throws DriverException {
437
                if (sds == null){
438
                        try {
439
                                DataSource ds = source.getRecordset();
440

    
441
                                if (ds == null) {
442
                                        return null;
443
                                }
444

    
445
                                sds = new SelectableDataSource(ds);
446
                                sds.setSelectionSupport(selectionSupport);
447
                                
448
                                return sds;
449
                        } catch (DriverLoadException e) {
450
                                throw new DriverException(e);
451
                        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
452
                                throw new DriverException(e);
453
            }
454
                }
455
                return sds;
456
        }
457
    
458
    /**
459
     * Para cuando haces una uni?n, sustituyes el recorset por el nuevo.
460
     * De esta forma, podr?s poner leyendas basadas en el nuevo
461
     * recordset
462
     * @param newSds
463
     * @throws DriverException 
464
     * @throws FieldNotFoundException 
465
     * @throws FieldNotFoundException 
466
     */
467
    public void setRecordset(SelectableDataSource newSds) throws DriverException, FieldNotFoundException
468
    {
469
        sds = newSds;
470
        sds.setSelectionSupport(selectionSupport);
471
        legend.setDataSource(sds);
472
        logger.debug("Recordset cambiado a " + sds.getName());
473
    }
474

    
475
        /**
476
         * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#setLegend(int,
477
         *                 com.iver.cit.gvsig.fmap.rendering.Legend)
478
         */
479
        public void setLegend(VectorialLegend r)
480
                throws DriverException, FieldNotFoundException {
481
                VectorialLegend oldLegend = legend;
482
                legend = r;
483

    
484
                try {
485
                        legend.setDataSource(getRecordset());
486

    
487
                        if (legend.getLabelField() != null) {
488
                            // sds.start();
489
                                // int idLabelField = getRecordset().getFieldIndexByName(legend.getLabelField());
490
                                createLabelLayer(sds);
491
                                // sds.stop();
492
                        }
493
                        else
494
                            removeLabels();
495
                } catch (DriverException e) {
496
                        throw new DriverException(e);
497
                } catch (FieldNotFoundException e) {
498
                        // TODO Auto-generated catch block
499
                        e.printStackTrace();
500
        }
501

    
502
                LegendChangedEvent e = LegendChangedEvent.createLegendChangedEvent(oldLegend, legend);
503
                callLegendChanged(e);
504
        }
505

    
506
        /**
507
         * Devuelve la Leyenda de la capa.
508
         *
509
         * @return Leyenda.
510
         */
511
        public Legend getLegend() {
512
                return legend;
513
        }
514

    
515
        /**
516
         * Devuelve el tipo de shape que contiene la capa.
517
         *
518
         * @return tipo de shape.
519
         *
520
         * @throws DriverException
521
         */
522
        public int getShapeType() throws DriverException {
523
                if (typeShape == -1) {
524
                        try {
525
                                logger.debug("source.start()");
526
                                source.start();
527
                                typeShape = source.getShapeType();
528
                                logger.debug("source.stop()");
529
                                source.stop();
530
                        } catch (DriverIOException e) {
531
                                throw new DriverException(e);
532
                        }
533
                }
534

    
535
                return typeShape;
536
        }
537

    
538
        /**
539
         * @throws XMLException
540
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties()
541
         */
542
        public XMLEntity getXMLEntity() throws XMLException {
543
                XMLEntity xml = super.getXMLEntity();
544
                xml.addChild(legend.getXMLEntity());
545
                xml.addChild(selectionSupport.getXMLEntity());
546

    
547
                if (source instanceof VectorialFileAdapter) {
548
                        xml.putProperty("type", "vectorial");
549
                        xml.putProperty("file", ((VectorialFileAdapter) source).getFile());
550
                        try {
551
                                xml.putProperty("recordset-name", getRecordset().getName());
552
                        } catch (DriverException e) {
553
                                throw new XMLException(e);
554
                        }
555
                } else if (source instanceof VectorialDBAdapter) {
556
            xml.putProperty("type", "vectorial");
557
            xml.putProperty("db", ((VectorialDBAdapter) source).getDriver().getClass().getName());
558
            try {
559
                xml.putProperty("recordset-name", getRecordset().getName());
560
            } catch (DriverException e) {
561
                throw new XMLException(e);
562
            }            
563
                } else if (source instanceof WFSAdapter) {
564
                }
565

    
566
                xml.putProperty("driverName", getSource().getDriver().getName());
567

    
568
        if (bHasJoin)
569
            xml.putProperty("hasJoin", "true");
570
                return xml;
571
        }
572

    
573
        /**
574
         * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity)
575
         */
576
        public void setXMLEntity03(XMLEntity xml)
577
                throws XMLException {
578
                
579
                super.setXMLEntity(xml);
580
                legend = LegendFactory.createFromXML03(xml.getChild(0));
581

    
582
                try {
583
                        // legend.setDataSource(getRecordset());
584
                        setLegend(legend);
585
                } catch (FieldNotFoundException e) {
586
                        throw new XMLException(e);
587
                } catch (DriverException e) {
588
                        throw new XMLException(e);
589
                }        
590

    
591
                selectionSupport.setXMLEntity03(xml.getChild(1));
592
        }
593

    
594
        /**
595
         * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity)
596
         */
597
        public void setXMLEntity(XMLEntity xml)
598
                throws XMLException {
599
        super.setXMLEntity(xml);
600
                
601
                legend = LegendFactory.createFromXML(xml.getChild(0));
602
                selectionSupport.setXMLEntity(xml.getChild(1));
603

    
604
                String recordsetName = xml.getStringProperty("recordset-name");
605
                try {
606
                        LayerFactory.getDataSourceFactory().changeDataSourceName(
607
                    getRecordset().getName(), recordsetName
608
                                        );
609
            // Hacemos que el recordset que hemos creado antes (los
610
            // recordset se crean antes que todo) sea el recordset
611
            // de esta capa. Y del que se crea automaticamente
612
            // en el setLegend del createLayer, nos olvidamos
613
            setRecordset(new SelectableDataSource(LayerFactory.getDataSourceFactory()
614
                        .createRandomDataSource(recordsetName, DataSourceFactory.AUTOMATIC_OPENING)));
615
                } catch (NoSuchTableException e1) {
616
                        throw new XMLException(e1);
617
                } catch (DriverException e1) {
618
                        throw new XMLException(e1);                
619
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e1) {
620
            throw new XMLException(e1);
621
        } catch (DriverLoadException e1) {
622
            throw new XMLException(e1);
623
        } catch (FieldNotFoundException e) {
624
            e.printStackTrace();
625
            throw new XMLException(e);
626
        }
627
        // Si tiene una uni?n, lo marcamos para que no se cree la leyenda hasta el final
628
        // de la lectura del proyecto
629
        if (xml.contains("hasJoin"))
630
        {
631
            setIsJoined(true);
632
            PostProcessSupport.addToPostProcess(this,"setLegend", legend, 1);
633
        }
634
        else
635
        {
636
            try {
637
                // legend.setDataSource(getRecordset());
638
                setLegend(legend);
639
            } catch (FieldNotFoundException e) {
640
                throw new XMLException(e);
641
            } catch (DriverException e) {
642
                throw new XMLException(e);
643
            }   
644
        }       
645
        
646
        }
647

    
648
        /**
649
         * A?ade un LegendListener a la lista de Listeners.
650
         *
651
         * @param listener LegendListener.
652
         */
653
        public void addLegendListener(LegendListener listener) {
654
                layerChangeSupport.addLayerListener(listener);
655
        }
656

    
657
        /**
658
         * Llamada al m?todo callLegendChanged de los listener.
659
         *
660
         * @param e Evento.
661
         */
662
        private void callLegendChanged(LegendChangedEvent e) {
663
                layerChangeSupport.callLegendChanged(e);
664
        }
665

    
666
        /**
667
         * Borra un LegendListener de la lista de Listeners
668
         *
669
         * @param listener LegendListener.
670
         */
671
        public void removeLegendListener(LegendListener listener) {
672
                layerChangeSupport.removeLayerListener(listener);
673
        }
674

    
675
        /**
676
         * Sobreimplementaci?n del m?todo toString para que las bases de datos
677
         * identifiquen la capa.
678
         *
679
         * @return DOCUMENT ME!
680
         */
681
        public String toString() {
682
                /*
683
                 * Se usa internamente para que la parte de datos
684
                 * identifique de forma un?voca las tablas
685
                 */
686
                String ret = super.toString();
687

    
688
                return "layer" + ret.substring(ret.indexOf('@') + 1);
689
        }
690

    
691
    public boolean isJoined() {
692
        return bHasJoin;
693
    }
694

    
695
    public void setIsJoined(boolean hasJoin) {
696
        bHasJoin = hasJoin;
697
    }
698
}