Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / AnnotationEditableAdapter.java @ 6212

History | View | Annotate | Download (20.4 KB)

1
package com.iver.cit.gvsig.fmap.edition;
2

    
3
import java.awt.Color;
4
import java.awt.Font;
5
import java.awt.geom.Point2D;
6
import java.awt.geom.Rectangle2D;
7
import java.io.IOException;
8
import java.util.ArrayList;
9
import java.util.List;
10

    
11
import com.hardcode.gdbms.engine.values.DoubleValue;
12
import com.hardcode.gdbms.engine.values.IntValue;
13
import com.hardcode.gdbms.engine.values.NumericValue;
14
import com.hardcode.gdbms.engine.values.StringValue;
15
import com.hardcode.gdbms.engine.values.Value;
16
import com.hardcode.gdbms.engine.values.ValueFactory;
17
import com.iver.cit.gvsig.fmap.DriverException;
18
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
19
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
20
import com.iver.cit.gvsig.fmap.core.IFeature;
21
import com.iver.cit.gvsig.fmap.core.IGeometry;
22
import com.iver.cit.gvsig.fmap.core.IRow;
23
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
24
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
25
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
26
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
27
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
28
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
29
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
30
import com.iver.cit.gvsig.fmap.layers.FBitSet;
31
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
32
import com.iver.cit.gvsig.fmap.layers.MappingAnnotation;
33
import com.iver.cit.gvsig.fmap.operations.strategies.AnnotationStrategy;
34
import com.iver.cit.gvsig.fmap.rendering.Legend;
35
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
36
import com.vividsolutions.jts.geom.Envelope;
37
import com.vividsolutions.jts.index.quadtree.Quadtree;
38

    
39
public class AnnotationEditableAdapter extends VectorialEditableAdapter{
40
        private ArrayList labels;
41
        private MappingAnnotation mapping;
42
        private Legend legend;
43
        private boolean isInPixels=true;
44
        private FLyrAnnotation lyrAnnotation;
45
        private LabelExpansion labelExpansion=new LabelExpansion();
46

    
47
        public FLabel createLabel(IRow row){
48
                FSymbol symbol;
49
                // El mapping[0] es el text
50
                int fieldId = mapping.getColumnText();
51
                // El mapping[1] es el ?ngulo
52
                int idFieldRotationText = mapping.getColumnRotate();
53
                // El mapping[2] es el color
54
                int idFieldColorText = mapping.getColumnColor();
55
                // El mapping[3] es el alto
56
                int idFieldHeightText = mapping.getColumnHeight();
57
                // El mapping[4] es el tipo de fuente
58
                int idFieldTypeFontText = mapping.getColumnTypeFont();
59
                // El mapping[5] es el estilo de fuente
60
                int idFieldStyleFontText = mapping.getColumnStyleFont();
61

    
62
                IGeometry geom = ((IFeature) row).getGeometry();
63
                String t = new String();
64
                Value val = row.getAttribute(fieldId);
65
                t = val.toString();
66
                if (idFieldColorText != -1) {
67
                        DoubleValue valColor = (DoubleValue) row
68
                                        .getAttribute(idFieldColorText);
69
                        t = t.concat(valColor.toString());
70
                }
71
                if (idFieldTypeFontText != -1) {
72
                        StringValue valTypeFont = (StringValue) row
73
                                        .getAttribute(idFieldTypeFontText);
74
                        t = t.concat(valTypeFont.toString());
75
                }
76
                if (idFieldStyleFontText != -1) {
77
                        IntValue valStyleFont = (IntValue) row
78
                                        .getAttribute(idFieldStyleFontText);
79
                        t = t.concat(valStyleFont.toString());
80
                }
81

    
82
                Value total = ValueFactory.createValue(t);
83

    
84
                FLabel[] lbls = geom.createLabels(0, true);
85
                for (int j = 0; j < lbls.length; j++) {
86
                        if (lbls[j] != null) {
87
                                lbls[j].setString(val.toString());
88
                                if (idFieldRotationText != -1) {
89
                                        DoubleValue rotation = (DoubleValue) row
90
                                                        .getAttribute(idFieldRotationText);
91
                                        lbls[j].setRotation(rotation.getValue());
92
                                } else {
93
                                        lbls[j]
94
                                                        .setRotation(legend.getDefaultSymbol()
95
                                                                        .getRotation());
96
                                }
97

    
98
                                float height;
99
                                if (idFieldHeightText != -1) {
100
                                        NumericValue h = (NumericValue) row
101
                                                        .getAttribute(idFieldHeightText);
102
                                        height = h.floatValue();
103
                                        lbls[j].setHeight(height);
104
                                } else {
105
                                        height = legend.getDefaultSymbol().getFontSize();
106
                                        lbls[j].setHeight(height);
107
                                }
108
                                VectorialUniqueValueLegend vuvl = (VectorialUniqueValueLegend) legend;
109
                                if (vuvl.getSymbolByValue(total) == null) {
110
                                        Color color;
111
                                        if (idFieldColorText != -1) {
112
                                                DoubleValue c = (DoubleValue) row
113
                                                                .getAttribute(idFieldColorText);
114
                                                color = new Color((int) c.getValue());
115
                                        } else {
116
                                                color = legend.getDefaultSymbol().getFontColor();
117
                                        }
118
                                        String typeFont;
119
                                        if (idFieldTypeFontText != -1) {
120
                                                StringValue tf = (StringValue) row
121
                                                                .getAttribute(idFieldTypeFontText);
122
                                                typeFont = tf.getValue();
123
                                        } else {
124
                                                typeFont = legend.getDefaultSymbol().getFont()
125
                                                                .getFontName();
126
                                        }
127
                                        int style;
128
                                        if (idFieldStyleFontText != -1) {
129
                                                IntValue sf = (IntValue) row
130
                                                                .getAttribute(idFieldStyleFontText);
131
                                                style = sf.getValue();
132
                                        } else {
133
                                                style = legend.getDefaultSymbol().getFont().getStyle();
134
                                        }
135
                                        symbol = new FSymbol(FConstant.SYMBOL_TYPE_TEXT);
136
                                        symbol.setFontSizeInPixels(isInPixels);
137
                                        symbol.setFont(new Font(typeFont, style, (int) height));
138
                                        symbol.setDescription(lbls[j].getString());
139
                                        symbol.setFontColor(color);
140
                                        vuvl.addSymbol(total, symbol);
141
                                }
142

    
143
                        }
144
                        return lbls[0];
145
                }
146
                return null;
147
        }
148

    
149

    
150

    
151

    
152
        public int doAddRow(IRow feat, int sourceType) throws DriverIOException, IOException {
153
                boolean cancel = fireBeforeRowAdded(sourceType);
154
                if (cancel)
155
                        return -1;
156
                Value[] values=feat.getAttributes();
157
                values[mapping.getColumnText()]=ValueFactory.createValue("New");
158
                FLabel label=createLabel(feat);
159
                //Rectangle2D r=((DefaultFeature)feat).getGeometry().getBounds2D();
160
                //r.setRect(r.getX()-r.getWidth()*4,r.getY()-r.getHeight()*4,r.getWidth()*10,r.getHeight()*4);
161
                //label.setBoundBox(r);
162
                AnnotationStrategy strategy = (AnnotationStrategy)lyrAnnotation.getStrategy();
163
                Rectangle2D r=strategy.getBoundBox(label.getOrig(),(float)label.getHeight(),label.getJustification(),label.getString());
164
        label.setBoundBox(r);
165
                IGeometry geom=getGeometry(label.getBoundBox());
166
                feat=new DefaultFeature(geom,values,feat.getID());
167

    
168
                ///lyrAnnotation.deleteSpatialIndex();
169

    
170
                int calculatedIndex = -1;
171
                calculatedIndex = (int) getRowCount()+delRows.cardinality() ;
172

    
173
                int pos = expansionFile.addRow(feat, IRowEdited.STATUS_ADDED, actualIndexFields);
174
                labelExpansion.addLabel(label);
175
                relations.put(new Integer(calculatedIndex), new Integer(pos));
176
                numAdd++;
177

    
178
                index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(),
179
                r.getY() + r.getHeight()), new Integer(calculatedIndex));
