root / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / gui / Annotation_TaskCreate.java @ 11743
History | View | Annotate | Download (21.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.Value; |
60 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
61 |
import com.iver.andami.PluginServices; |
62 |
import com.iver.cit.gvsig.fmap.MapContext; |
63 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
65 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
66 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
67 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
68 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
69 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
70 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
71 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
72 |
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition; |
73 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
74 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
75 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
76 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
77 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
78 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping; |
79 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
80 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
81 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
82 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
83 |
import com.iver.cit.gvsig.fmap.layers.LayerListener; |
84 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
85 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
86 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
87 |
import com.iver.utiles.PostProcessSupport; |
88 |
import com.iver.utiles.swing.threads.AbstractMonitorableTask; |
89 |
|
90 |
|
91 |
/**
|
92 |
* Task to create the annotation layer.
|
93 |
*
|
94 |
* @author Vicente Caballero Navarro
|
95 |
*/
|
96 |
public class Annotation_TaskCreate extends AbstractMonitorableTask { |
97 |
Annotation_Layer lyrVect; |
98 |
IWriter writer; |
99 |
int rowCount;
|
100 |
ReadableVectorial va; |
101 |
SelectableDataSource sds; |
102 |
FBitSet bitSet; |
103 |
MapContext mapContext; |
104 |
VectorialDriver reader; |
105 |
private Annotation_Mapping mapping;
|
106 |
private String duplicate; |
107 |
private HashMap mapGeom = new HashMap(); |
108 |
private HashMap mapAttri = new HashMap(); |
109 |
|
110 |
public Annotation_TaskCreate(MapContext mapContext, Annotation_Layer lyr,
|
111 |
IWriter writer, Driver reader, String duplicate) |
112 |
throws DriverIOException, com.iver.cit.gvsig.fmap.DriverException {
|
113 |
this.duplicate = duplicate;
|
114 |
this.mapping = lyr.getAnnotatonMapping();
|
115 |
this.mapContext = mapContext;
|
116 |
this.lyrVect = lyr;
|
117 |
this.writer = writer;
|
118 |
this.reader = (VectorialDriver) reader;
|
119 |
|
120 |
setInitialStep(0);
|
121 |
setDeterminatedProcess(true);
|
122 |
setStatusMessage(PluginServices.getText(this, "exporting_") + ": " + |
123 |
PluginServices.getText(this, "annotations")); |
124 |
|
125 |
va = lyrVect.getSource(); |
126 |
sds = lyrVect.getRecordset(); |
127 |
|
128 |
bitSet = sds.getSelection(); |
129 |
|
130 |
if (bitSet.cardinality() == 0) { |
131 |
rowCount = va.getShapeCount(); |
132 |
} else {
|
133 |
rowCount = bitSet.cardinality(); |
134 |
} |
135 |
|
136 |
setFinalStep(rowCount); |
137 |
} |
138 |
|
139 |
/**
|
140 |
* DOCUMENT ME!
|
141 |
*
|
142 |
* @throws Exception DOCUMENT ME!
|
143 |
*/
|
144 |
public void run() throws Exception { |
145 |
if (duplicate.equals(PluginServices.getText(this, "centered"))) { |
146 |
duplicate(); |
147 |
} |
148 |
|
149 |
// va.start();
|
150 |
ICoordTrans ct = lyrVect.getCoordTrans(); |
151 |
DriverAttributes attr = va.getDriverAttributes(); |
152 |
boolean bMustClone = false; |
153 |
|
154 |
if (attr != null) { |
155 |
if (attr.isLoadedInMemory()) {
|
156 |
bMustClone = attr.isLoadedInMemory(); |
157 |
} |
158 |
} |
159 |
|
160 |
SHPLayerDefinition lyrDef = (SHPLayerDefinition) writer.getTableDefinition(); |
161 |
lyrDef.setShapeType(FShape.POINT); |
162 |
|
163 |
FieldDescription[] fields = getFieldDescriptions();
|
164 |
lyrDef.setFieldsDesc(fields); |
165 |
writer.initialize(lyrDef); |
166 |
|
167 |
// Creamos la tabla.
|
168 |
writer.preProcess(); |
169 |
|
170 |
if (duplicate.equals(PluginServices.getText(this, "centered"))) { |
171 |
int pos = 0; |
172 |
Iterator iter = mapGeom.keySet().iterator();
|
173 |
|
174 |
while (iter.hasNext()) {
|
175 |
String textValue = (String) iter.next(); |
176 |
Rectangle2D rectangle = (Rectangle2D) mapGeom.get(textValue); |
177 |
IGeometry geom = ShapeFactory.createPoint2D(rectangle.getCenterX(), |
178 |
rectangle.getCenterY()); |
179 |
|
180 |
if (ct != null) { |
181 |
if (bMustClone) {
|
182 |
geom = geom.cloneGeometry(); |
183 |
} |
184 |
|
185 |
geom.reProject(ct); |
186 |
} |
187 |
|
188 |
reportStep(); |
189 |
setNote(PluginServices.getText(this, "exporting_") + " " + pos + |
190 |
" " + mapGeom.size());
|
191 |
|
192 |
Value[] values = (Value[]) mapAttri.get(textValue); |
193 |
IFeature feat = new DefaultFeature(geom, values, "" + pos); |
194 |
DefaultRowEdited edRow = new DefaultRowEdited(feat,
|
195 |
DefaultRowEdited.STATUS_ADDED, pos); |
196 |
writer.process(edRow); |
197 |
pos++; |
198 |
} |
199 |
} else if (duplicate.equals(PluginServices.getText(this, "none"))) { |
200 |
va.start(); |
201 |
|
202 |
if (bitSet.cardinality() == 0) { |
203 |
rowCount = va.getShapeCount(); |
204 |
|
205 |
for (int i = 0; i < rowCount; i++) { |
206 |
IGeometry geom = va.getShape(i); |
207 |
|
208 |
if (geom.getGeometryType() != FShape.POINT) {
|
209 |
Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
|
210 |
geom = ShapeFactory.createPoint2D(p.getX(), p.getY()); |
211 |
} |
212 |
|
213 |
if (ct != null) { |
214 |
if (bMustClone) {
|
215 |
geom = geom.cloneGeometry(); |
216 |
} |
217 |
|
218 |
geom.reProject(ct); |
219 |
} |
220 |
|
221 |
reportStep(); |
222 |
setNote(PluginServices.getText(this, "exporting_") + " " + |
223 |
i + " " + rowCount);
|
224 |
|
225 |
if (isCanceled()) {
|
226 |
break;
|
227 |
} |
228 |
|
229 |
if (geom != null) { |
230 |
Value[] valuesAnnotation = getValuesAnnotation(i);
|
231 |
|
232 |
IFeature feat = new DefaultFeature(geom,
|
233 |
valuesAnnotation, "" + i);
|
234 |
DefaultRowEdited edRow = new DefaultRowEdited(feat,
|
235 |
DefaultRowEdited.STATUS_ADDED, i); |
236 |
writer.process(edRow); |
237 |
} |
238 |
} |
239 |
} else {
|
240 |
int counter = 0; |
241 |
|
242 |
for (int i = bitSet.nextSetBit(0); i >= 0; |
243 |
i = bitSet.nextSetBit(i + 1)) {
|
244 |
IGeometry geom = va.getShape(i); |
245 |
|
246 |
if (geom.getGeometryType() != FShape.POINT) {
|
247 |
Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
|
248 |
geom = ShapeFactory.createPoint2D(p.getX(), p.getY()); |
249 |
} |
250 |
|
251 |
if (ct != null) { |
252 |
if (bMustClone) {
|
253 |
geom = geom.cloneGeometry(); |
254 |
} |
255 |
|
256 |
geom.reProject(ct); |
257 |
} |
258 |
|
259 |
reportStep(); |
260 |
setNote(PluginServices.getText(this, "exporting_") + " " + |
261 |
counter + " " + bitSet.cardinality());
|
262 |
|
263 |
if (isCanceled()) {
|
264 |
break;
|
265 |
} |
266 |
|
267 |
if (geom != null) { |
268 |
Value[] valuesAnnotation = getValuesAnnotation(i);
|
269 |
IFeature feat = new DefaultFeature(geom,
|
270 |
valuesAnnotation, "" + i);
|
271 |
DefaultRowEdited edRow = new DefaultRowEdited(feat,
|
272 |
DefaultRowEdited.STATUS_ADDED, i); |
273 |
|
274 |
writer.process(edRow); |
275 |
} |
276 |
|
277 |
va.stop(); |
278 |
} |
279 |
} |
280 |
} |
281 |
|
282 |
writer.postProcess(); |
283 |
|
284 |
//
|
285 |
// if (bitSet.cardinality() == 0) {
|
286 |
// rowCount = va.getShapeCount();
|
287 |
//
|
288 |
// for (int i = 0; i < rowCount; i++) {
|
289 |
// IGeometry geom = va.getShape(i);
|
290 |
//
|
291 |
// if (geom.getGeometryType() != FShape.POINT) {
|
292 |
// Point2D p = FLabel.createLabelPoint((FShape)
|
293 |
// geom.getInternalShape());
|
294 |
// geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
|
295 |
// }
|
296 |
//
|
297 |
// if (ct != null) {
|
298 |
// if (bMustClone) {
|
299 |
// geom = geom.cloneGeometry();
|
300 |
// }
|
301 |
//
|
302 |
// geom.reProject(ct);
|
303 |
// }
|
304 |
//
|
305 |
// reportStep();
|
306 |
// setNote(PluginServices.getText(this, "exporting_") +" "+ i+ "
|
307 |
// "+rowCount);
|
308 |
//
|
309 |
// if (isCanceled()) {
|
310 |
// break;
|
311 |
// }
|
312 |
//
|
313 |
// if (geom != null) {
|
314 |
// Value[] valuesAnnotation = getValuesAnnotation(i);
|
315 |
//
|
316 |
// IFeature feat = new DefaultFeature(geom, valuesAnnotation,
|
317 |
// "" + i);
|
318 |
// DefaultRowEdited edRow = new DefaultRowEdited(feat,
|
319 |
// DefaultRowEdited.STATUS_ADDED, i);
|
320 |
// writer.process(edRow);
|
321 |
// }
|
322 |
// }
|
323 |
// } else {
|
324 |
// int counter = 0;
|
325 |
//
|
326 |
// for (int i = bitSet.nextSetBit(0); i >= 0;
|
327 |
// i = bitSet.nextSetBit(i + 1)) {
|
328 |
// IGeometry geom = va.getShape(i);
|
329 |
//
|
330 |
// if (geom.getGeometryType() != FShape.POINT) {
|
331 |
// Point2D p = FLabel.createLabelPoint((FShape)
|
332 |
// geom.getInternalShape());
|
333 |
// geom = ShapeFactory.createPoint2D(p.getX(), p.getY());
|
334 |
// }
|
335 |
//
|
336 |
// if (ct != null) {
|
337 |
// if (bMustClone) {
|
338 |
// geom = geom.cloneGeometry();
|
339 |
// }
|
340 |
//
|
341 |
// geom.reProject(ct);
|
342 |
// }
|
343 |
//
|
344 |
// reportStep();
|
345 |
// setNote(PluginServices.getText(this, "exporting_") +" "+ counter+ "
|
346 |
// "+bitSet.cardinality());
|
347 |
//
|
348 |
// if (isCanceled()) {
|
349 |
// break;
|
350 |
// }
|
351 |
//
|
352 |
// if (geom != null) {
|
353 |
// Value[] valuesAnnotation = getValuesAnnotation(i);
|
354 |
// IFeature feat = new DefaultFeature(geom, valuesAnnotation,
|
355 |
// "" + i);
|
356 |
// DefaultRowEdited edRow = new DefaultRowEdited(feat,
|
357 |
// DefaultRowEdited.STATUS_ADDED, i);
|
358 |
//
|
359 |
// writer.process(edRow);
|
360 |
// }
|
361 |
// }
|
362 |
// }
|
363 |
//
|
364 |
// writer.postProcess();
|
365 |
// va.stop();
|
366 |
mapAttri.clear(); |
367 |
mapGeom.clear(); |
368 |
|
369 |
if (reader != null) { |
370 |
int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager() |
371 |
.getActiveWindow(), |
372 |
PluginServices.getText(this,
|
373 |
"insertar_en_la_vista_la_capa_creada"),
|
374 |
PluginServices.getText(this, "insertar_capa"), |
375 |
JOptionPane.YES_NO_OPTION);
|
376 |
|
377 |
if (res == JOptionPane.YES_OPTION) { |
378 |
PostProcessSupport.executeCalls(); |
379 |
lyrDef = (SHPLayerDefinition) writer.getTableDefinition(); |
380 |
|
381 |
FLayer newLayer = LayerFactory.createLayer(lyrDef.getName(), |
382 |
reader, mapContext.getProjection()); |
383 |
|
384 |
Annotation_Layer la = new Annotation_Layer();
|
385 |
LayerListener[] layerListeners = newLayer.getLayerListeners();
|
386 |
|
387 |
for (int i = 0; i < layerListeners.length; i++) { |
388 |
la.addLayerListener(layerListeners[i]); |
389 |
} |
390 |
|
391 |
la.setSource(((FLyrVect) newLayer).getSource()); |
392 |
la.setProjection(newLayer.getProjection()); |
393 |
la.setName(newLayer.getName()); |
394 |
la.setLegend((VectorialLegend) lyrVect.getLegend()); |
395 |
Annotation_Mapping.addAnnotationMapping(la); |
396 |
mapContext.getLayers().addLayer(la); |
397 |
} |
398 |
} |
399 |
} |
400 |
|
401 |
/**
|
402 |
* DOCUMENT ME!
|
403 |
*
|
404 |
* @return DOCUMENT ME!
|
405 |
*/
|
406 |
private FieldDescription[] getFieldDescriptions() { |
407 |
SHPLayerDefinition lyrDef = (SHPLayerDefinition) writer.getTableDefinition(); |
408 |
FieldDescription[] fields = new FieldDescription[Annotation_Mapping.NUMCOLUMNS]; // lyrDef.getFieldsDesc(); |
409 |
|
410 |
int posText = mapping.getColumnText();
|
411 |
int posTypeFont = mapping.getColumnTypeFont();
|
412 |
int posStyleFont = mapping.getColumnStyleFont();
|
413 |
int posColor = mapping.getColumnColor();
|
414 |
int posHeight = mapping.getColumnHeight();
|
415 |
int posRotate = mapping.getColumnRotate();
|
416 |
|
417 |
FieldDescription[] fieldsDescriptions = lyrDef.getFieldsDesc();
|
418 |
setField(Annotation_Mapping.TEXT, fieldsDescriptions, fields, posText, 0);
|
419 |
setField(Annotation_Mapping.TYPEFONT, fieldsDescriptions, fields, |
420 |
posTypeFont, 1);
|
421 |
setField(Annotation_Mapping.STYLEFONT, fieldsDescriptions, fields, |
422 |
posStyleFont, 2);
|
423 |
setField(Annotation_Mapping.COLOR, fieldsDescriptions, fields, |
424 |
posColor, 3);
|
425 |
setField(Annotation_Mapping.HEIGHT, fieldsDescriptions, fields, |
426 |
posHeight, 4);
|
427 |
setField(Annotation_Mapping.ROTATE, fieldsDescriptions, fields, |
428 |
posRotate, 5);
|
429 |
|
430 |
return fields;
|
431 |
} |
432 |
|
433 |
/**
|
434 |
* DOCUMENT ME!
|
435 |
*
|
436 |
* @param name DOCUMENT ME!
|
437 |
* @param antFields DOCUMENT ME!
|
438 |
* @param fields DOCUMENT ME!
|
439 |
* @param pos DOCUMENT ME!
|
440 |
* @param i DOCUMENT ME!
|
441 |
*/
|
442 |
private void setField(String name, FieldDescription[] antFields, |
443 |
FieldDescription[] fields, int pos, int i) { |
444 |
int type = Annotation_Mapping.getType(name);
|
445 |
|
446 |
if (pos != -1) { |
447 |
fields[i] = antFields[pos]; |
448 |
} else {
|
449 |
fields[i] = new FieldDescription();
|
450 |
|
451 |
if (type != Types.VARCHAR) { |
452 |
if (name.equals("Color")) { |
453 |
fields[i].setFieldLength(10);
|
454 |
} |
455 |
} |
456 |
|
457 |
// else {
|
458 |
// fields[i].setFieldLength(10);
|
459 |
// fields[i].setFieldDecimalCount(3);
|
460 |
// }
|
461 |
} |
462 |
|
463 |
fields[i].setFieldType(type); |
464 |
fields[i].setFieldName(name); |
465 |
} |
466 |
|
467 |
/**
|
468 |
* DOCUMENT ME!
|
469 |
*
|
470 |
* @param i DOCUMENT ME!
|
471 |
*
|
472 |
* @return DOCUMENT ME!
|
473 |
*
|
474 |
* @throws DriverException DOCUMENT ME!
|
475 |
* @throws EditionException DOCUMENT ME!
|
476 |
*/
|
477 |
private Value[] getValuesAnnotation(int i) |
478 |
throws DriverException, EditionException {
|
479 |
int posText = mapping.getColumnText();
|
480 |
int posTypeFont = mapping.getColumnTypeFont();
|
481 |
int posStyleFont = mapping.getColumnStyleFont();
|
482 |
int posColor = mapping.getColumnColor();
|
483 |
int posHeight = mapping.getColumnHeight();
|
484 |
int posRotate = mapping.getColumnRotate();
|
485 |
|
486 |
Value[] values = sds.getRow(i);
|
487 |
Value[] valuesAnnotation = new Value[Annotation_Mapping.NUMCOLUMNS]; |
488 |
|
489 |
setValue(Annotation_Mapping.TEXT, values, valuesAnnotation, posText, 0);
|
490 |
setValue(Annotation_Mapping.TYPEFONT, values, valuesAnnotation, |
491 |
posTypeFont, 1);
|
492 |
setValue(Annotation_Mapping.STYLEFONT, values, valuesAnnotation, |
493 |
posStyleFont, 2);
|
494 |
setValue(Annotation_Mapping.COLOR, values, valuesAnnotation, posColor, 3);
|
495 |
setValue(Annotation_Mapping.HEIGHT, values, valuesAnnotation, |
496 |
posHeight, 4);
|
497 |
setValue(Annotation_Mapping.ROTATE, values, valuesAnnotation, |
498 |
posRotate, 5);
|
499 |
|
500 |
return valuesAnnotation;
|
501 |
} |
502 |
|
503 |
/**
|
504 |
* DOCUMENT ME!
|
505 |
*
|
506 |
* @param name DOCUMENT ME!
|
507 |
* @param antValues DOCUMENT ME!
|
508 |
* @param values DOCUMENT ME!
|
509 |
* @param pos DOCUMENT ME!
|
510 |
* @param i DOCUMENT ME!
|
511 |
*/
|
512 |
private void setValue(String name, Value[] antValues, Value[] values, |
513 |
int pos, int i) { |
514 |
int type = Annotation_Mapping.getType(name);
|
515 |
|
516 |
if (pos != -1) { |
517 |
try {
|
518 |
values[i] = ValueFactory.createValueByType(antValues[pos].toString(), |
519 |
type); |
520 |
} catch (ParseException e) { |
521 |
e.printStackTrace(); |
522 |
} |
523 |
} else {
|
524 |
// if (type == Types.VARCHAR) {
|
525 |
// values[i] = ValueFactory.createNullValue();
|
526 |
// } else {
|
527 |
try {
|
528 |
if (name == Annotation_Mapping.TEXT) {
|
529 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
530 |
Annotation_Mapping.DEFAULTTEXT), type); |
531 |
} else if (name == Annotation_Mapping.COLOR) { |
532 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
533 |
Annotation_Mapping.DEFAULTCOLOR), type); |
534 |
} else if (name == Annotation_Mapping.HEIGHT) { |
535 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
536 |
Annotation_Mapping.DEFAULTHEIGHT), type); |
537 |
} else if (name == Annotation_Mapping.TYPEFONT) { |
538 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
539 |
Annotation_Mapping.DEFAULTTYPEFONT), type); |
540 |
} else if (name == Annotation_Mapping.STYLEFONT) { |
541 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
542 |
Annotation_Mapping.DEFAULTSTYLEFONT), type); |
543 |
} else if (name == Annotation_Mapping.ROTATE) { |
544 |
values[i] = ValueFactory.createValueByType(String.valueOf(
|
545 |
Annotation_Mapping.DEFAULTROTATE), type); |
546 |
} |
547 |
} catch (ParseException e) { |
548 |
e.printStackTrace(); |
549 |
} |
550 |
|
551 |
// }
|
552 |
} |
553 |
} |
554 |
|
555 |
/**
|
556 |
* DOCUMENT ME!
|
557 |
*
|
558 |
* @throws DriverIOException DOCUMENT ME!
|
559 |
* @throws DriverException DOCUMENT ME!
|
560 |
* @throws EditionException DOCUMENT ME!
|
561 |
*/
|
562 |
private void duplicate() |
563 |
throws DriverIOException, DriverException, EditionException {
|
564 |
va.start(); |
565 |
|
566 |
if (bitSet.cardinality() == 0) { |
567 |
rowCount = va.getShapeCount(); |
568 |
|
569 |
for (int i = 0; i < rowCount; i++) { |
570 |
IGeometry geom = va.getShape(i); |
571 |
modifyMap(geom, i); |
572 |
|
573 |
// reportStep();
|
574 |
// setNote(PluginServices.getText(this, "exporting_") +" "+ i+ "
|
575 |
// "+rowCount);
|
576 |
if (isCanceled()) {
|
577 |
break;
|
578 |
} |
579 |
} |
580 |
} else {
|
581 |
for (int i = bitSet.nextSetBit(0); i >= 0; |
582 |
i = bitSet.nextSetBit(i + 1)) {
|
583 |
IGeometry geom = va.getShape(i); |
584 |
modifyMap(geom, i); |
585 |
|
586 |
// reportStep();
|
587 |
// setNote(PluginServices.getText(this, "exporting_") +" "+
|
588 |
// counter+ " "+bitSet.cardinality());
|
589 |
if (isCanceled()) {
|
590 |
break;
|
591 |
} |
592 |
} |
593 |
} |
594 |
|
595 |
va.stop(); |
596 |
} |
597 |
|
598 |
/**
|
599 |
* DOCUMENT ME!
|
600 |
*
|
601 |
* @param geom DOCUMENT ME!
|
602 |
* @param index DOCUMENT ME!
|
603 |
*
|
604 |
* @throws DriverException DOCUMENT ME!
|
605 |
* @throws EditionException DOCUMENT ME!
|
606 |
*/
|
607 |
private void modifyMap(IGeometry geom, int index) |
608 |
throws DriverException, EditionException {
|
609 |
if (geom.getGeometryType() != FShape.POINT) {
|
610 |
Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
|
611 |
geom = ShapeFactory.createPoint2D(p.getX(), p.getY()); |
612 |
} |
613 |
|
614 |
if (geom != null) { |
615 |
Value[] valuesAnnotation = getValuesAnnotation(index);
|
616 |
String textValue = valuesAnnotation[0].toString(); |
617 |
|
618 |
if (!mapAttri.containsKey(textValue)) {
|
619 |
mapAttri.put(textValue, valuesAnnotation); |
620 |
} |
621 |
|
622 |
if (mapGeom.containsKey(textValue)) {
|
623 |
IGeometry geometry2 = geom; |
624 |
Rectangle2D rectangle1 = (Rectangle2D) mapGeom.get(textValue); |
625 |
|
626 |
// FPoint2D pointNew = new
|
627 |
// FPoint2D((point1.getX()+point2.getX())/2,(point1.getY()+point2.getY())/2);
|
628 |
mapGeom.put(textValue, |
629 |
rectangle1.createUnion(geometry2.getBounds2D())); |
630 |
reportStep(); |
631 |
setNote(PluginServices.getText(this, "exporting_")); |
632 |
} else {
|
633 |
mapGeom.put(textValue, geom.getBounds2D()); |
634 |
} |
635 |
} |
636 |
} |
637 |
} |