Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / gui / Annotation_TaskCreate.java @ 12274

History | View | Annotate | Download (22.8 KB)

1

    
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

    
43
package com.iver.cit.gvsig.project.documents.gui;
44

    
45
import java.awt.geom.Point2D;
46
import java.awt.geom.Rectangle2D;
47
import java.sql.Types;
48
import java.text.ParseException;
49
import java.util.HashMap;
50
import java.util.Iterator;
51

    
52
import javax.swing.JComponent;
53
import javax.swing.JOptionPane;
54

    
55
import org.cresques.cts.ICoordTrans;
56

    
57
import com.hardcode.driverManager.Driver;
58
import com.hardcode.gdbms.engine.data.driver.DriverException;
59
import com.hardcode.gdbms.engine.values.NumericValue;
60
import com.hardcode.gdbms.engine.values.Value;
61
import com.hardcode.gdbms.engine.values.ValueFactory;
62
import com.iver.andami.PluginServices;
63
import com.iver.cit.gvsig.fmap.MapContext;
64
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
65
import com.iver.cit.gvsig.fmap.core.FShape;
66
import com.iver.cit.gvsig.fmap.core.IFeature;
67
import com.iver.cit.gvsig.fmap.core.IGeometry;
68
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
69
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
70
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
71
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
72
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
73
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition;
74
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
75
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited;
76
import com.iver.cit.gvsig.fmap.edition.EditionException;
77
import com.iver.cit.gvsig.fmap.edition.IWriter;
78
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer;
79
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping;
80
import com.iver.cit.gvsig.fmap.layers.FBitSet;
81
import com.iver.cit.gvsig.fmap.layers.FLayer;
82
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
83
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
84
import com.iver.cit.gvsig.fmap.layers.LayerListener;
85
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
86
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
87
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
88
import com.iver.utiles.PostProcessSupport;
89
import com.iver.utiles.swing.threads.AbstractMonitorableTask;
90

    
91

    
92
/**
93
 * Task to create the annotation layer.
94
 *
95
 * @author Vicente Caballero Navarro
96
 */