180
        //lyrAnnotation.getFMap().invalidate();
181
        fireAfterRowAdded(calculatedIndex, sourceType);
182
        return calculatedIndex;
183
        }
184

    
185
        public int doModifyRow(int calculatedIndex, IRow feat,int sourceType) throws IOException, DriverIOException {
186
                boolean cancel = fireBeforeModifyRow(feat,calculatedIndex, sourceType);
187
                if (cancel)
188
                        return -1;
189
                int posAnteriorInExpansionFile = -1;
190
                Integer integer = new Integer(calculatedIndex);
191

    
192
                System.err.println("Modifica una Row en la posici?n: "
193
                                + calculatedIndex);
194
                // Si la geometr?a no ha sido modificada
195
                if (!relations.containsKey(integer)) {
196
                        FLabel label=(FLabel)getLabel(calculatedIndex,true).clone();
197
                        Value value=feat.getAttribute(mapping.getColumnText());
198
                        Rectangle2D rLabelAnt=(Rectangle2D)label.getBoundBox().clone();
199
                        label.setString(value.toString());
200

    
201
                        if (mapping.getColumnRotate()==mapping.getColumnText()){
202
                                label.setRotation(((NumericValue)value).doubleValue());
203
                        } //Aqu? hay que comprobar, si se quiere, el resto de columnas, si son iguales a la de Texto.
204

    
205

    
206
                        int newPosition = expansionFile.addRow(feat, IRowEdited.STATUS_MODIFIED, actualIndexFields);
207
                        relations.put(integer, new Integer(newPosition));
208

    
209
                        // Se actualiza el ?ndice espacial
210
                        IGeometry g=((IFeature) feat).getGeometry();
211
                        double[] d=new double[4];
212
                        //Rectangle2D r = g.getBounds2D();
213
                        g.getPathIterator(null).currentSegment(d);
214
                        Point2D p=new Point2D.Double(d[0],d[1]);
215
                        label.setBoundBox(new Rectangle2D.Double(p.getX(),p.getY(),rLabelAnt.getWidth(),rLabelAnt.getHeight()));
216
                        Rectangle2D rLabel=(Rectangle2D)label.getBoundBox();
217
                        label.setOrig(p);
218
                        index.remove(new Envelope(rLabelAnt.getX(), rLabelAnt.getX()
219
                                        + rLabelAnt.getWidth(), rLabelAnt.getY(), rLabelAnt.getY()
220
                                        + rLabelAnt.getHeight()), new Integer(calculatedIndex));
221
                        index.insert(new Envelope(rLabel.getX(), rLabel.getX() + rLabel.getWidth(), rLabel
222
                                        .getY(), rLabel.getY() + rLabel.getHeight()), new Integer(
223
                                        calculatedIndex));
224
                        labelExpansion.addLabel(label);
225
                } else {
226
                        FLabel label=(FLabel)labelExpansion.getLabel(((Integer)relations.get(new Integer(calculatedIndex))).intValue()).clone();
227
                        Value value=feat.getAttribute(mapping.getColumnText());
228
                        Rectangle2D rLabelAnt=(Rectangle2D)label.getBoundBox().clone();
229
                        label.setString(value.toString());
230

    
231
                        if (mapping.getColumnRotate()==mapping.getColumnText()){
232
                                label.setRotation(((NumericValue)value).doubleValue());
233
                        } //Aqu? hay que comprobar, si se quiere, el resto de columnas, si son iguales a la de Texto.
234

    
235

    
236
                        // Obtenemos el ?ndice en el fichero de expansi?n
237
                        int num = ((Integer) relations.get(integer)).intValue();
238
                        posAnteriorInExpansionFile = num;
239

    
240
                        /*
241
                         * Se modifica la geometr?a y nos guardamos el ?ndice dentro del
242
                         * fichero de expansi?n en el que se encuentra la geometr?a
243
                         * modificada
244
                         */
245
                        num = expansionFile.modifyRow(num, feat, actualIndexFields);
246

    
247
                        /*
248
                         * Actualiza la relaci?n del ?ndice de la geometr?a al ?ndice en el
249
                         * fichero de expansi?n.
250
                         */
251
                        relations.put(integer, new Integer(num));
252

    
253
                        Rectangle2D r = ((IFeature) feat).getGeometry().getBounds2D();
254

    
255
                        Point2D p=new Point2D.Double(r.getX(),r.getY());
256

    
257
                        label.setBoundBox(new Rectangle2D.Double(p.getX(),p.getY()+rLabelAnt.getHeight(),rLabelAnt.getWidth(),rLabelAnt.getHeight()));
258
                        Rectangle2D rLabel=(Rectangle2D)label.getBoundBox();
259
                        label.setOrig(p);
260
                        index.remove(new Envelope(rLabelAnt.getX(), rLabelAnt.getX()
261
                                        + rLabelAnt.getWidth(), rLabelAnt.getY(), rLabelAnt.getY()
262
                                        + rLabelAnt.getHeight()), new Integer(calculatedIndex));
263
                        index.insert(new Envelope(rLabel.getX(), rLabel.getX() + rLabel.getWidth(), rLabel
264
                                        .getY(), rLabel.getY() + rLabel.getHeight()), new Integer(
265
                                        calculatedIndex));
266
                        labelExpansion.modifyLabel(num,label);
267
                }
268
                fireAfterModifyRow(calculatedIndex,sourceType);
269
                return posAnteriorInExpansionFile;
270
        }
