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 | 11743 | caballero | |
---|---|---|---|
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 | 11536 | caballero | package com.iver.cit.gvsig.project.documents.gui; |
44 | |||
45 | 11613 | caballero | 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 | 11536 | caballero | 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 | 11743 | caballero | import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
87 | 11536 | caballero | import com.iver.utiles.PostProcessSupport; |
88 | import com.iver.utiles.swing.threads.AbstractMonitorableTask; |
||
89 | |||
90 | 11743 | caballero | |
91 | 11613 | caballero | /**
|
92 | * Task to create the annotation layer.
|
||
93 | 11615 | caballero | *
|
94 | 11613 | caballero | * @author Vicente Caballero Navarro
|
95 | */
|
||
96 | public class Annotation_TaskCreate extends AbstractMonitorableTask { |
||
97 | 11743 | caballero | 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 | 11536 | caballero | |
110 | 11743 | caballero | 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 | 11536 | caballero | |
120 | 11743 | caballero | setInitialStep(0);
|
121 | setDeterminatedProcess(true);
|
||
122 | setStatusMessage(PluginServices.getText(this, "exporting_") + ": " + |
||
123 | PluginServices.getText(this, "annotations")); |
||
124 | 11536 | caballero | |
125 | 11743 | caballero | va = lyrVect.getSource(); |
126 | sds = lyrVect.getRecordset(); |
||
127 | 11536 | caballero | |
128 | 11743 | caballero | bitSet = sds.getSelection(); |
129 | 11536 | caballero | |
130 | 11743 | caballero | if (bitSet.cardinality() == 0) { |
131 | rowCount = va.getShapeCount(); |
||
132 | } else {
|
||
133 | rowCount = bitSet.cardinality(); |
||
134 | } |
||
135 | 11536 | caballero | |
136 | 11743 | caballero | setFinalStep(rowCount); |
137 | } |
||
138 | 11536 | caballero | |
139 | 11743 | caballero | /**
|
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 | 11536 | caballero | |
149 | 11743 | caballero | // va.start();
|
150 | ICoordTrans ct = lyrVect.getCoordTrans(); |
||
151 | DriverAttributes attr = va.getDriverAttributes(); |
||
152 | boolean bMustClone = false; |
||
153 | 11536 | caballero | |
154 | 11743 | caballero | if (attr != null) { |
155 | if (attr.isLoadedInMemory()) {
|
||
156 | bMustClone = attr.isLoadedInMemory(); |
||
157 | } |
||
158 | } |
||
159 | 11536 | caballero | |
160 | 11743 | caballero | SHPLayerDefinition lyrDef = (SHPLayerDefinition) writer.getTableDefinition(); |
161 | lyrDef.setShapeType(FShape.POINT); |
||
162 | 11536 | caballero | |
163 | 11743 | caballero | FieldDescription[] fields = getFieldDescriptions();
|
164 | lyrDef.setFieldsDesc(fields); |
||
165 | writer.initialize(lyrDef); |
||
166 | 11536 | caballero | |
167 | 11743 | caballero | // Creamos la tabla.
|
168 | writer.preProcess(); |
||
169 | 11536 | caballero | |
170 | 11743 | caballero | if (duplicate.equals(PluginServices.getText(this, "centered"))) { |
171 | int pos = 0; |
||
172 | Iterator iter = mapGeom.keySet().iterator();
|
||
173 | 11536 | caballero | |
174 | 11743 | caballero | 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 | 11536 | caballero | |
180 | 11743 | caballero | if (ct != null) { |
181 | if (bMustClone) {
|
||
182 | geom = geom.cloneGeometry(); |
||
183 | } |
||
184 | 11536 | caballero | |
185 | 11743 | caballero | geom.reProject(ct); |
186 | } |
||
187 | 11536 | caballero | |
188 | 11743 | caballero | reportStep(); |
189 | setNote(PluginServices.getText(this, "exporting_") + " " + pos + |
||
190 | " " + mapGeom.size());
|
||
191 | 11536 | caballero | |
192 | 11743 | caballero | 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 | 11536 | caballero | |
202 | 11743 | caballero | if (bitSet.cardinality() == 0) { |
203 | rowCount = va.getShapeCount(); |
||
204 | 11536 | caballero | |
205 | 11743 | caballero | for (int i = 0; i < rowCount; i++) { |
206 | IGeometry geom = va.getShape(i); |
||
207 | 11536 | caballero | |
208 | 11743 | caballero | if (geom.getGeometryType() != FShape.POINT) {
|
209 | Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
|
||
210 | geom = ShapeFactory.createPoint2D(p.getX(), p.getY()); |
||
211 | } |
||
212 | 11536 | caballero | |
213 | 11743 | caballero | if (ct != null) { |
214 | if (bMustClone) {
|
||
215 | geom = geom.cloneGeometry(); |
||
216 | } |
||
217 | 11536 | caballero | |
218 | 11743 | caballero | geom.reProject(ct); |
219 | } |
||
220 | 11536 | caballero | |
221 | 11743 | caballero | reportStep(); |
222 | setNote(PluginServices.getText(this, "exporting_") + " " + |
||
223 | i + " " + rowCount);
|
||
224 | 11536 | caballero | |
225 | 11743 | caballero | if (isCanceled()) {
|
226 | break;
|
||
227 | } |
||
228 | 11536 | caballero | |
229 | 11743 | caballero | if (geom != null) { |
230 | Value[] valuesAnnotation = getValuesAnnotation(i);
|
||
231 | 11536 | caballero | |
232 | 11743 | caballero | 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 | 11536 | caballero | |
242 | 11743 | caballero | for (int i = bitSet.nextSetBit(0); i >= 0; |
243 | i = bitSet.nextSetBit(i + 1)) {
|
||
244 | IGeometry geom = va.getShape(i); |
||
245 | 11536 | caballero | |
246 | 11743 | caballero | if (geom.getGeometryType() != FShape.POINT) {
|
247 | Point2D p = FLabel.createLabelPoint((FShape) geom.getInternalShape());
|
||
248 | geom = ShapeFactory.createPoint2D(p.getX(), p.getY()); |
||
249 | } |
||
250 | 11536 | caballero | |
251 | 11743 | caballero | if (ct != null) { |
252 | if (bMustClone) {
|
||
253 | geom = geom.cloneGeometry(); |
||
254 | } |
||
255 | 11536 | caballero | |
256 | 11743 | caballero | geom.reProject(ct); |
257 | } |
||
258 | 11536 | caballero | |
259 | 11743 | caballero | reportStep(); |
260 | setNote(PluginServices.getText(this, "exporting_") + " " + |
||
261 | counter + " " + bitSet.cardinality());
|
||
262 | 11536 | caballero | |
263 | 11743 | caballero | if (isCanceled()) {
|
264 | break;
|
||
265 | } |
||
266 | 11536 | caballero | |
267 | 11743 | caballero | 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 | 11536 | caballero | |
274 | 11743 | caballero | writer.process(edRow); |
275 | } |
||
276 | 11536 | caballero | |
277 | 11743 | caballero | va.stop(); |
278 | } |
||
279 | } |
||
280 | } |
||
281 | 11536 | caballero | |
282 | 11743 | caballero | writer.postProcess(); |
283 | 11536 | caballero | |
284 | 11743 | caballero | //
|
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 | 11536 | caballero | |
369 | 11743 | caballero | 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 | 11536 | caballero | |
377 | 11743 | caballero | if (res == JOptionPane.YES_OPTION) { |
378 | PostProcessSupport.executeCalls(); |
||
379 | lyrDef = (SHPLayerDefinition) writer.getTableDefinition(); |
||
380 | 11536 | caballero | |
381 | 11743 | caballero | FLayer newLayer = LayerFactory.createLayer(lyrDef.getName(), |
382 | reader, mapContext.getProjection()); |
||
383 | 11536 | caballero | |
384 | 11743 | caballero | Annotation_Layer la = new Annotation_Layer();
|
385 | LayerListener[] layerListeners = newLayer.getLayerListeners();
|
||
386 | 11536 | caballero | |
387 | 11743 | caballero | for (int i = 0; i < layerListeners.length; i++) { |
388 | la.addLayerListener(layerListeners[i]); |
||
389 | } |
||
390 | 11536 | caballero | |
391 | 11743 | caballero | 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 | 11536 | caballero | |
401 | 11743 | caballero | /**
|
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 | 11536 | caballero | |
410 | 11743 | caballero | 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 | 11536 | caballero | |
417 | 11743 | caballero | 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 | 11536 | caballero | |
430 | 11743 | caballero | return fields;
|
431 | } |
||
432 | 11536 | caballero | |
433 | 11743 | caballero | /**
|
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 | 11536 | caballero | |
446 | 11743 | caballero | if (pos != -1) { |
447 | fields[i] = antFields[pos]; |
||
448 | } else {
|
||
449 | fields[i] = new FieldDescription();
|
||
450 | 11536 | caballero | |
451 | 11743 | caballero | if (type != Types.VARCHAR) { |
452 | if (name.equals("Color")) { |
||
453 | fields[i].setFieldLength(10);
|
||
454 | } |
||
455 | } |
||
456 | 11536 | caballero | |
457 | 11743 | caballero | // else {
|
458 | // fields[i].setFieldLength(10);
|
||
459 | // fields[i].setFieldDecimalCount(3);
|
||
460 | // }
|
||
461 | } |
||
462 | 11536 | caballero | |
463 | 11743 | caballero | fields[i].setFieldType(type); |
464 | fields[i].setFieldName(name); |
||
465 | } |
||
466 | 11536 | caballero | |
467 | 11743 | caballero | /**
|
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 | 11536 | caballero | |
486 | 11743 | caballero | Value[] values = sds.getRow(i);
|
487 | Value[] valuesAnnotation = new Value[Annotation_Mapping.NUMCOLUMNS]; |
||
488 | 11536 | caballero | |
489 | 11743 | caballero | 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 | 11613 | caballero | |
500 | 11743 | caballero | return valuesAnnotation;
|
501 | } |
||
502 | 11613 | caballero | |
503 | 11743 | caballero | /**
|
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 | 11613 | caballero | |
516 | 11743 | caballero | 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 | 11613 | caballero | |
551 | 11743 | caballero | // }
|
552 | } |
||
553 | } |
||
554 | 11613 | caballero | |
555 | 11743 | caballero | /**
|
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 | 11613 | caballero | |
566 | 11743 | caballero | if (bitSet.cardinality() == 0) { |
567 | rowCount = va.getShapeCount(); |
||
568 | 11613 | caballero | |
569 | 11743 | caballero | for (int i = 0; i < rowCount; i++) { |
570 | IGeometry geom = va.getShape(i); |
||
571 | modifyMap(geom, i); |
||
572 | 11613 | caballero | |
573 | 11743 | caballero | // 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 | 11613 | caballero | |
586 | 11743 | caballero | // reportStep();
|
587 | // setNote(PluginServices.getText(this, "exporting_") +" "+
|
||
588 | // counter+ " "+bitSet.cardinality());
|
||
589 | if (isCanceled()) {
|
||
590 | break;
|
||
591 | } |
||
592 | } |
||
593 | } |
||
594 | 11613 | caballero | |
595 | 11743 | caballero | va.stop(); |
596 | } |
||
597 | 11613 | caballero | |
598 | 11743 | caballero | /**
|
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 | 11613 | caballero | |
614 | 11743 | caballero | if (geom != null) { |
615 | Value[] valuesAnnotation = getValuesAnnotation(index);
|
||
616 | String textValue = valuesAnnotation[0].toString(); |
||
617 | 11613 | caballero | |
618 | 11743 | caballero | if (!mapAttri.containsKey(textValue)) {
|
619 | mapAttri.put(textValue, valuesAnnotation); |
||
620 | } |
||
621 | 11613 | caballero | |
622 | 11743 | caballero | if (mapGeom.containsKey(textValue)) {
|
623 | IGeometry geometry2 = geom; |
||
624 | Rectangle2D rectangle1 = (Rectangle2D) mapGeom.get(textValue); |
||
625 | 11613 | caballero | |
626 | 11743 | caballero | // 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 | 11536 | caballero | } |