97
public class Annotation_TaskCreate extends AbstractMonitorableTask {
98
    Annotation_Layer lyrVect;
99
    IWriter writer;
100
    int rowCount;
101
    ReadableVectorial va;
102
    SelectableDataSource sds;
103
    FBitSet bitSet;
104
    MapContext mapContext;
105
    VectorialDriver reader;
106
    private Annotation_Mapping mapping;
107
    private String duplicate;
108
    private HashMap mapGeom = new HashMap();
109
    private HashMap mapAttri = new HashMap();
110

    
111
    public Annotation_TaskCreate(MapContext mapContext, Annotation_Layer lyr,
112
        IWriter writer, Driver reader, String duplicate)
113
        throws DriverIOException, com.iver.cit.gvsig.fmap.DriverException {
114
        this.duplicate = duplicate;
115
        this.mapping = lyr.getAnnotatonMapping();
116
        this.mapContext = mapContext;
117
        this.lyrVect = lyr;
118
        this.writer = writer;
119
        this.reader = (VectorialDriver) reader;
120

    
121
        setInitialStep(0);
122
        setDeterminatedProcess(true);
123
        setStatusMessage(PluginServices.getText(this, "exporting_") + ": " +
124
            PluginServices.getText(this, "annotations"));
125

    
126
        va = lyrVect.getSource();
127
        sds = lyrVect.getRecordset();
128

    
129
        bitSet = sds.getSelection();
130

    
131
        if (bitSet.cardinality() == 0) {
132
            rowCount = va.getShapeCount();
133
        } else {
134
            rowCount = bitSet.cardinality();
135
        }
136

    
137
        setFinalStep(rowCount);
138
    }
139

    
140
    /**
141
     * DOCUMENT ME!
142
     *
143
     * @throws Exception DOCUMENT ME!
144
     */
145
    public void run() throws Exception {
146
        if (duplicate.equals(PluginServices.getText(this, "centered"))) {
147
            duplicate();
148
        }
149

    
150
        // va.start();
151
        ICoordTrans ct = lyrVect.getCoordTrans();
152
        DriverAttributes attr = va.getDriverAttributes();
153
        boolean bMustClone = false;
154

    
155
        if (attr != null) {
156
            if (attr.isLoadedInMemory()) {
157
                bMustClone = attr.isLoadedInMemory();
158
            }
159
        }
160

    
161
        SHPLayerDefinition lyrDef = (SHPLayerDefinition) writer.getTableDefinition();
162
        lyrDef.setShapeType(FShape.POINT);
163

    
164
        FieldDescription[] fields = getFieldDescriptions();
165
        lyrDef.setFieldsDesc(fields);
166
        writer.initialize(lyrDef);
167

    
168
        // Creamos la tabla.
169
        writer.preProcess();
170

    
171
        if (duplicate.equals(PluginServices.getText(this, "centered"))) {
172
            int pos = 0;
173
            Iterator iter = mapGeom.keySet().iterator();
174

    
175
            while (iter.hasNext()) {
176
                String textValue = (String) iter.next();
177
                Rectangle2D rectangle = (Rectangle2D) mapGeom.get(textValue);
178
                IGeometry geom = ShapeFactory.createPoint2D(rectangle.getCenterX(),
179
                        rectangle.getCenterY());
180

    
181
                if (ct != null) {
182
                    if (bMustClone) {
183
                        geom = geom.cloneGeometry();
184
                    }
185

    
186
                    geom.reProject(ct);
187
                }
188

    
189
                reportStep();
190
                setNote(PluginServices.getText(this, "exporting_") + " " + pos +
191
                    "    " + mapGeom.size());
192

    
193
                Value[] values = (Value[]) mapAttri.get(textValue);
194
                IFeature feat = new DefaultFeature(geom, values, "" + pos);
195
                DefaultRowEdited edRow = new DefaultRowEdited(feat,
196
                        DefaultRowEdited.STATUS_ADDED, pos);
197
                writer.process(edRow);
198
                pos++;
199
            }
200
        } else if (duplicate.equals(PluginServices.getText(this, "duplicate.none"))) {
201
            va.start();
202

    
203
            if (bitSet.cardinality() == 0) {
204
                rowCount = va.getShapeCount();
205

    
206
                for (int i = 0; i < rowCount; i++) {
207
                    IGeometry geom = va.getShape(i);
208

    
209
                    if (geom.getGeometryType() != FShape.POINT) {
210
                        Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
211
                        geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
212
                    }
213

    
214
                    if (ct != null) {
215
                        if (bMustClone) {
216
                            geom = geom.cloneGeometry();
217
                        }
218

    
219
                        geom.reProject(ct);
220
                    }
221

    
222
                    reportStep();
223
                    setNote(PluginServices.getText(this, "exporting_") + " " +
224
                        i + "    " + rowCount);
225

    
226
                    if (isCanceled()) {
227
                        break;
228
                    }
229

    
230
                    if (geom != null) {
231
                        Value[] valuesAnnotation = getValuesAnnotation(i);
232

    
233
                        IFeature feat = new DefaultFeature(geom,
234
                                valuesAnnotation, "" + i);
235
                        DefaultRowEdited edRow = new DefaultRowEdited(feat,
236
                                DefaultRowEdited.STATUS_ADDED, i);
237
                        writer.process(edRow);
238
                    }
239
                }
240
            } else {
241
                int counter = 0;
242

    
243
                for (int i = bitSet.nextSetBit(0); i >= 0;
244
                        i = bitSet.nextSetBit(i + 1)) {
245
                    IGeometry geom = va.getShape(i);
246

    
247
                    if (geom.getGeometryType() != FShape.POINT) {
248
                        Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
249
                        geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
250
                    }
251

    
252
                    if (ct != null) {
253
                        if (bMustClone) {
254
                            geom = geom.cloneGeometry();
255
                        }
256

    
257
                        geom.reProject(ct);
258
                    }
259

    
260
                    reportStep();
261
                    setNote(PluginServices.getText(this, "exporting_") + " " +
262
                        counter + "    " + bitSet.cardinality());
263

    
264
                    if (isCanceled()) {
265
                        break;
266
                    }
267

    
268
                    if (geom != null) {
269
                        Value[] valuesAnnotation = getValuesAnnotation(i);
270
                        IFeature feat = new DefaultFeature(geom,
271
                                valuesAnnotation, "" + i);
272
                        DefaultRowEdited edRow = new DefaultRowEdited(feat,
273
                                DefaultRowEdited.STATUS_ADDED, i);
274

    
275
                        writer.process(edRow);
276
                    }
277

    
278
                    va.stop();
279
                }
280
            }
281
        }
282

    
283
        writer.postProcess();
284

    
285
        //
286
        // if (bitSet.cardinality() == 0) {
287
        // rowCount = va.getShapeCount();
288
        //
289
        // for (int i = 0; i < rowCount; i++) {
290
        // IGeometry geom = va.getShape(i);
291
        //
292
        // if (geom.getGeometryType() != FShape.POINT) {
293
        // Point2D p = FLabel.createLabelPoint((FShape)
294
        // geom.getInternalShape());
295
        // geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
296
        // }
297
        //
298
        // if (ct != null) {
299
        // if (bMustClone) {
300
        // geom = geom.cloneGeometry();
301
        // }
302
        //
303
        // geom.reProject(ct);
304
        // }
305
        //
306
        // reportStep();
307
        // setNote(PluginServices.getText(this, "exporting_") +" "+ i+ "
308
        // "+rowCount);
309
        //
310
        // if (isCanceled()) {
311
        // break;
312
        // }
313
        //
314
        // if (geom != null) {
315
        // Value[] valuesAnnotation = getValuesAnnotation(i);
316
        //
317
        // IFeature feat = new DefaultFeature(geom, valuesAnnotation,
318
        // "" + i);
319
        // DefaultRowEdited edRow = new DefaultRowEdited(feat,
320
        // DefaultRowEdited.STATUS_ADDED, i);
321
        // writer.process(edRow);
322
        // }
323
        // }
324
        // } else {
325
        // int counter = 0;
326
        //
327
        // for (int i = bitSet.nextSetBit(0); i >= 0;
328
        // i = bitSet.nextSetBit(i + 1)) {
329
        // IGeometry geom = va.getShape(i);
330
        //
331
        // if (geom.getGeometryType() != FShape.POINT) {
332
        // Point2D p = FLabel.createLabelPoint((FShape)
333
        // geom.getInternalShape());
334
        // geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
335
        // }
336
        //
337
        // if (ct != null) {
338
        // if (bMustClone) {
339
        // geom = geom.cloneGeometry();
340
        // }
341
        //
342
        // geom.reProject(ct);
343
        // }
344
        //
345
        // reportStep();
346
        // setNote(PluginServices.getText(this, "exporting_") +" "+ counter+ "
347
        // "+bitSet.cardinality());
348
        //
349
        // if (isCanceled()) {
350
        // break;
351
        // }
352
        //
353
        // if (geom != null) {
354
        // Value[] valuesAnnotation = getValuesAnnotation(i);
355
        // IFeature feat = new DefaultFeature(geom, valuesAnnotation,
356
        // "" + i);
357
        // DefaultRowEdited edRow = new DefaultRowEdited(feat,
358
        // DefaultRowEdited.STATUS_ADDED, i);
359
        //
360
        // writer.process(edRow);
361
        // }
362
        // }
363
        // }
364
        //
365
        // writer.postProcess();
366
        // va.stop();
367
        mapAttri.clear();
368
        mapGeom.clear();
369

    
370
        if (reader != null) {
371
            int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager()
372
                                                                               .getActiveWindow(),
373
                    PluginServices.getText(this,
374
                        "insertar_en_la_vista_la_capa_creada"),
375
                    PluginServices.getText(this, "insertar_capa"),
376
                    JOptionPane.YES_NO_OPTION);
377

    
378
            if (res == JOptionPane.YES_OPTION) {
379
                PostProcessSupport.executeCalls();
380
                lyrDef = (SHPLayerDefinition) writer.getTableDefinition();
381

    
382
                FLayer newLayer = LayerFactory.createLayer(lyrDef.getName(),
383
                        reader, mapContext.getProjection());
384

    
385
                Annotation_Layer la = new Annotation_Layer();
386
                LayerListener[] layerListeners = newLayer.getLayerListeners();
387

    
388
                for (int i = 0; i < layerListeners.length; i++) {
389
                    la.addLayerListener(layerListeners[i]);
390
                }
391

    
392
                la.setSource(((FLyrVect) newLayer).getSource());
393
                la.setProjection(newLayer.getProjection());
394
                la.setName(newLayer.getName());
395
                la.setLegend((VectorialLegend) lyrVect.getLegend());
396
                Annotation_Mapping.addAnnotationMapping(la);
397
                mapContext.getLayers().addLayer(la);
398
            }
399
        }
400
    }