271

    
272
        public IRow doRemoveRow(int index,int sourceType) throws DriverIOException, IOException {
273
                boolean cancel = fireBeforeRemoveRow(index, sourceType);
274
                if (cancel)
275
                        return null;
276
                //Llega el calculatedIndex
277
            Integer integer = new Integer(index);
278

    
279
        IFeature feat = null;
280

    
281
        FLabel label=getLabel(index,true);
282
        delRows.set(index, true);
283
        //Si la geometr?a no ha sido modificada
284
        if (!relations.containsKey(integer)) {
285

    
286
            try {
287
                                feat = (DefaultFeature) (ova.getFeature(index));
288
                        } catch (DriverException e) {
289
                                throw new DriverIOException(e);
290
                        }
291
       } else {
292
                        int num = ((Integer) relations.get(integer)).intValue();
293
                        feat = (IFeature) expansionFile.getRow(num).getLinkedRow();
294
                }
295
        System.err.println("Elimina una Row en la posici?n: " + index);
296
        //Se actualiza el ?ndice
297
        if (feat != null) {
298
            Rectangle2D r = label.getBoundBox();
299
            this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(),
300
                    r.getY(), r.getY() + r.getHeight()), new Integer(index));
301
        }
302
        setSelection(new FBitSet());
303
        fireAfterRemoveRow(index, sourceType);
