svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dxf / DXFMemoryDriver.java @ 6611
History | View | Annotate | Download (35.7 KB)
1 | 758 | jmorell | /*
|
---|---|---|---|
2 | * @(#)DXFMemoryDriver 29-dic-2004
|
||
3 | 5389 | caballero | *
|
4 | 758 | jmorell | * @author jmorell (jose.morell@gmail.com)
|
5 | */
|
||
6 | 1100 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
7 | *
|
||
8 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
9 | *
|
||
10 | * This program is free software; you can redistribute it and/or
|
||
11 | * modify it under the terms of the GNU General Public License
|
||
12 | * as published by the Free Software Foundation; either version 2
|
||
13 | * of the License, or (at your option) any later version.
|
||
14 | *
|
||
15 | * This program is distributed in the hope that it will be useful,
|
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
18 | * GNU General Public License for more details.
|
||
19 | *
|
||
20 | * You should have received a copy of the GNU General Public License
|
||
21 | * along with this program; if not, write to the Free Software
|
||
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
23 | *
|
||
24 | * For more information, contact:
|
||
25 | *
|
||
26 | * Generalitat Valenciana
|
||
27 | * Conselleria d'Infraestructures i Transport
|
||
28 | * Av. Blasco Ib??ez, 50
|
||
29 | * 46010 VALENCIA
|
||
30 | * SPAIN
|
||
31 | *
|
||
32 | * +34 963862235
|
||
33 | * gvsig@gva.es
|
||
34 | * www.gvsig.gva.es
|
||
35 | *
|
||
36 | * or
|
||
37 | *
|
||
38 | * IVER T.I. S.A
|
||
39 | * Salamanca 50
|
||
40 | * 46005 Valencia
|
||
41 | * Spain
|
||
42 | *
|
||
43 | * +34 963163400
|
||
44 | * dac@iver.es
|
||
45 | */
|
||
46 | 758 | jmorell | package com.iver.cit.gvsig.fmap.drivers.dxf; |
47 | |||
48 | 839 | jmorell | import java.awt.Color; |
49 | import java.awt.Font; |
||
50 | 758 | jmorell | import java.awt.geom.Point2D; |
51 | import java.io.File; |
||
52 | 4937 | fjp | import java.io.FileInputStream; |
53 | import java.io.FileNotFoundException; |
||
54 | import java.io.FileOutputStream; |
||
55 | 758 | jmorell | import java.io.IOException; |
56 | 4937 | fjp | import java.nio.channels.FileChannel; |
57 | 6521 | azabala | import java.sql.Types; |
58 | 758 | jmorell | import java.util.ArrayList; |
59 | 6521 | azabala | import java.util.Date; |
60 | 4937 | fjp | import java.util.Properties; |
61 | 758 | jmorell | |
62 | import org.cresques.cts.IProjection; |
||
63 | 2196 | vcaballero | import org.cresques.geo.Point3D; |
64 | 758 | jmorell | import org.cresques.io.DxfFile; |
65 | import org.cresques.px.IObjList; |
||
66 | import org.cresques.px.dxf.AcadColor; |
||
67 | import org.cresques.px.dxf.DxfFeatureMaker; |
||
68 | 3184 | jmorell | import org.cresques.px.dxf.DxfHeaderManager; |
69 | 758 | jmorell | import org.cresques.px.gml.Feature; |
70 | import org.cresques.px.gml.LineString; |
||
71 | 2196 | vcaballero | import org.cresques.px.gml.LineString3D; |
72 | 758 | jmorell | import org.cresques.px.gml.Point; |
73 | import org.cresques.px.gml.Polygon; |
||
74 | 2196 | vcaballero | import org.cresques.px.gml.Polygon3D; |
75 | 758 | jmorell | |
76 | 4937 | fjp | import com.hardcode.gdbms.driver.DriverUtilities; |
77 | 1828 | fernando | import com.hardcode.gdbms.engine.data.driver.DriverException; |
78 | import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
||
79 | 2217 | fernando | import com.hardcode.gdbms.engine.data.edition.DataWare; |
80 | 758 | jmorell | import com.hardcode.gdbms.engine.values.IntValue; |
81 | import com.hardcode.gdbms.engine.values.Value; |
||
82 | import com.hardcode.gdbms.engine.values.ValueFactory; |
||
83 | 2196 | vcaballero | import com.iver.cit.gvsig.fmap.core.FPoint2D; |
84 | 758 | jmorell | import com.iver.cit.gvsig.fmap.core.FPoint3D; |
85 | import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
||
86 | 2196 | vcaballero | import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
87 | 758 | jmorell | import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
88 | 2196 | vcaballero | import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
89 | 758 | jmorell | import com.iver.cit.gvsig.fmap.core.FShape; |
90 | import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
||
91 | 913 | jmorell | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
92 | 758 | jmorell | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
93 | 6164 | luisw2 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
94 | 1233 | fjp | import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
95 | 6521 | azabala | import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
96 | 5558 | fjp | import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
97 | import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
||
98 | 758 | jmorell | import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
99 | 3271 | fjp | import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
100 | 758 | jmorell | import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
101 | 4937 | fjp | import com.iver.cit.gvsig.fmap.edition.EditionException; |
102 | import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
||
103 | import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
||
104 | 5595 | fjp | import com.iver.cit.gvsig.fmap.edition.IWriteable; |
105 | import com.iver.cit.gvsig.fmap.edition.IWriter; |
||
106 | 4937 | fjp | import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfFieldsMapping; |
107 | import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfWriter; |
||
108 | 758 | jmorell | import com.iver.cit.gvsig.fmap.rendering.Legend; |
109 | import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
||
110 | import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
||
111 | |||
112 | /**
|
||
113 | * @author jmorell (jose.morell@gmail.com)
|
||
114 | * @version 29-dic-2004
|
||
115 | */
|
||
116 | 4937 | fjp | public class DXFMemoryDriver extends MemoryDriver implements |
117 | 5595 | fjp | VectorialFileDriver, WithDefaultLegend, ISpatialWriter, IWriteable { |
118 | 4937 | fjp | private static String tempDirectoryPath = System |
119 | .getProperty("java.io.tmpdir");
|
||
120 | 758 | jmorell | |
121 | 6521 | azabala | /*
|
122 | * azabala, bug 666:
|
||
123 | * retoco los ID para que sean static, y a?ado un FieldDescription[] por
|
||
124 | * defecto, ya que todos los ficheros DXF comparten el mismo esquema.
|
||
125 | * TODO Unificar el mecanismo de FieldDescription con el de
|
||
126 | * arrayFields. ArrayList arrayFields es util para el TableModel, pero el
|
||
127 | * problema es que el tipo de dato de todas las columnas es Object.class, mientras
|
||
128 | * que LayerDefinition si que tiene una verdadera descripcion del esquema
|
||
129 | * a emplear
|
||
130 | *
|
||
131 | * arrayFields.add("ID");
|
||
132 | arrayFields.add("FShape");
|
||
133 | arrayFields.add("Entity");
|
||
134 | arrayFields.add("Layer");
|
||
135 | arrayFields.add("Color");
|
||
136 | arrayFields.add("Elevation");
|
||
137 | arrayFields.add("Thickness");
|
||
138 | arrayFields.add("Text");
|
||
139 | arrayFields.add("HeightText");
|
||
140 | arrayFields.add("RotationText");
|
||
141 | */
|
||
142 | private final static int ID_FIELD_ID = 0; |
||
143 | 4937 | fjp | |
144 | 6521 | azabala | private final static int ID_FIELD_FSHAPE = 1; |
145 | 4937 | fjp | |
146 | 6521 | azabala | private final static int ID_FIELD_ENTITY = 2; |
147 | 4937 | fjp | |
148 | 6521 | azabala | private final static int ID_FIELD_LAYER = 3; |
149 | 4937 | fjp | |
150 | 6521 | azabala | private final static int ID_FIELD_COLOR = 4; |
151 | 4937 | fjp | |
152 | 6521 | azabala | private final static int ID_FIELD_ELEVATION = 5; |
153 | 4937 | fjp | |
154 | 6521 | azabala | private final static int ID_FIELD_THICKNESS = 6; |
155 | 4937 | fjp | |
156 | 6521 | azabala | private final static int ID_FIELD_TEXT = 7; |
157 | 4937 | fjp | |
158 | 6521 | azabala | private final static int ID_FIELD_HEIGHTTEXT = 8; |
159 | 4937 | fjp | |
160 | 6521 | azabala | private final static int ID_FIELD_ROTATIONTEXT = 9; |
161 | |||
162 | private final static FieldDescription[] fields = new FieldDescription[10]; |
||
163 | static{
|
||
164 | FieldDescription fieldDesc = new FieldDescription();
|
||
165 | fieldDesc.setFieldName("ID");
|
||
166 | fieldDesc.setFieldType(Types.INTEGER);
|
||
167 | fieldDesc.setFieldLength(20);
|
||
168 | fieldDesc.setFieldDecimalCount(0);
|
||
169 | fields[0] = fieldDesc;
|
||
170 | |||
171 | fieldDesc = new FieldDescription();
|
||
172 | fieldDesc.setFieldName("FShape");
|
||
173 | fieldDesc.setFieldType(Types.VARCHAR);
|
||
174 | fieldDesc.setFieldLength(254);
|
||
175 | fieldDesc.setFieldDecimalCount(0);
|
||
176 | fields[1] = fieldDesc;
|
||
177 | |||
178 | fieldDesc = new FieldDescription();
|
||
179 | fieldDesc.setFieldName("Entity");
|
||
180 | fieldDesc.setFieldType(Types.VARCHAR);
|
||
181 | fieldDesc.setFieldLength(254);
|
||
182 | fieldDesc.setFieldDecimalCount(0);
|
||
183 | fields[2] = fieldDesc;
|
||
184 | |||
185 | fieldDesc = new FieldDescription();
|
||
186 | fieldDesc.setFieldName("Layer");
|
||
187 | fieldDesc.setFieldType(Types.VARCHAR);
|
||
188 | fieldDesc.setFieldLength(254);
|
||
189 | fieldDesc.setFieldDecimalCount(0);
|
||
190 | fields[3] = fieldDesc;
|
||
191 | |||
192 | fieldDesc = new FieldDescription();
|
||
193 | fieldDesc.setFieldName("Color");
|
||
194 | fieldDesc.setFieldType(Types.DOUBLE);
|
||
195 | fieldDesc.setFieldLength(20);
|
||
196 | fieldDesc.setFieldDecimalCount(5);
|
||
197 | fields[4] = fieldDesc;
|
||
198 | |||
199 | fieldDesc = new FieldDescription();
|
||
200 | fieldDesc.setFieldName("Elevation");
|
||
201 | fieldDesc.setFieldType(Types.DOUBLE);
|
||
202 | fieldDesc.setFieldLength(20);
|
||
203 | fieldDesc.setFieldDecimalCount(5);
|
||
204 | fields[5] = fieldDesc;
|
||
205 | |||
206 | fieldDesc = new FieldDescription();
|
||
207 | fieldDesc.setFieldName("Thickness");
|
||
208 | fieldDesc.setFieldType(Types.DOUBLE);
|
||
209 | fieldDesc.setFieldLength(20);
|
||
210 | fieldDesc.setFieldDecimalCount(5);
|
||
211 | fields[6] = fieldDesc;
|
||
212 | |||
213 | fieldDesc = new FieldDescription();
|
||
214 | fieldDesc.setFieldName("Text");
|
||
215 | fieldDesc.setFieldType(Types.VARCHAR);
|
||
216 | fieldDesc.setFieldLength(254);
|
||
217 | fieldDesc.setFieldDecimalCount(0);
|
||
218 | fields[7] = fieldDesc;
|
||
219 | |||
220 | fieldDesc = new FieldDescription();
|
||
221 | fieldDesc.setFieldName("Height");
|
||
222 | fieldDesc.setFieldType(Types.DOUBLE);
|
||
223 | fieldDesc.setFieldLength(20);
|
||
224 | fieldDesc.setFieldDecimalCount(5);
|
||
225 | fields[8] = fieldDesc;
|
||
226 | |||
227 | fieldDesc = new FieldDescription();
|
||
228 | fieldDesc.setFieldName("Rotation");
|
||
229 | fieldDesc.setFieldType(Types.DOUBLE);
|
||
230 | fieldDesc.setFieldLength(20);
|
||
231 | fieldDesc.setFieldDecimalCount(5);
|
||
232 | fields[9] = fieldDesc;
|
||
233 | |||
234 | } |
||
235 | |||
236 | 4937 | fjp | private DxfWriter dxfWriter = new DxfWriter(); |
237 | |||
238 | private File fTemp; |
||
239 | |||
240 | 758 | jmorell | VectorialUniqueValueLegend defaultLegend; |
241 | 4937 | fjp | |
242 | 758 | jmorell | private String path; |
243 | 4937 | fjp | |
244 | 758 | jmorell | private File m_Fich; |
245 | 4937 | fjp | |
246 | 758 | jmorell | private DxfFile.EntityFactory featureMaker;
|
247 | 4937 | fjp | |
248 | 758 | jmorell | private DxfFile dxfFeatureFile;
|
249 | 4937 | fjp | |
250 | 758 | jmorell | private IObjList.vector features;
|
251 | 4937 | fjp | |
252 | 1233 | fjp | private DriverAttributes attr = new DriverAttributes(); |
253 | 4937 | fjp | |
254 | 758 | jmorell | /**
|
255 | * Habilita la utilizaci?n del lector del HEADER del DXF.
|
||
256 | */
|
||
257 | private DxfFile.VarSettings headerManager;
|
||
258 | |||
259 | 4937 | fjp | /*
|
260 | * (non-Javadoc)
|
||
261 | 5389 | caballero | *
|
262 | 758 | jmorell | * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#open(java.io.File)
|
263 | */
|
||
264 | public void open(File f) throws IOException { |
||
265 | 4937 | fjp | m_Fich = f; |
266 | 758 | jmorell | } |
267 | 4937 | fjp | |
268 | 758 | jmorell | public void initialize() throws IOException { |
269 | 913 | jmorell | float heightText = 10; |
270 | 4937 | fjp | |
271 | 1233 | fjp | attr.setLoadedInMemory(true);
|
272 | 4937 | fjp | |
273 | 6164 | luisw2 | IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
274 | 758 | jmorell | featureMaker = new DxfFeatureMaker(proj);
|
275 | 4937 | fjp | headerManager = new DxfHeaderManager();
|
276 | dxfFeatureFile = new DxfFile(proj, m_Fich.getAbsolutePath(),
|
||
277 | featureMaker, headerManager); |
||
278 | 758 | jmorell | dxfFeatureFile.load(); |
279 | 4937 | fjp | features = (IObjList.vector) ((DxfFeatureMaker) featureMaker) |
280 | .getObjects(); |
||
281 | String acadVersion = (String) ((DxfHeaderManager) headerManager) |
||
282 | .getAcadVersion(); |
||
283 | System.out.println("initialize(): acadVersion = " + acadVersion); |
||
284 | if (!featureMaker.isDxf3DFile() && !headerManager.isWritedDxf3D()) { // y no |
||
285 | // est?n
|
||
286 | // todos
|
||
287 | // a
|
||
288 | // 9999
|
||
289 | Feature[] features2D = new Feature[features.size()]; |
||
290 | for (int i = 0; i < features.size(); i++) { |
||
291 | Feature fea = (Feature) features.get(i); |
||
292 | 2196 | vcaballero | if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
293 | 4937 | fjp | Point point = (Point) fea.getGeometry(); |
294 | 2196 | vcaballero | Point point2 = new Point(); |
295 | 4937 | fjp | for (int j = 0; j < point.pointNr(); j++) { |
296 | point2.add(point.get(j)); |
||
297 | 2196 | vcaballero | } |
298 | point2.setTextPoint(point.isTextPoint()); |
||
299 | fea.setGeometry(point2); |
||
300 | features2D[i] = fea; |
||
301 | 4937 | fjp | // } else if (fea.getGeometry() instanceof InsPoint3D) {
|
302 | // InsPoint insPoint = (InsPoint)fea.getGeometry();
|
||
303 | // InsPoint insPoint2 = new InsPoint();
|
||
304 | // for (int j=0;j<insPoint.pointNr();j++) {
|
||
305 | // insPoint2.add(insPoint.get(j));
|
||
306 | // }
|
||
307 | // fea.setGeometry(insPoint2);
|
||
308 | // features2D[i] = fea;
|
||
309 | 2196 | vcaballero | } else if (fea.getGeometry() instanceof LineString3D) { |
310 | 4937 | fjp | LineString lineString = (LineString) fea.getGeometry(); |
311 | 2196 | vcaballero | LineString lineString2 = new LineString();
|
312 | 4937 | fjp | for (int j = 0; j < lineString.pointNr(); j++) { |
313 | lineString2.add(lineString.get(j)); |
||
314 | 2196 | vcaballero | } |
315 | fea.setGeometry(lineString2); |
||
316 | features2D[i] = fea; |
||
317 | } else if (fea.getGeometry() instanceof Polygon3D) { |
||
318 | 4937 | fjp | Polygon polygon = (Polygon) fea.getGeometry(); |
319 | 2196 | vcaballero | Polygon polygon2 = new Polygon(); |
320 | 4937 | fjp | for (int j = 0; j < polygon.pointNr(); j++) { |
321 | polygon2.add(polygon.get(j)); |
||
322 | 2196 | vcaballero | } |
323 | fea.setGeometry(polygon2); |
||
324 | features2D[i] = fea; |
||
325 | } |
||
326 | } |
||
327 | 4937 | fjp | features.clear(); |
328 | for (int i = 0; i < features2D.length; i++) { |
||
329 | features.add(features2D[i]); |
||
330 | 2196 | vcaballero | } |
331 | } |
||
332 | 4937 | fjp | // String acadVersion =
|
333 | // (String)((DxfHeaderManager)headerManager).getAcadVersion();
|
||
334 | // System.out.println("initialize(): acadVersion = " + acadVersion);
|
||
335 | |||
336 | 758 | jmorell | int nAtt = featureMaker.getAttributes().size();
|
337 | 4937 | fjp | |
338 | 758 | jmorell | // Campos de las MemoryLayer:
|
339 | 4937 | fjp | Value[] auxRow = new Value[10 + nAtt]; |
340 | 913 | jmorell | ArrayList arrayFields = new ArrayList(); |
341 | arrayFields.add("ID");
|
||
342 | 2196 | vcaballero | arrayFields.add("FShape");
|
343 | 913 | jmorell | arrayFields.add("Entity");
|
344 | arrayFields.add("Layer");
|
||
345 | arrayFields.add("Color");
|
||
346 | arrayFields.add("Elevation");
|
||
347 | arrayFields.add("Thickness");
|
||
348 | arrayFields.add("Text");
|
||
349 | arrayFields.add("HeightText");
|
||
350 | arrayFields.add("RotationText");
|
||
351 | 4937 | fjp | for (int i = 0; i < nAtt; i++) { |
352 | 758 | jmorell | String att[] = new String[2]; |
353 | 4937 | fjp | att = (String[]) featureMaker.getAttributes().get(i); |
354 | 913 | jmorell | arrayFields.add(att[0]);
|
355 | 758 | jmorell | } |
356 | 4937 | fjp | |
357 | getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
||
358 | |||
359 | for (int i = 0; i < features.size(); i++) { |
||
360 | |||
361 | auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0.0);
|
||
362 | auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0.0);
|
||
363 | auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
||
364 | |||
365 | Feature fea = (Feature) features.get(i); |
||
366 | if (fea.getGeometry() instanceof Point |
||
367 | && !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
|
||
368 | Point point = (Point) fea.getGeometry(); |
||
369 | 758 | jmorell | Point2D pto = new Point2D.Double(); |
370 | 4937 | fjp | pto = (Point2D) point.get(0); |
371 | 758 | jmorell | FShape nuevoShp; |
372 | 4937 | fjp | if (point.isTextPoint()) {
|
373 | 913 | jmorell | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
374 | 4937 | fjp | auxRow[ID_FIELD_FSHAPE] = ValueFactory |
375 | .createValue(new String("FPoint2D")); |
||
376 | auxRow[ID_FIELD_ENTITY] = ValueFactory |
||
377 | .createValue(new String(fea.getProp("dxfEntity"))); |
||
378 | auxRow[ID_FIELD_LAYER] = ValueFactory |
||
379 | .createValue(new String(fea.getProp("layer"))); |
||
380 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
381 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
382 | auxRow[ID_FIELD_TEXT] = ValueFactory |
||
383 | .createValue(new String(fea.getProp("text"))); |
||
384 | heightText = Float.parseFloat(fea.getProp("textHeight")); |
||
385 | auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory |
||
386 | .createValue(heightText); |
||
387 | double auxR = Double.parseDouble(fea |
||
388 | .getProp("textRotation"));
|
||
389 | auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory |
||
390 | .createValue(auxR); |
||
391 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
392 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
393 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
394 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
395 | // Attributes
|
||
396 | for (int j = 0; j < nAtt; j++) { |
||
397 | String[] attributes = new String[2]; |
||
398 | attributes = (String[]) featureMaker.getAttributes() |
||
399 | .get(j); |
||
400 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
401 | (String) attributes[1])); |
||
402 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
403 | auxRow[10 + j] = ValueFactory
|
||
404 | .createValue(new String(fea |
||
405 | .getProp(attributes[0])));
|
||
406 | } |
||
407 | } |
||
408 | nuevoShp = new FPoint2D(pto.getX(), pto.getY());
|
||
409 | 913 | jmorell | addShape(nuevoShp, auxRow); |
410 | 4937 | fjp | } else {
|
411 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
412 | auxRow[ID_FIELD_FSHAPE] = ValueFactory |
||
413 | .createValue(new String("FPoint2D")); |
||
414 | auxRow[ID_FIELD_ENTITY] = ValueFactory |
||
415 | .createValue(new String(fea.getProp("dxfEntity"))); |
||
416 | auxRow[ID_FIELD_LAYER] = ValueFactory |
||
417 | .createValue(new String(fea.getProp("layer"))); |
||
418 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
419 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
420 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
421 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
422 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
423 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
424 | // Attributes
|
||
425 | for (int j = 0; j < nAtt; j++) { |
||
426 | String[] attributes = new String[2]; |
||
427 | attributes = (String[]) featureMaker.getAttributes() |
||
428 | .get(j); |
||
429 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
430 | (String) attributes[1])); |
||
431 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
432 | auxRow[10 + j] = ValueFactory
|
||
433 | .createValue(new String(fea |
||
434 | .getProp(attributes[0])));
|
||
435 | } |
||
436 | } |
||
437 | nuevoShp = new FPoint2D(pto.getX(), pto.getY());
|
||
438 | 758 | jmorell | addShape(nuevoShp, auxRow); |
439 | 4937 | fjp | } |
440 | 2196 | vcaballero | } else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
441 | 4937 | fjp | org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D) fea |
442 | .getGeometry(); |
||
443 | 2196 | vcaballero | Point3D pto = new Point3D();
|
444 | 4937 | fjp | pto = (Point3D) point.getPoint3D(0);
|
445 | 2196 | vcaballero | FShape nuevoShp; |
446 | 4937 | fjp | if (point.isTextPoint()) {
|
447 | 2196 | vcaballero | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
448 | 4937 | fjp | auxRow[ID_FIELD_FSHAPE] = ValueFactory |
449 | .createValue(new String("FPoint3D")); |
||
450 | auxRow[ID_FIELD_ENTITY] = ValueFactory |
||
451 | .createValue(new String(fea.getProp("dxfEntity"))); |
||
452 | auxRow[ID_FIELD_LAYER] = ValueFactory |
||
453 | .createValue(new String(fea.getProp("layer"))); |
||
454 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
455 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
456 | auxRow[ID_FIELD_TEXT] = ValueFactory |
||
457 | .createValue(new String(fea.getProp("text"))); |
||
458 | heightText = Float.parseFloat(fea.getProp("textHeight")); |
||
459 | auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory |
||
460 | .createValue(heightText); |
||
461 | double auxR = Double.parseDouble(fea |
||
462 | .getProp("textRotation"));
|
||
463 | auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory |
||
464 | .createValue(auxR); |
||
465 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
466 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
467 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
468 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
469 | // Attributes
|
||
470 | for (int j = 0; j < nAtt; j++) { |
||
471 | String[] attributes = new String[2]; |
||
472 | attributes = (String[]) featureMaker.getAttributes() |
||
473 | .get(j); |
||
474 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
475 | (String) attributes[1])); |
||
476 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
477 | auxRow[10 + j] = ValueFactory
|
||
478 | .createValue(new String(fea |
||
479 | .getProp(attributes[0])));
|
||
480 | } |
||
481 | } |
||
482 | nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
|
||
483 | 2196 | vcaballero | addShape(nuevoShp, auxRow); |
484 | 4937 | fjp | } else {
|
485 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
486 | auxRow[ID_FIELD_FSHAPE] = ValueFactory |
||
487 | .createValue(new String("FPoint3D")); |
||
488 | auxRow[ID_FIELD_ENTITY] = ValueFactory |
||
489 | .createValue(new String(fea.getProp("dxfEntity"))); |
||
490 | auxRow[ID_FIELD_LAYER] = ValueFactory |
||
491 | .createValue(new String(fea.getProp("layer"))); |
||
492 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
493 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
494 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
495 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
496 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
497 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
498 | // Attributes
|
||
499 | for (int j = 0; j < nAtt; j++) { |
||
500 | String[] attributes = new String[2]; |
||
501 | attributes = (String[]) featureMaker.getAttributes() |
||
502 | .get(j); |
||
503 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
504 | (String) attributes[1])); |
||
505 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
506 | auxRow[10 + j] = ValueFactory
|
||
507 | .createValue(new String(fea |
||
508 | .getProp(attributes[0])));
|
||
509 | } |
||
510 | } |
||
511 | nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
|
||
512 | 2196 | vcaballero | addShape(nuevoShp, auxRow); |
513 | 4937 | fjp | } |
514 | /*
|
||
515 | * } else if (fea.getGeometry() instanceof InsPoint &&
|
||
516 | * !(fea.getGeometry() instanceof InsPoint3D)) { InsPoint
|
||
517 | * insPoint = (InsPoint)fea.getGeometry(); Point2D pto = new
|
||
518 | * Point2D.Double(); pto = (Point2D)insPoint.get(0);
|
||
519 | * auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
||
520 | * auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
|
||
521 | * String("PointZ")); auxRow[ID_FIELD_ENTITY] =
|
||
522 | * ValueFactory.createValue(new
|
||
523 | * String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
|
||
524 | * ValueFactory.createValue(new String(fea.getProp("layer")));
|
||
525 | * int auxInt = Integer.parseInt(fea.getProp("color"));
|
||
526 | * auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
||
527 | * double auxE = Double.parseDouble(fea.getProp("elevation"));
|
||
528 | * auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
|
||
529 | * Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
|
||
530 | * new String[2]; attributes =
|
||
531 | * (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
|
||
532 | * ValueFactory.createValue(new String((String)attributes[1]));
|
||
533 | * if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
||
534 | * auxRow[9+j] = ValueFactory.createValue(new
|
||
535 | * String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
|
||
536 | * new FPoint2D(pto.getX(),pto.getY()); addShape(nuevoShp,
|
||
537 | * auxRow); } else if (fea.getGeometry() instanceof InsPoint3D) {
|
||
538 | * InsPoint3D insPoint = (InsPoint3D)fea.getGeometry(); Point3D
|
||
539 | * pto = new Point3D(); pto = (Point3D)insPoint.getPoint3D(0);
|
||
540 | * auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
||
541 | * auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
|
||
542 | * String("PointZ")); auxRow[ID_FIELD_ENTITY] =
|
||
543 | * ValueFactory.createValue(new
|
||
544 | * String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
|
||
545 | * ValueFactory.createValue(new String(fea.getProp("layer")));
|
||
546 | * int auxInt = Integer.parseInt(fea.getProp("color"));
|
||
547 | * auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
||
548 | * double auxE = Double.parseDouble(fea.getProp("elevation"));
|
||
549 | * auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
|
||
550 | * Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
|
||
551 | * new String[2]; attributes =
|
||
552 | * (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
|
||
553 | * ValueFactory.createValue(new String((String)attributes[1]));
|
||
554 | * if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
||
555 | * auxRow[9+j] = ValueFactory.createValue(new
|
||
556 | * String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
|
||
557 | * new FPoint3D(pto.getX(),pto.getY(),pto.getZ());
|
||
558 | * addShape(nuevoShp, auxRow);
|
||
559 | */
|
||
560 | } else if (fea.getGeometry() instanceof LineString |
||
561 | && !(fea.getGeometry() instanceof LineString3D)) {
|
||
562 | 758 | jmorell | GeneralPathX genPathX = new GeneralPathX();
|
563 | Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
||
564 | 4937 | fjp | for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
565 | pts[j] = (Point2D) fea.getGeometry().get(j);
|
||
566 | 758 | jmorell | } |
567 | genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
||
568 | 4937 | fjp | for (int j = 1; j < pts.length; j++) { |
569 | 758 | jmorell | genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
570 | } |
||
571 | 4937 | fjp | // double[] elevations = new double[pts.length];
|
572 | // for (int j=0;j<pts.length;j++) {
|
||
573 | // elevations[j]=pts[j].getZ();
|
||
574 | // }
|
||
575 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
576 | auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
||
577 | "FPolyline2D"));
|
||
578 | auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
||
579 | fea.getProp("dxfEntity")));
|
||
580 | auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
||
581 | fea.getProp("layer")));
|
||
582 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
583 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
584 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
585 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
586 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
587 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
588 | // Attributes
|
||
589 | for (int j = 0; j < nAtt; j++) { |
||
590 | String[] attributes = new String[2]; |
||
591 | attributes = (String[]) featureMaker.getAttributes().get(j); |
||
592 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
593 | (String) attributes[1])); |
||
594 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
595 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
596 | fea.getProp(attributes[0])));
|
||
597 | } |
||
598 | } |
||
599 | 758 | jmorell | FShape nuevoShp = new FPolyline2D(genPathX);
|
600 | addShape(nuevoShp, auxRow); |
||
601 | 2196 | vcaballero | } else if (fea.getGeometry() instanceof LineString3D) { |
602 | 758 | jmorell | GeneralPathX genPathX = new GeneralPathX();
|
603 | 2196 | vcaballero | Point3D[] pts = new Point3D[fea.getGeometry().pointNr()]; |
604 | 4937 | fjp | for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
605 | pts[j] = ((LineString3D) fea.getGeometry()).getPoint3D(j); |
||
606 | 2196 | vcaballero | } |
607 | genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
||
608 | 4937 | fjp | for (int j = 1; j < pts.length; j++) { |
609 | 2196 | vcaballero | genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
610 | } |
||
611 | 4937 | fjp | double[] elevations = new double[pts.length]; |
612 | for (int j = 0; j < pts.length; j++) { |
||
613 | elevations[j] = pts[j].getZ(); |
||
614 | } |
||
615 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
616 | auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
||
617 | "FPolyline3D"));
|
||
618 | auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
||
619 | fea.getProp("dxfEntity")));
|
||
620 | auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
||
621 | fea.getProp("layer")));
|
||
622 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
623 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
624 | if (fea.getProp("elevation") != null) { |
||
625 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
626 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
627 | } |
||
628 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
629 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
630 | // Attributes
|
||
631 | for (int j = 0; j < nAtt; j++) { |
||
632 | String[] attributes = new String[2]; |
||
633 | attributes = (String[]) featureMaker.getAttributes().get(j); |
||
634 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
635 | (String) attributes[1])); |
||
636 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
637 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
638 | fea.getProp(attributes[0])));
|
||
639 | } |
||
640 | } |
||
641 | 2196 | vcaballero | FShape nuevoShp = new FPolyline3D(genPathX, elevations);
|
642 | addShape(nuevoShp, auxRow); |
||
643 | 4937 | fjp | } else if (fea.getGeometry() instanceof Polygon |
644 | && !(fea.getGeometry() instanceof Polygon3D)) {
|
||
645 | 2196 | vcaballero | GeneralPathX genPathX = new GeneralPathX();
|
646 | 4937 | fjp | // 050112: A?ado una posici?n m?s para el punto que cierra y
|
647 | // creo el objeto firstPt.
|
||
648 | 936 | jmorell | Point2D firstPt = new Point2D.Double(); |
649 | 4937 | fjp | firstPt = (Point2D) fea.getGeometry().get(0); |
650 | Point2D[] pts = new Point2D[fea.getGeometry().pointNr() + 1]; |
||
651 | for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
||
652 | pts[j] = (Point2D) fea.getGeometry().get(j);
|
||
653 | 758 | jmorell | } |
654 | 4937 | fjp | // 050112: A?ado el primer punto al final para cerrar los
|
655 | // pol?gonos.
|
||
656 | 936 | jmorell | pts[fea.getGeometry().pointNr()] = firstPt; |
657 | 758 | jmorell | genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
658 | 4937 | fjp | for (int j = 1; j < pts.length; j++) { |
659 | 758 | jmorell | genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
660 | } |
||
661 | 4937 | fjp | // double[] elevations = new double[pts.length];
|
662 | // for (int j=0;j<pts.length;j++) {
|
||
663 | // elevations[j]=pts[j].getZ();
|
||
664 | // }
|
||
665 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
666 | auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
||
667 | "FPolygon2D"));
|
||
668 | auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
||
669 | fea.getProp("dxfEntity")));
|
||
670 | auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
||
671 | fea.getProp("layer")));
|
||
672 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
673 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
674 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
675 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
676 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
677 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
678 | // Attributes
|
||
679 | for (int j = 0; j < nAtt; j++) { |
||
680 | String[] attributes = new String[2]; |
||
681 | attributes = (String[]) featureMaker.getAttributes().get(j); |
||
682 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
683 | (String) attributes[1])); |
||
684 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
685 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
686 | fea.getProp(attributes[0])));
|
||
687 | } |
||
688 | } |
||
689 | 758 | jmorell | FShape nuevoShp = new FPolygon2D(genPathX);
|
690 | addShape(nuevoShp, auxRow); |
||
691 | 2196 | vcaballero | } else if (fea.getGeometry() instanceof Polygon3D) { |
692 | GeneralPathX genPathX = new GeneralPathX();
|
||
693 | 4937 | fjp | // 050112: A?ado una posici?n m?s para el punto que cierra y
|
694 | // creo el objeto firstPt.
|
||
695 | 2196 | vcaballero | Point3D firstPt = new Point3D();
|
696 | 4937 | fjp | firstPt = (Point3D) ((Polygon3D) fea.getGeometry()) |
697 | .getPoint3D(0);
|
||
698 | Point3D[] pts = new Point3D[fea.getGeometry().pointNr() + 1]; |
||
699 | for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
||
700 | pts[j] = (Point3D) ((Polygon3D) fea.getGeometry()) |
||
701 | .getPoint3D(j); |
||
702 | 2196 | vcaballero | } |
703 | 4937 | fjp | // 050112: A?ado el primer punto al final para cerrar los
|
704 | // pol?gonos.
|
||
705 | 2196 | vcaballero | pts[fea.getGeometry().pointNr()] = firstPt; |
706 | genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
||
707 | 4937 | fjp | for (int j = 1; j < pts.length; j++) { |
708 | 2196 | vcaballero | genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
709 | } |
||
710 | 4937 | fjp | double[] elevations = new double[pts.length]; |
711 | for (int j = 0; j < pts.length; j++) { |
||
712 | elevations[j] = pts[j].getZ(); |
||
713 | } |
||
714 | auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
||
715 | auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
||
716 | "FPolygon3D"));
|
||
717 | auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
||
718 | fea.getProp("dxfEntity")));
|
||
719 | auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
||
720 | fea.getProp("layer")));
|
||
721 | int auxInt = Integer.parseInt(fea.getProp("color")); |
||
722 | auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
||
723 | if (fea.getProp("elevation") != null) { |
||
724 | double auxE = Double.parseDouble(fea.getProp("elevation")); |
||
725 | auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
||
726 | } |
||
727 | double auxT = Double.parseDouble(fea.getProp("thickness")); |
||
728 | auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
||
729 | // Attributes
|
||
730 | for (int j = 0; j < nAtt; j++) { |
||
731 | String[] attributes = new String[2]; |
||
732 | attributes = (String[]) featureMaker.getAttributes().get(j); |
||
733 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
734 | (String) attributes[1])); |
||
735 | if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
||
736 | auxRow[10 + j] = ValueFactory.createValue(new String( |
||
737 | fea.getProp(attributes[0])));
|
||
738 | } |
||
739 | } |
||
740 | 2196 | vcaballero | FShape nuevoShp = new FPolygon3D(genPathX, elevations);
|
741 | addShape(nuevoShp, auxRow); |
||
742 | 758 | jmorell | } else {
|
743 | 4937 | fjp | // System.out.println("Detectado feature desconocido");
|
744 | 758 | jmorell | } |
745 | } |
||
746 | 4937 | fjp | |
747 | defaultLegend = LegendFactory |
||
748 | .createVectorialUniqueValueLegend(getShapeType()); |
||
749 | 758 | jmorell | defaultLegend.setFieldName("Color");
|
750 | 936 | jmorell | defaultLegend.setLabelField("Text");
|
751 | 839 | jmorell | defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
|
752 | defaultLegend.getDefaultSymbol().setShapeVisible(false);
|
||
753 | defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
|
||
754 | 4937 | fjp | defaultLegend.getDefaultSymbol().setFont( |
755 | new Font("SansSerif", Font.PLAIN, 9)); |
||
756 | 839 | jmorell | defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
|
757 | defaultLegend.getDefaultSymbol().setFontSize(heightText); |
||
758 | 4937 | fjp | defaultLegend.getDefaultSymbol().setStyle( |
759 | FConstant.SYMBOL_STYLE_DGNSPECIAL); |
||
760 | 1461 | jmorell | defaultLegend.getDefaultSymbol().setSize(3);
|
761 | 1402 | fjp | defaultLegend.getDefaultSymbol().setSizeInPixels(true);
|
762 | 4937 | fjp | |
763 | 839 | jmorell | defaultLegend.setLabelHeightField("HeightText");
|
764 | defaultLegend.setLabelRotationField("RotationText");
|
||
765 | 4937 | fjp | |
766 | 1828 | fernando | ObjectDriver rs = this;
|
767 | 758 | jmorell | IntValue clave; |
768 | FSymbol theSymbol = null;
|
||
769 | 4937 | fjp | |
770 | 758 | jmorell | try {
|
771 | 4937 | fjp | // TODO: Provisional hasta que cambiemos los s?mbolos.
|
772 | /*
|
||
773 | * BufferedImage bi= new BufferedImage(5, 5,
|
||
774 | * BufferedImage.TYPE_INT_ARGB); Graphics2D big =
|
||
775 | * bi.createGraphics(); Color color=new Color(0,0,0,0);
|
||
776 | * big.setBackground(color); big.clearRect(0, 0, 5, 5); Paint
|
||
777 | * fillProv = null; Rectangle2D rProv = new Rectangle();
|
||
778 | * rProv.setFrame(0, 0,5,5); fillProv = new TexturePaint(bi,rProv);
|
||
779 | */
|
||
780 | |||
781 | for (long j = 0; j < rs.getRowCount(); j++) { |
||
782 | clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR); |
||
783 | if (defaultLegend.getSymbolByValue(clave) == null) { |
||
784 | 936 | jmorell | theSymbol = new FSymbol(getShapeType());
|
785 | 758 | jmorell | theSymbol.setDescription(clave.toString()); |
786 | theSymbol.setColor(AcadColor.getColor(clave.getValue())); |
||
787 | 1402 | fjp | // theSymbol.setFill(fillProv);
|
788 | 4937 | fjp | // 050202, jmorell: Asigna los colores de Autocad a los
|
789 | // bordes
|
||
790 | // de los pol?gonos.
|
||
791 | theSymbol.setOutlineColor(AcadColor.getColor(clave |
||
792 | .getValue())); |
||
793 | |||
794 | 1402 | fjp | theSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL); |
795 | 1461 | jmorell | theSymbol.setSize(3);
|
796 | 1402 | fjp | theSymbol.setSizeInPixels(true);
|
797 | 4937 | fjp | |
798 | 758 | jmorell | defaultLegend.addSymbol(clave, theSymbol); |
799 | } |
||
800 | } // for
|
||
801 | } catch (DriverException e) {
|
||
802 | e.printStackTrace(); |
||
803 | 4937 | fjp | throw new IOException( |
804 | "Error al poner la leyenda por defecto en el DXF");
|
||
805 | 758 | jmorell | } |
806 | } |
||
807 | |||
808 | 4937 | fjp | /*
|
809 | * (non-Javadoc)
|
||
810 | 5389 | caballero | *
|
811 | 758 | jmorell | * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
|
812 | */
|
||
813 | public boolean accept(File f) { |
||
814 | return f.getName().toUpperCase().endsWith("DXF"); |
||
815 | } |
||
816 | |||
817 | 4937 | fjp | /*
|
818 | * (non-Javadoc)
|
||
819 | 5389 | caballero | *
|
820 | 758 | jmorell | * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getShapeType()
|
821 | */
|
||
822 | public int getShapeType() { |
||
823 | 839 | jmorell | return FShape.MULTI;
|
824 | 758 | jmorell | } |
825 | |||
826 | 4937 | fjp | /*
|
827 | * (non-Javadoc)
|
||
828 | 5389 | caballero | *
|
829 | 758 | jmorell | * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getName()
|
830 | */
|
||
831 | public String getName() { |
||
832 | return "gvSIG DXF Memory Driver"; |
||
833 | } |
||
834 | |||
835 | 4937 | fjp | /*
|
836 | * (non-Javadoc)
|
||
837 | 5389 | caballero | *
|
838 | 758 | jmorell | * @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
|
839 | */
|
||
840 | public Legend getDefaultLegend() {
|
||
841 | return defaultLegend;
|
||
842 | } |
||
843 | |||
844 | 4937 | fjp | /*
|
845 | * (non-Javadoc)
|
||
846 | 5389 | caballero | *
|
847 | 4937 | fjp | * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
|
848 | */
|
||
849 | public DriverAttributes getDriverAttributes() {
|
||
850 | return attr;
|
||
851 | } |
||
852 | 2183 | fernando | |
853 | 4937 | fjp | /**
|
854 | * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys()
|
||
855 | */
|
||
856 | public int[] getPrimaryKeys() throws DriverException { |
||
857 | return null; |
||
858 | } |
||
859 | 2217 | fernando | |
860 | 4937 | fjp | /**
|
861 | * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#write(com.hardcode.gdbms.engine.data.edition.DataWare)
|
||
862 | */
|
||
863 | public void write(DataWare arg0) throws DriverException { |
||
864 | // TODO Auto-generated method stub
|
||
865 | 2880 | fernando | |
866 | 4937 | fjp | } |
867 | |||
868 | /*
|
||
869 | * (non-Javadoc)
|
||
870 | 5389 | caballero | *
|
871 | 4937 | fjp | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()
|
872 | */
|
||
873 | public void close() throws IOException { |
||
874 | // TODO Auto-generated method stub
|
||
875 | |||
876 | } |
||
877 | |||
878 | 3720 | fjp | public File getFile() { |
879 | return m_Fich;
|
||
880 | } |
||
881 | 3271 | fjp | |
882 | 4937 | fjp | public boolean canWriteGeometry(int gvSIGgeometryType) { |
883 | return dxfWriter.canWriteGeometry(gvSIGgeometryType);
|
||
884 | } |
||
885 | 3720 | fjp | |
886 | 5558 | fjp | public void initialize(ITableDefinition layerDef) throws EditionException { |
887 | 4937 | fjp | int aux = (int) (Math.random() * 1000); |
888 | fTemp = new File(tempDirectoryPath + "/tmpDxf" + aux + ".dxf"); |
||
889 | dxfWriter.setFile(fTemp); |
||
890 | |||
891 | 5558 | fjp | dxfWriter.initialize(layerDef); |
892 | 4937 | fjp | /*
|
893 | * arrayFields.add("ID"); arrayFields.add("FShape");
|
||
894 | * arrayFields.add("Entity"); arrayFields.add("Layer");
|
||
895 | * arrayFields.add("Color"); arrayFields.add("Elevation");
|
||
896 | * arrayFields.add("Thickness"); arrayFields.add("Text");
|
||
897 | * arrayFields.add("HeightText"); arrayFields.add("RotationText");
|
||
898 | */
|
||
899 | |||
900 | DxfFieldsMapping fieldsMapping = new DxfFieldsMapping();
|
||
901 | fieldsMapping.setLayerField("Layer");
|
||
902 | fieldsMapping.setColorField("Color");
|
||
903 | fieldsMapping.setElevationField("Elevation");
|
||
904 | fieldsMapping.setThicknessField("Thickness");
|
||
905 | fieldsMapping.setTextField("Text");
|
||
906 | fieldsMapping.setHeightText("HeightText");
|
||
907 | fieldsMapping.setRotationText("Layer");
|
||
908 | dxfWriter.setFieldMapping(fieldsMapping); |
||
909 | 5558 | fjp | dxfWriter.setProjection(((ILayerDefinition)layerDef).getProjection()); |
910 | 4937 | fjp | } |
911 | |||
912 | public void preProcess() throws EditionException { |
||
913 | dxfWriter.preProcess(); |
||
914 | } |
||
915 | |||
916 | public void process(IRowEdited row) throws EditionException { |
||
917 | dxfWriter.process(row); |
||
918 | } |
||
919 | |||
920 | public void postProcess() throws EditionException { |
||
921 | dxfWriter.postProcess(); |
||
922 | try {
|
||
923 | |||
924 | // close();
|
||
925 | |||
926 | // Dxf
|
||
927 | FileChannel fcinDxf = new FileInputStream(fTemp).getChannel(); |
||
928 | FileChannel fcoutDxf = new FileOutputStream(m_Fich).getChannel(); |
||
929 | DriverUtilities.copy(fcinDxf, fcoutDxf); |
||
930 | |||
931 | // Borramos los temporales
|
||
932 | fTemp.delete(); |
||
933 | 6323 | fjp | reload(); |
934 | 4937 | fjp | |
935 | } catch (FileNotFoundException e) { |
||
936 | e.printStackTrace(); |
||
937 | throw new EditionException(e); |
||
938 | } catch (IOException e) { |
||
939 | e.printStackTrace(); |
||
940 | throw new EditionException(e); |
||
941 | 6323 | fjp | } catch (DriverException e) {
|
942 | e.printStackTrace(); |
||
943 | throw new EditionException(e); |
||
944 | 4937 | fjp | } |
945 | |||
946 | } |
||
947 | |||
948 | public String getCapability(String capability) { |
||
949 | return dxfWriter.getCapability(capability);
|
||
950 | } |
||
951 | |||
952 | public void setCapabilities(Properties capabilities) { |
||
953 | dxfWriter.setCapabilities(capabilities); |
||
954 | |||
955 | } |
||
956 | |||
957 | public boolean canWriteAttribute(int sqlType) { |
||
958 | return dxfWriter.canWriteAttribute(sqlType);
|
||
959 | } |
||
960 | 6521 | azabala | |
961 | /**
|
||
962 | * Returns de field type of the specified field index.
|
||
963 | * @return field type of i field
|
||
964 | */
|
||
965 | public int getFieldType(int i) throws DriverException { |
||
966 | //azabala: we overwrite MemoryDriver because type resolution
|
||
967 | //is based in first register value (it could be null)
|
||
968 | if(i >= fields.length)
|
||
969 | throw new DriverException("Excedido el numero de campos del dxf"); |
||
970 | return fields[i].getFieldType();
|
||
971 | } |
||
972 | 4937 | fjp | |
973 | /*
|
||
974 | * (non-Javadoc)
|
||
975 | 5389 | caballero | *
|
976 | 4937 | fjp | * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#reLoad()
|
977 | */
|
||
978 | 6323 | fjp | public void reload() throws IOException, DriverException { |
979 | super.reload();
|
||
980 | 4937 | fjp | try {
|
981 | initialize(); |
||
982 | } catch (IOException e) { |
||
983 | e.printStackTrace(); |
||
984 | throw new IOException("DXF: Error reloading " + path + " file."); |
||
985 | } |
||
986 | } |
||
987 | |||
988 | 5389 | caballero | public void setFlatness(double flatness) { |
989 | // TODO Auto-generated method stub
|
||
990 | |||
991 | } |
||
992 | |||
993 | 5521 | caballero | public boolean isWritable() { |
994 | return m_Fich.canWrite();
|
||
995 | } |
||
996 | |||
997 | 5595 | fjp | public IWriter getWriter() {
|
998 | return this; |
||
999 | } |
||
1000 | |||
1001 | 6259 | fjp | public ITableDefinition getTableDefinition() {
|
1002 | return dxfWriter.getTableDefinition();
|
||
1003 | } |
||
1004 | |||
1005 | 6356 | fjp | public boolean canAlterTable() { |
1006 | return false; |
||
1007 | } |
||
1008 | |||
1009 | 758 | jmorell | } |