401

    
402
    /**
403
     * DOCUMENT ME!
404
     *
405
     * @return DOCUMENT ME!
406
     */
407
    private FieldDescription[] getFieldDescriptions() {
408
        SHPLayerDefinition lyrDef = (SHPLayerDefinition) writer.getTableDefinition();
409
        FieldDescription[] fields = new FieldDescription[Annotation_Mapping.NUMCOLUMNS]; // lyrDef.getFieldsDesc();
410

    
411
        int posText = mapping.getColumnText();
412
        int posTypeFont = mapping.getColumnTypeFont();
413
        int posStyleFont = mapping.getColumnStyleFont();
414
        int posColor = mapping.getColumnColor();
415
        int posHeight = mapping.getColumnHeight();
416
        int posRotate = mapping.getColumnRotate();
417

    
418
        FieldDescription[] fieldsDescriptions = lyrDef.getFieldsDesc();
419
        setField(Annotation_Mapping.TEXT, fieldsDescriptions, fields, posText, 0);
420
        setField(Annotation_Mapping.TYPEFONT, fieldsDescriptions, fields,
421
            posTypeFont, 1);
422
        setField(Annotation_Mapping.STYLEFONT, fieldsDescriptions, fields,
423
            posStyleFont, 2);
424
        setField(Annotation_Mapping.COLOR, fieldsDescriptions, fields,
425
            posColor, 3);
426
        setField(Annotation_Mapping.HEIGHT, fieldsDescriptions, fields,
427
            posHeight, 4);
428
        setField(Annotation_Mapping.ROTATE, fieldsDescriptions, fields,
429
            posRotate, 5);
430

    
431
        return fields;
432
    }