304
        return feat;
305
        }
306

    
307
        public void undoAddRow(int calculatedIndex, int sourceType) throws DriverIOException, IOException {
308
                boolean cancel = fireBeforeRemoveRow(calculatedIndex, sourceType);
309
                if (cancel)
310
                        return;
311
                Rectangle2D r = getLabel(calculatedIndex,true).getBoundBox();
312
        this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(),
313
                r.getY(), r.getY() + r.getHeight()), new Integer(calculatedIndex));
314
        expansionFile.deleteLastRow();
315
                relations.remove(new Integer(calculatedIndex));
316
                numAdd--;
317
        setSelection(new FBitSet());
318
                labelExpansion.deleteLastLabel();
319
                fireAfterRemoveRow(calculatedIndex, sourceType);
320
        }
321

    
322
        public void undoModifyRow(int calculatedIndex, int previousExpansionFileIndex, int sourceType) throws IOException, DriverIOException {
323

    
324
                if (previousExpansionFileIndex == -1) {
325
                    //Se obtiene la geometr?a para actualizar el ?ndice
326
                        int inverse = getInversedIndex(calculatedIndex);
327
                        DefaultFeature df=(DefaultFeature)getRow(inverse).getLinkedRow();
328

    
329

    
330
                        IGeometry g = df.getGeometry();
331
                    Rectangle2D r = g.getBounds2D();
332
                    //Se elimina de las relaciones y del fichero de expansi?n
333
                    relations.remove(new Integer(calculatedIndex));
334
                    expansionFile.deleteLastRow();
335
                    labelExpansion.deleteLastLabel();
336
                    //Se actualizan los ?ndices
337
                    DefaultFeature dfAnt=(DefaultFeature)getRow(inverse).getLinkedRow();
338
                    IGeometry gAnt = dfAnt.getGeometry();
339
                    boolean cancel = fireBeforeModifyRow(dfAnt,calculatedIndex, sourceType);
340
                            if (cancel)
341
                                    return;
342
                    Rectangle2D rAnt = gAnt.getBounds2D();
343
                    this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(),
344
                            r.getY(), r.getY() + r.getHeight()),
345
                        new Integer(calculatedIndex));
346
                    this.index.insert(new Envelope(rAnt.getX(),
347
                            rAnt.getX() + rAnt.getWidth(), rAnt.getY(),
348
                            rAnt.getY() + rAnt.getHeight()), new Integer(calculatedIndex));