433

    
434
    /**
435
     * DOCUMENT ME!
436
     *
437
     * @param name DOCUMENT ME!
438
     * @param antFields DOCUMENT ME!
439
     * @param fields DOCUMENT ME!
440
     * @param pos DOCUMENT ME!
441
     * @param i DOCUMENT ME!
442
     */
443
    private void setField(String name, FieldDescription[] antFields,
444
        FieldDescription[] fields, int pos, int i) {
445
        int type = Annotation_Mapping.getType(name);
446

    
447
        if (pos != -1) {
448
            fields[i] = antFields[pos];
449
        } else {
450
            fields[i] = new FieldDescription();
451

    
452
            if (type != Types.VARCHAR) {
453
                if (name.equals("Color")) {
454
                    fields[i].setFieldLength(10);
455
                }
456
            }
457

    
458
            //                        else {
459
            //                                fields[i].setFieldLength(10);
460
            //                                fields[i].setFieldDecimalCount(3);
461
            //                        }
462
        }
463

    
464
        fields[i].setFieldType(type);
465
        fields[i].setFieldName(name);
466
    }
467

    
468
    /**
469
     * DOCUMENT ME!
470
     *
471
     * @param i DOCUMENT ME!
472
     *
473
     * @return DOCUMENT ME!
474
     *
475
     * @throws DriverException DOCUMENT ME!
476
     * @throws EditionException DOCUMENT ME!
477
     */
478
    private Value[] getValuesAnnotation(int i)
479
        throws DriverException, EditionException {
480
        int posText = mapping.getColumnText();
481
        int posTypeFont = mapping.getColumnTypeFont();
482
        int posStyleFont = mapping.getColumnStyleFont();
483
        int posColor = mapping.getColumnColor();
484
        int posHeight = mapping.getColumnHeight();
485
        int posRotate = mapping.getColumnRotate();
486

    
487
        Value[] values = sds.getRow(i);
488
        Value[] valuesAnnotation = new Value[Annotation_Mapping.NUMCOLUMNS];
489

    
490
        setValue(Annotation_Mapping.TEXT, values, valuesAnnotation, posText, 0);
491
        setValue(Annotation_Mapping.TYPEFONT, values, valuesAnnotation,
492
            posTypeFont, 1);
493
        setValue(Annotation_Mapping.STYLEFONT, values, valuesAnnotation,
494
            posStyleFont, 2);
495
        setValue(Annotation_Mapping.COLOR, values, valuesAnnotation, posColor, 3);
496
        setValue(Annotation_Mapping.HEIGHT, values, valuesAnnotation,
497
            posHeight, 4);
498
        setValue(Annotation_Mapping.ROTATE, values, valuesAnnotation,
499
            posRotate, 5);
500

    
501
        return valuesAnnotation;
502
    }
503

    
504
    /**
505
     * DOCUMENT ME!
506
     *
507
     * @param name DOCUMENT ME!
508
     * @param antValues DOCUMENT ME!
509
     * @param values DOCUMENT ME!
510
     * @param pos DOCUMENT ME!
511
     * @param i DOCUMENT ME!
512
     */
513
    private void setValue(String name, Value[] antValues, Value[] values,
514
        int pos, int i) {
515
        int type = Annotation_Mapping.getType(name);
516

    
517
//        if (pos != -1) {
518
//            try {
519
//                values[i] = ValueFactory.createValueByType(antValues[pos].toString(),
520
//                        type);
521
//            } catch (ParseException e) {
522
//                e.printStackTrace();
523
//            }
524
//        } else {
525
            // if (type == Types.VARCHAR) {
526
            // values[i] = ValueFactory.createNullValue();
527
            // } else {
528
            try {
529
                if (name == Annotation_Mapping.TEXT) {
530
                        if (pos!=-1){
531
                                values[i] = ValueFactory.createValue(antValues[pos].toString());
532
                        }else{
533
                                values[i] = ValueFactory.createValueByType(String.valueOf(
534
                                Annotation_Mapping.DEFAULTTEXT), type);
535
                        }
536
                } else if (name == Annotation_Mapping.COLOR) {
537
                        if (pos!=-1){
538
                                values[i] = ValueFactory.createValue(((NumericValue)antValues[pos]).intValue());
539
                        }else{
540
                                values[i] = ValueFactory.createValueByType(String.valueOf(
541
                                Annotation_Mapping.DEFAULTCOLOR), type);
542
                        }
543
                } else if (name == Annotation_Mapping.HEIGHT) {
544
                        if (pos!=-1){
545
                                values[i] = ValueFactory.createValue(((NumericValue)antValues[pos]).intValue());
546
                        }else{
547
                                values[i] = ValueFactory.createValueByType(String.valueOf(
548
                                Annotation_Mapping.DEFAULTHEIGHT), type);
549
                        }
550
                } else if (name == Annotation_Mapping.TYPEFONT) {
551
                        if (pos!=-1){
552
                                values[i] = ValueFactory.createValue(antValues[pos].toString());
553
                        }else{
554
                                values[i] = ValueFactory.createValueByType(String.valueOf(
555
                                Annotation_Mapping.DEFAULTTYPEFONT), type);
556
                        }
557
                } else if (name == Annotation_Mapping.STYLEFONT) {
558
                        if (pos!=-1){
559
                                values[i] = ValueFactory.createValue(((NumericValue)antValues[pos]).intValue());
560
                        }else{
561
                                values[i] = ValueFactory.createValueByType(String.valueOf(
562
                                Annotation_Mapping.DEFAULTSTYLEFONT), type);
563
                        }
564
                } else if (name == Annotation_Mapping.ROTATE) {
565
                        if (pos!=-1){
566
                                values[i] = ValueFactory.createValue(((NumericValue)antValues[pos]).intValue());
567
                        }else{
568
                                values[i] = ValueFactory.createValueByType(String.valueOf(
569
                                Annotation_Mapping.DEFAULTROTATE), type);
570
                        }
571
                }
572
            } catch (ParseException e) {
573
                e.printStackTrace();
574
            }
575

    
576
            // }
577
//        }
578
    }