349

    
350

    
351
                } else {
352
                    //Se obtiene la geometr?a para actualizar el ?ndice
353
                    IGeometry g = null;
354
                    int inverse = getInversedIndex(calculatedIndex);
355
                    DefaultFeature df=(DefaultFeature)getRow(inverse).getLinkedRow();
356
                    g = df.getGeometry();
357
                    Rectangle2D r = g.getBounds2D();
358
                    this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(),
359
                            r.getY(), r.getY() + r.getHeight()),
360
                        new Integer(calculatedIndex));
361

    
362
                    //Se actualiza la relaci?n de ?ndices
363
                    relations.put(new Integer(calculatedIndex),
364
                        new Integer(previousExpansionFileIndex));
365

    
366
                    //Se actualizan los ?ndices
367
                    df=(DefaultFeature)getRow(inverse).getLinkedRow();
368
                    boolean cancel = fireBeforeModifyRow(df,calculatedIndex, sourceType);
369
                            if (cancel)
370
                                    return;
371
                    g = df.getGeometry();
372
                    r = g.getBounds2D();
373
                    this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(),
374
                            r.getY(), r.getY() + r.getHeight()),
375
                        new Integer(calculatedIndex));
376
                    Value value=df.getAttribute(mapping.getColumnText());
377
                            FLabel label= getLabel(inverse,true);
378
                            label.setString(value.toString());
379
                            if (mapping.getColumnRotate()==mapping.getColumnText()){
380
                                    label.setRotation(((NumericValue)value).doubleValue());
381
                            }
382
                }
383
                fireAfterModifyRow(calculatedIndex, sourceType);
384
        }
385

    
386
        public void undoRemoveRow(int index, int sourceType) throws IOException, DriverIOException {
387
                boolean cancel = fireBeforeRowAdded(sourceType);
388
                if (cancel)
389
                        return;
390
                delRows.set(index, false);
391
            Rectangle2D r = getLabel(index,true).getBoundBox();
392
            this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(),
393
                        r.getY(), r.getY() + r.getHeight()), new Integer(index));
394
            fireAfterRowAdded(index, sourceType);
395
        }
396

    
397
        public AnnotationEditableAdapter(FLyrAnnotation lyrAnnotation) {
398
                super();
399
                this.labels=lyrAnnotation.getLabels();
400
                this.mapping=lyrAnnotation.getMapping();
401
                this.legend=lyrAnnotation.getLegend();
402
                this.isInPixels=lyrAnnotation.isInPixels();
403
                this.lyrAnnotation=lyrAnnotation;
404
        }
405
        public IRowEdited[] getFeatures(Rectangle2D r, String strEPSG) throws DriverException {
406
                // En esta clase suponemos random access.
407
                // Luego tendremos otra clase que sea VectorialEditableDBAdapter
408
                // que reescribir? este m?todo.
409
        Envelope e = FConverter.convertRectangle2DtoEnvelope(r);
410
        List l = index.query(e);
411
        IRowEdited[] feats = new IRowEdited[l.size()];
412
        try {
413
                for (int index = 0; index < l.size(); index++) {
414
                    Integer i = (Integer) l.get(index);
415
                    int inverse = getInversedIndex(i.intValue());
416
                                feats[index] = (IRowEdited) getRow(inverse);
417
                }
418
                } catch (DriverIOException e1) {
419
                        throw new DriverException(e1);
420
                } catch (IOException e1) {
421
                        throw new DriverException(e1);
422
                }
423

    
424
                return feats;
425
        }
426
         /* (non-Javadoc)
427
     * @see com.iver.cit.gvsig.fmap.edition.IEditableSource#getRow(int)
428
     */
429
    public IRowEdited getRow(int index) throws DriverIOException, IOException {
430
            int calculatedIndex=getCalculatedIndex(index);
431
            Integer integer = new Integer(calculatedIndex);
432
        //Si no est? en el fichero de expansi?n
433
            DefaultRowEdited edRow=null;
434

    
435
            if (!relations.containsKey(integer)) {
436
                        try {
437
                                IFeature f=ova.getFeature(calculatedIndex);
438
                                String s=f.getID();
439
                                FLabel label=getLabel(index,false);
440
                                if (label==null)
441
                                        return null;
442
                                IGeometry geom=getGeometry(label.getBoundBox());
443
                                f=new DefaultFeature(geom,f.getAttributes(),s);
444
                                //f.setID(s);
445
                                edRow = new DefaultRowEdited(f,
446
                                        DefaultRowEdited.STATUS_ORIGINAL, index);
447
                        } catch (DriverException e) {
448
                                throw new DriverIOException(e);
449
                        }
450

    
451
            return edRow;
452
        } else {
453
            int num = ((Integer) relations.get(integer)).intValue();
454
            IRowEdited aux = expansionFile.getRow(num);
455
            IFeature f=(IFeature)aux.getLinkedRow().cloneRow();
456
            IGeometry geom=getGeometry(labelExpansion.getLabel(num).getBoundBox());
457
            String s=f.getID();
458
            f=new DefaultFeature(geom,f.getAttributes(),s);
459
            //f.setID(s);
460
            edRow = new DefaultRowEdited(f, aux.getStatus(), index);
461
            return edRow;
462
        }
463
    }