579

    
580
    /**
581
     * DOCUMENT ME!
582
     *
583
     * @throws DriverIOException DOCUMENT ME!
584
     * @throws DriverException DOCUMENT ME!
585
     * @throws EditionException DOCUMENT ME!
586
     */
587
    private void duplicate()
588
        throws DriverIOException, DriverException, EditionException {
589
        va.start();
590

    
591
        if (bitSet.cardinality() == 0) {
592
            rowCount = va.getShapeCount();
593

    
594
            for (int i = 0; i < rowCount; i++) {
595
                IGeometry geom = va.getShape(i);
596
                modifyMap(geom, i);
597

    
598
                // reportStep();
599
                // setNote(PluginServices.getText(this, "exporting_") +" "+ i+ "
600
                // "+rowCount);
601
                if (isCanceled()) {
602
                    break;
603
                }
604
            }
605
        } else {
606
            for (int i = bitSet.nextSetBit(0); i >= 0;
607
                    i = bitSet.nextSetBit(i + 1)) {
608
                IGeometry geom = va.getShape(i);
609
                modifyMap(geom, i);
610

    
611
                // reportStep();
612
                // setNote(PluginServices.getText(this, "exporting_") +" "+
613
                // counter+ " "+bitSet.cardinality());
614
                if (isCanceled()) {
615
                    break;
616
                }
617
            }
618
        }
619

    
620
        va.stop();
621
    }
622

    
623
    /**
624
     * DOCUMENT ME!
625
     *
626
     * @param geom DOCUMENT ME!
627
     * @param index DOCUMENT ME!
628
     *
629
     * @throws DriverException DOCUMENT ME!
630
     * @throws EditionException DOCUMENT ME!
631
     */
632
    private void modifyMap(IGeometry geom, int index)
633
        throws DriverException, EditionException {
634
        if (geom.getGeometryType() != FShape.POINT) {
635
            Point2D p = FLabel.createLabelPoint(geom.getInternalShape());
636
            geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
637
        }
638

    
639
        if (geom != null) {
640
            Value[] valuesAnnotation = getValuesAnnotation(index);
641
            String textValue = valuesAnnotation[0].toString();
642

    
643
            if (!mapAttri.containsKey(textValue)) {
644
                mapAttri.put(textValue, valuesAnnotation);
645
            }
646

    
647
            if (mapGeom.containsKey(textValue)) {
648
                IGeometry geometry2 = geom;
649
                Rectangle2D rectangle1 = (Rectangle2D) mapGeom.get(textValue);
650

    
651
                // FPoint2D pointNew = new
652
                // FPoint2D((point1.getX()+point2.getX())/2,(point1.getY()+point2.getY())/2);
653
                mapGeom.put(textValue,
654
                    rectangle1.createUnion(geometry2.getBounds2D()));
655
                reportStep();
656
                setNote(PluginServices.getText(this, "exporting_"));
657
            } else {
658
                mapGeom.put(textValue, geom.getBounds2D());
659
            }
660
        }
661
    }
662
}