464
    private IGeometry getGeometry(Rectangle2D r){
465
            GeneralPathX resul = new GeneralPathX();
466
                Point2D[] vs=new Point2D[4];
467
                vs[0]=new Point2D.Double(r.getX(),r.getY());
468
            vs[1]=new Point2D.Double(r.getMaxX(),r.getY());
469
            vs[2]=new Point2D.Double(r.getMaxX(),r.getMaxY());
470
            vs[3]=new Point2D.Double(r.getX(),r.getMaxY());
471
            //vs[4]=new Point2D.Double(r.getX(),r.getY());
472
                for (int i = 0; i < vs.length; i++) {
473
                        if (i == 0) {
474
                                resul.moveTo(vs[i].getX(),vs[i].getY());
475
                        } else {
476
                                resul.lineTo(vs[i].getX(),vs[i].getY());
477
                        }
478
                }
479
                resul.closePath();
480
                return ShapeFactory.createPolygon2D(resul);
481
    }
482
    public void startEdition(int sourceType) throws EditionException {
483
            isEditing = true;
484
                try {
485
                        expansionFile.open();
486
                                index = new Quadtree();
487

    
488
                                for (int i = 0; i < labels.size(); i++) {
489
                                        Rectangle2D r=((FLabel)labels.get(i)).getBoundBox();
490
                                        Envelope e = new Envelope(r.getX(),
491
                                                        r.getX() + r.getWidth(), r.getY(), r.getY()
492
                                                                        + r.getHeight());
493
                                        index.insert(e, new Integer(i));
494
                                        if (fullExtent == null) {
495
                                                fullExtent = r;
496
                                        } else {
497
                                                fullExtent.add(r);
498
                                        }
499
                                }
500
                } catch (IOException e) {
501
                        throw new EditionException(e);
502
                }
503

    
504
                System.err.println("Se han metido en el ?ndice "
505
                                + index.queryAll().size() + " labels");
506
        }
507

    
508
    public Rectangle2D getShapeBounds(int index) throws IOException {
509
                //Solo se utiliza cuando el driver es BoundedShapes
510
//                 Si no est? en el fichero de expansi?n
511
                Integer integer = new Integer((int) index);
512
                if (!relations.containsKey(integer)) {
513
                        if (ova.getDriver() instanceof BoundedShapes){
514
                                BoundedShapes bs = (BoundedShapes) ova.getDriver();
515
                                return bs.getShapeBounds(index);
516
                        }else{
517
                                return ova.getDriver().getShape(index).getBounds2D();
518
                        }
519

    
520
                } else {
521
                        int num = ((Integer) relations.get(integer)).intValue();
522
                        DefaultRowEdited feat;
523
                        feat = (DefaultRowEdited) expansionFile.getRow(num);
524
                        if (feat.getStatus() == IRowEdited.STATUS_DELETED)
525
                                return null;
526
                        IGeometry geom = ((IFeature)feat.getLinkedRow()).getGeometry();
527
                        return geom.getBounds2D();
528
                }
529

    
530
        }
531
    public FLabel getLabel(int index,boolean calculated) {
532
            FLabel label=null;
533
            int calculatedIndex=index;
534
            Integer integer=new Integer(index);
535
            if (!calculated){
536
                    calculatedIndex=getCalculatedIndex(index);
537
                    integer = new Integer(calculatedIndex);
538
            }
539
            //Si no est? en el fichero de expansi?n
540
            if (!relations.containsKey(integer)) {
541
                    if (calculatedIndex > labels.size()){
542
                            return null;
543
                    }
544
                    label=(FLabel)labels.get(calculatedIndex);
545
                    return label;
546
        } else {
547
            int num = ((Integer) relations.get(integer)).intValue();
548
            label=labelExpansion.getLabel(num);
549
            return (FLabel)label;
550
        }
551
    }
552
}