svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dxf / DXFMemoryDriver.java @ 23888
History | View | Annotate | Download (34.3 KB)
1 |
/*
|
---|---|
2 |
* @(#)DXFMemoryDriver 29-dic-2004
|
3 |
*
|
4 |
* @author jmorell (jose.morell@gmail.com)
|
5 |
*/
|
6 |
/* 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 |
package com.iver.cit.gvsig.fmap.drivers.dxf; |
47 |
|
48 |
import java.awt.Color; |
49 |
import java.awt.geom.Point2D; |
50 |
import java.io.File; |
51 |
import java.io.FileInputStream; |
52 |
import java.io.FileNotFoundException; |
53 |
import java.io.FileOutputStream; |
54 |
import java.io.IOException; |
55 |
import java.nio.channels.FileChannel; |
56 |
import java.sql.Types; |
57 |
import java.util.ArrayList; |
58 |
import java.util.Properties; |
59 |
import java.util.logging.Logger; |
60 |
|
61 |
import javax.swing.table.DefaultTableModel; |
62 |
|
63 |
import org.cresques.cts.IProjection; |
64 |
import org.cresques.geo.Point3D; |
65 |
import org.cresques.io.DxfFile; |
66 |
import org.cresques.px.IObjList; |
67 |
import org.cresques.px.dxf.AcadColor; |
68 |
import org.cresques.px.dxf.DxfFeatureMaker; |
69 |
import org.cresques.px.dxf.DxfHeaderManager; |
70 |
import org.cresques.px.gml.Feature; |
71 |
import org.cresques.px.gml.LineString; |
72 |
import org.cresques.px.gml.LineString3D; |
73 |
import org.cresques.px.gml.Point; |
74 |
import org.cresques.px.gml.Polygon; |
75 |
import org.cresques.px.gml.Polygon3D; |
76 |
|
77 |
import com.hardcode.gdbms.driver.DriverUtilities; |
78 |
import com.hardcode.gdbms.driver.exceptions.FileNotFoundDriverException; |
79 |
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException; |
80 |
import com.hardcode.gdbms.driver.exceptions.InitializeWriterException; |
81 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
82 |
import com.hardcode.gdbms.driver.exceptions.ReloadDriverException; |
83 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
84 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
85 |
import com.hardcode.gdbms.engine.values.IntValue; |
86 |
import com.hardcode.gdbms.engine.values.Value; |
87 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
88 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessWriterVisitorException; |
89 |
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException; |
90 |
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException; |
91 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
92 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
93 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
94 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
95 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
96 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
97 |
import com.iver.cit.gvsig.fmap.core.FShape; |
98 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
99 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
100 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
101 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
102 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
103 |
import com.iver.cit.gvsig.fmap.drivers.AbstractCadMemoryDriver; |
104 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
105 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
106 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
107 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
108 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
109 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
110 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
111 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
112 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
113 |
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfFieldsMapping; |
114 |
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfWriter; |
115 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
116 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
117 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
118 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy; |
119 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy; |
120 |
|
121 |
/**
|
122 |
* @author jmorell (jose.morell@gmail.com)
|
123 |
* @author azabala
|
124 |
* @version 29-dic-2004
|
125 |
*/
|
126 |
public class DXFMemoryDriver extends AbstractCadMemoryDriver implements |
127 |
VectorialFileDriver, WithDefaultLegend, ISpatialWriter, IWriteable { |
128 |
|
129 |
private static String tempDirectoryPath = System |
130 |
.getProperty("java.io.tmpdir");
|
131 |
|
132 |
|
133 |
private DxfWriter dxfWriter = new DxfWriter(); |
134 |
private File fTemp; |
135 |
VectorialUniqueValueLegend defaultLegend; |
136 |
private File m_Fich; |
137 |
private DxfFile.EntityFactory featureMaker;
|
138 |
private DxfFile dxfFeatureFile;
|
139 |
private IObjList.vector features;
|
140 |
private DriverAttributes attr = new DriverAttributes(); |
141 |
|
142 |
/**
|
143 |
* Habilita la utilizaci?n del lector del HEADER del DXF.
|
144 |
*/
|
145 |
private DxfFile.VarSettings headerManager;
|
146 |
private AttrInTableLabelingStrategy labeling;
|
147 |
|
148 |
/*
|
149 |
* (non-Javadoc)
|
150 |
*
|
151 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#open(java.io.File)
|
152 |
*/
|
153 |
public void open(File f) { |
154 |
m_Fich = f; |
155 |
} |
156 |
|
157 |
public void initialize() throws ReadDriverException { |
158 |
float heightText = 10; |
159 |
|
160 |
attr.setLoadedInMemory(true);
|
161 |
|
162 |
IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
163 |
featureMaker = new DxfFeatureMaker(proj);
|
164 |
headerManager = new DxfHeaderManager();
|
165 |
dxfFeatureFile = new DxfFile(proj, m_Fich.getAbsolutePath(),
|
166 |
featureMaker, headerManager); |
167 |
try {
|
168 |
dxfFeatureFile.load(); |
169 |
} catch (Exception e1) { |
170 |
// throw new FileNotFoundDriverException(getName(),e1);
|
171 |
} |
172 |
features = (IObjList.vector) ((DxfFeatureMaker) featureMaker) |
173 |
.getObjects(); |
174 |
String acadVersion = (String) ((DxfHeaderManager) headerManager) |
175 |
.getAcadVersion(); |
176 |
System.out.println("initialize(): acadVersion = " + acadVersion); |
177 |
if (!featureMaker.isDxf3DFile() && !headerManager.isWritedDxf3D()) { // y no |
178 |
// est?n
|
179 |
// todos
|
180 |
// a
|
181 |
// 9999
|
182 |
Feature[] features2D = new Feature[features.size()]; |
183 |
for (int i = 0; i < features.size(); i++) { |
184 |
Feature fea = (Feature) features.get(i); |
185 |
if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
186 |
Point point = (Point) fea.getGeometry(); |
187 |
Point point2 = new Point(); |
188 |
for (int j = 0; j < point.pointNr(); j++) { |
189 |
point2.add(point.get(j)); |
190 |
} |
191 |
point2.setTextPoint(point.isTextPoint()); |
192 |
fea.setGeometry(point2); |
193 |
features2D[i] = fea; |
194 |
// } else if (fea.getGeometry() instanceof InsPoint3D) {
|
195 |
// InsPoint insPoint = (InsPoint)fea.getGeometry();
|
196 |
// InsPoint insPoint2 = new InsPoint();
|
197 |
// for (int j=0;j<insPoint.pointNr();j++) {
|
198 |
// insPoint2.add(insPoint.get(j));
|
199 |
// }
|
200 |
// fea.setGeometry(insPoint2);
|
201 |
// features2D[i] = fea;
|
202 |
} else if (fea.getGeometry() instanceof LineString3D) { |
203 |
LineString lineString = (LineString) fea.getGeometry(); |
204 |
LineString lineString2 = new LineString();
|
205 |
for (int j = 0; j < lineString.pointNr(); j++) { |
206 |
lineString2.add(lineString.get(j)); |
207 |
} |
208 |
fea.setGeometry(lineString2); |
209 |
features2D[i] = fea; |
210 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
211 |
Polygon polygon = (Polygon) fea.getGeometry(); |
212 |
Polygon polygon2 = new Polygon(); |
213 |
for (int j = 0; j < polygon.pointNr(); j++) { |
214 |
polygon2.add(polygon.get(j)); |
215 |
} |
216 |
fea.setGeometry(polygon2); |
217 |
features2D[i] = fea; |
218 |
} |
219 |
} |
220 |
features.clear(); |
221 |
for (int i = 0; i < features2D.length; i++) { |
222 |
features.add(features2D[i]); |
223 |
} |
224 |
} |
225 |
// String acadVersion =
|
226 |
// (String)((DxfHeaderManager)headerManager).getAcadVersion();
|
227 |
// System.out.println("initialize(): acadVersion = " + acadVersion);
|
228 |
|
229 |
int nAtt = featureMaker.getAttributes().size();
|
230 |
|
231 |
// Campos de las MemoryLayer:
|
232 |
Value[] auxRow = new Value[10 + nAtt]; |
233 |
ArrayList arrayFields = new ArrayList(); |
234 |
arrayFields.add("ID");
|
235 |
arrayFields.add("FShape");
|
236 |
arrayFields.add("Entity");
|
237 |
arrayFields.add("Layer");
|
238 |
arrayFields.add("Color");
|
239 |
arrayFields.add("Elevation");
|
240 |
arrayFields.add("Thickness");
|
241 |
arrayFields.add("Text");
|
242 |
arrayFields.add("HeightText");
|
243 |
arrayFields.add("RotationText");
|
244 |
for (int i = 0; i < nAtt; i++) { |
245 |
String att[] = new String[2]; |
246 |
att = (String[]) featureMaker.getAttributes().get(i); |
247 |
arrayFields.add(att[0]);
|
248 |
} |
249 |
|
250 |
labeling = new AttrInTableLabelingStrategy();
|
251 |
((AttrInTableLabelingStrategy) labeling).setTextFieldId(arrayFields.indexOf("Text"));
|
252 |
((AttrInTableLabelingStrategy) labeling).setRotationFieldId(arrayFields.indexOf("RotationText"));
|
253 |
((AttrInTableLabelingStrategy) labeling).setHeightFieldId(arrayFields.indexOf("HeightText"));
|
254 |
((AttrInTableLabelingStrategy) labeling).setUnit(1); //MapContext.NAMES[1] (meters) |
255 |
|
256 |
getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
257 |
|
258 |
for (int i = 0; i < features.size(); i++) { |
259 |
|
260 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0.0);
|
261 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0.0);
|
262 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
263 |
|
264 |
Feature fea = (Feature) features.get(i); |
265 |
if (fea.getGeometry() instanceof Point |
266 |
&& !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
|
267 |
Point point = (Point) fea.getGeometry(); |
268 |
Point2D pto = new Point2D.Double(); |
269 |
pto = point.get(0);
|
270 |
FShape nuevoShp; |
271 |
if (point.isTextPoint()) {
|
272 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
273 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory |
274 |
.createValue(new String("FPoint2D")); |
275 |
auxRow[ID_FIELD_ENTITY] = ValueFactory |
276 |
.createValue(new String(fea.getProp("dxfEntity"))); |
277 |
auxRow[ID_FIELD_LAYER] = ValueFactory |
278 |
.createValue(new String(fea.getProp("layer"))); |
279 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
280 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
281 |
auxRow[ID_FIELD_TEXT] = ValueFactory |
282 |
.createValue(new String(fea.getProp("text"))); |
283 |
heightText = Float.parseFloat(fea.getProp("textHeight")); |
284 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory |
285 |
.createValue(heightText); |
286 |
double auxR = Double.parseDouble(fea |
287 |
.getProp("textRotation"));
|
288 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory |
289 |
.createValue(auxR); |
290 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
291 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
292 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
293 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
294 |
// Attributes
|
295 |
for (int j = 0; j < nAtt; j++) { |
296 |
String[] attributes = new String[2]; |
297 |
attributes = (String[]) featureMaker.getAttributes() |
298 |
.get(j); |
299 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
300 |
attributes[1]));
|
301 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
302 |
auxRow[10 + j] = ValueFactory
|
303 |
.createValue(new String(fea |
304 |
.getProp(attributes[0])));
|
305 |
} |
306 |
} |
307 |
nuevoShp = new FPoint2D(pto.getX(), pto.getY());
|
308 |
addShape(nuevoShp, auxRow); |
309 |
} else {
|
310 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
311 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory |
312 |
.createValue(new String("FPoint2D")); |
313 |
auxRow[ID_FIELD_ENTITY] = ValueFactory |
314 |
.createValue(new String(fea.getProp("dxfEntity"))); |
315 |
auxRow[ID_FIELD_LAYER] = ValueFactory |
316 |
.createValue(new String(fea.getProp("layer"))); |
317 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
318 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
319 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
320 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
321 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
322 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
323 |
// Attributes
|
324 |
for (int j = 0; j < nAtt; j++) { |
325 |
String[] attributes = new String[2]; |
326 |
attributes = (String[]) featureMaker.getAttributes() |
327 |
.get(j); |
328 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
329 |
attributes[1]));
|
330 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
331 |
auxRow[10 + j] = ValueFactory
|
332 |
.createValue(new String(fea |
333 |
.getProp(attributes[0])));
|
334 |
} |
335 |
} |
336 |
nuevoShp = new FPoint2D(pto.getX(), pto.getY());
|
337 |
addShape(nuevoShp, auxRow); |
338 |
} |
339 |
} else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
340 |
org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D) fea |
341 |
.getGeometry(); |
342 |
Point3D pto = new Point3D();
|
343 |
pto = point.getPoint3D(0);
|
344 |
FShape nuevoShp; |
345 |
if (point.isTextPoint()) {
|
346 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
347 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory |
348 |
.createValue(new String("FPoint3D")); |
349 |
auxRow[ID_FIELD_ENTITY] = ValueFactory |
350 |
.createValue(new String(fea.getProp("dxfEntity"))); |
351 |
auxRow[ID_FIELD_LAYER] = ValueFactory |
352 |
.createValue(new String(fea.getProp("layer"))); |
353 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
354 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
355 |
auxRow[ID_FIELD_TEXT] = ValueFactory |
356 |
.createValue(new String(fea.getProp("text"))); |
357 |
heightText = Float.parseFloat(fea.getProp("textHeight")); |
358 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory |
359 |
.createValue(heightText); |
360 |
double auxR = Double.parseDouble(fea |
361 |
.getProp("textRotation"));
|
362 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory |
363 |
.createValue(auxR); |
364 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
365 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
366 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
367 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
368 |
// Attributes
|
369 |
for (int j = 0; j < nAtt; j++) { |
370 |
String[] attributes = new String[2]; |
371 |
attributes = (String[]) featureMaker.getAttributes() |
372 |
.get(j); |
373 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
374 |
attributes[1]));
|
375 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
376 |
auxRow[10 + j] = ValueFactory
|
377 |
.createValue(new String(fea |
378 |
.getProp(attributes[0])));
|
379 |
} |
380 |
} |
381 |
nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
|
382 |
addShape(nuevoShp, auxRow); |
383 |
} else {
|
384 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
385 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory |
386 |
.createValue(new String("FPoint3D")); |
387 |
auxRow[ID_FIELD_ENTITY] = ValueFactory |
388 |
.createValue(new String(fea.getProp("dxfEntity"))); |
389 |
auxRow[ID_FIELD_LAYER] = ValueFactory |
390 |
.createValue(new String(fea.getProp("layer"))); |
391 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
392 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
393 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
394 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
395 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
396 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
397 |
// Attributes
|
398 |
for (int j = 0; j < nAtt; j++) { |
399 |
String[] attributes = new String[2]; |
400 |
attributes = (String[]) featureMaker.getAttributes() |
401 |
.get(j); |
402 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
403 |
attributes[1]));
|
404 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
405 |
auxRow[10 + j] = ValueFactory
|
406 |
.createValue(new String(fea |
407 |
.getProp(attributes[0])));
|
408 |
} |
409 |
} |
410 |
nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
|
411 |
addShape(nuevoShp, auxRow); |
412 |
} |
413 |
/*
|
414 |
* } else if (fea.getGeometry() instanceof InsPoint &&
|
415 |
* !(fea.getGeometry() instanceof InsPoint3D)) { InsPoint
|
416 |
* insPoint = (InsPoint)fea.getGeometry(); Point2D pto = new
|
417 |
* Point2D.Double(); pto = (Point2D)insPoint.get(0);
|
418 |
* auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
419 |
* auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
|
420 |
* String("PointZ")); auxRow[ID_FIELD_ENTITY] =
|
421 |
* ValueFactory.createValue(new
|
422 |
* String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
|
423 |
* ValueFactory.createValue(new String(fea.getProp("layer")));
|
424 |
* int auxInt = Integer.parseInt(fea.getProp("color"));
|
425 |
* auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
426 |
* double auxE = Double.parseDouble(fea.getProp("elevation"));
|
427 |
* auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
|
428 |
* Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
|
429 |
* new String[2]; attributes =
|
430 |
* (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
|
431 |
* ValueFactory.createValue(new String((String)attributes[1]));
|
432 |
* if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
433 |
* auxRow[9+j] = ValueFactory.createValue(new
|
434 |
* String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
|
435 |
* new FPoint2D(pto.getX(),pto.getY()); addShape(nuevoShp,
|
436 |
* auxRow); } else if (fea.getGeometry() instanceof InsPoint3D) {
|
437 |
* InsPoint3D insPoint = (InsPoint3D)fea.getGeometry(); Point3D
|
438 |
* pto = new Point3D(); pto = (Point3D)insPoint.getPoint3D(0);
|
439 |
* auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
440 |
* auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
|
441 |
* String("PointZ")); auxRow[ID_FIELD_ENTITY] =
|
442 |
* ValueFactory.createValue(new
|
443 |
* String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
|
444 |
* ValueFactory.createValue(new String(fea.getProp("layer")));
|
445 |
* int auxInt = Integer.parseInt(fea.getProp("color"));
|
446 |
* auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
447 |
* double auxE = Double.parseDouble(fea.getProp("elevation"));
|
448 |
* auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
|
449 |
* Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
|
450 |
* new String[2]; attributes =
|
451 |
* (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
|
452 |
* ValueFactory.createValue(new String((String)attributes[1]));
|
453 |
* if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
454 |
* auxRow[9+j] = ValueFactory.createValue(new
|
455 |
* String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
|
456 |
* new FPoint3D(pto.getX(),pto.getY(),pto.getZ());
|
457 |
* addShape(nuevoShp, auxRow);
|
458 |
*/
|
459 |
} else if (fea.getGeometry() instanceof LineString |
460 |
&& !(fea.getGeometry() instanceof LineString3D)) {
|
461 |
GeneralPathX genPathX = new GeneralPathX();
|
462 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
463 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
464 |
pts[j] = fea.getGeometry().get(j); |
465 |
} |
466 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
467 |
for (int j = 1; j < pts.length; j++) { |
468 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
469 |
} |
470 |
// double[] elevations = new double[pts.length];
|
471 |
// for (int j=0;j<pts.length;j++) {
|
472 |
// elevations[j]=pts[j].getZ();
|
473 |
// }
|
474 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
475 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
476 |
"FPolyline2D"));
|
477 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
478 |
fea.getProp("dxfEntity")));
|
479 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
480 |
fea.getProp("layer")));
|
481 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
482 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
483 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
484 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
485 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
486 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
487 |
// Attributes
|
488 |
for (int j = 0; j < nAtt; j++) { |
489 |
String[] attributes = new String[2]; |
490 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
491 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
492 |
attributes[1]));
|
493 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
494 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
495 |
fea.getProp(attributes[0])));
|
496 |
} |
497 |
} |
498 |
FShape nuevoShp = new FPolyline2D(genPathX);
|
499 |
addShape(nuevoShp, auxRow); |
500 |
} else if (fea.getGeometry() instanceof LineString3D) { |
501 |
GeneralPathX genPathX = new GeneralPathX();
|
502 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()]; |
503 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
504 |
pts[j] = ((LineString3D) fea.getGeometry()).getPoint3D(j); |
505 |
} |
506 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
507 |
for (int j = 1; j < pts.length; j++) { |
508 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
509 |
} |
510 |
double[] elevations = new double[pts.length]; |
511 |
for (int j = 0; j < pts.length; j++) { |
512 |
elevations[j] = pts[j].getZ(); |
513 |
} |
514 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
515 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
516 |
"FPolyline3D"));
|
517 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
518 |
fea.getProp("dxfEntity")));
|
519 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
520 |
fea.getProp("layer")));
|
521 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
522 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
523 |
if (fea.getProp("elevation") != null) { |
524 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
525 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
526 |
} |
527 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
528 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
529 |
// Attributes
|
530 |
for (int j = 0; j < nAtt; j++) { |
531 |
String[] attributes = new String[2]; |
532 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
533 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
534 |
attributes[1]));
|
535 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
536 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
537 |
fea.getProp(attributes[0])));
|
538 |
} |
539 |
} |
540 |
FShape nuevoShp = new FPolyline3D(genPathX, elevations);
|
541 |
addShape(nuevoShp, auxRow); |
542 |
} else if (fea.getGeometry() instanceof Polygon |
543 |
&& !(fea.getGeometry() instanceof Polygon3D)) {
|
544 |
GeneralPathX genPathX = new GeneralPathX();
|
545 |
// 050112: A?ado una posici?n m?s para el punto que cierra y
|
546 |
// creo el objeto firstPt.
|
547 |
Point2D firstPt = new Point2D.Double(); |
548 |
firstPt = fea.getGeometry().get(0);
|
549 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr() + 1]; |
550 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
551 |
pts[j] = fea.getGeometry().get(j); |
552 |
} |
553 |
// 050112: A?ado el primer punto al final para cerrar los
|
554 |
// pol?gonos.
|
555 |
pts[fea.getGeometry().pointNr()] = firstPt; |
556 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
557 |
for (int j = 1; j < pts.length; j++) { |
558 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
559 |
} |
560 |
// double[] elevations = new double[pts.length];
|
561 |
// for (int j=0;j<pts.length;j++) {
|
562 |
// elevations[j]=pts[j].getZ();
|
563 |
// }
|
564 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
565 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
566 |
"FPolygon2D"));
|
567 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
568 |
fea.getProp("dxfEntity")));
|
569 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
570 |
fea.getProp("layer")));
|
571 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
572 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
573 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
574 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
575 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
576 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
577 |
// Attributes
|
578 |
for (int j = 0; j < nAtt; j++) { |
579 |
String[] attributes = new String[2]; |
580 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
581 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
582 |
attributes[1]));
|
583 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
584 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
585 |
fea.getProp(attributes[0])));
|
586 |
} |
587 |
} |
588 |
FShape nuevoShp = new FPolygon2D(genPathX);
|
589 |
addShape(nuevoShp, auxRow); |
590 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
591 |
GeneralPathX genPathX = new GeneralPathX();
|
592 |
// 050112: A?ado una posici?n m?s para el punto que cierra y
|
593 |
// creo el objeto firstPt.
|
594 |
Point2D firstPt = new Point3D(); |
595 |
Point2D p=((Polygon3D) fea.getGeometry())
|
596 |
.get(0);
|
597 |
if (p instanceof Point2D.Float){ |
598 |
firstPt=new Point3D(p);
|
599 |
}else
|
600 |
firstPt = p; |
601 |
Point2D[] pts = new Point3D[fea.getGeometry().pointNr() + 1]; |
602 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
603 |
p=((Polygon3D) fea.getGeometry()) |
604 |
.get(j); |
605 |
if (p instanceof Point2D.Float){ |
606 |
pts[j]=new Point3D(p);
|
607 |
}else
|
608 |
pts[j] = p; |
609 |
} |
610 |
// 050112: A?ado el primer punto al final para cerrar los
|
611 |
// pol?gonos.
|
612 |
pts[fea.getGeometry().pointNr()] = firstPt; |
613 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
614 |
for (int j = 1; j < pts.length; j++) { |
615 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
616 |
} |
617 |
double[] elevations = new double[pts.length]; |
618 |
for (int j = 0; j < pts.length; j++) { |
619 |
if (pts[j] instanceof Point3D) |
620 |
elevations[j] = ((Point3D)pts[j]).getZ(); |
621 |
} |
622 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
623 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String( |
624 |
"FPolygon3D"));
|
625 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String( |
626 |
fea.getProp("dxfEntity")));
|
627 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String( |
628 |
fea.getProp("layer")));
|
629 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
630 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
631 |
if (fea.getProp("elevation") != null) { |
632 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
633 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
634 |
} |
635 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
636 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
637 |
// Attributes
|
638 |
for (int j = 0; j < nAtt; j++) { |
639 |
String[] attributes = new String[2]; |
640 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
641 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
642 |
attributes[1]));
|
643 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
644 |
auxRow[10 + j] = ValueFactory.createValue(new String( |
645 |
fea.getProp(attributes[0])));
|
646 |
} |
647 |
} |
648 |
FShape nuevoShp = new FPolygon3D(genPathX, elevations);
|
649 |
addShape(nuevoShp, auxRow); |
650 |
} else {
|
651 |
// System.out.println("Detectado feature desconocido");
|
652 |
} |
653 |
} |
654 |
|
655 |
defaultLegend = LegendFactory |
656 |
.createVectorialUniqueValueLegend(getShapeType()); |
657 |
defaultLegend.setClassifyingFieldNames(new String[] {"Color"}); |
658 |
defaultLegend.setClassifyingFieldTypes(new int[]{Types.INTEGER,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.INTEGER,Types.DOUBLE,Types.DOUBLE}); |
659 |
|
660 |
Logger.getAnonymousLogger().info("DXFMemoryDriver: should check if this is a text symbol"); |
661 |
ISymbol myDefaultSymbol = SymbologyFactory. |
662 |
createDefaultSymbolByShapeType(getShapeType(), Color.BLACK);
|
663 |
|
664 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
665 |
|
666 |
ObjectDriver rs = this;
|
667 |
IntValue clave; |
668 |
ISymbol theSymbol = null;
|
669 |
|
670 |
try {
|
671 |
// TODO: Provisional hasta que cambiemos los s?mbolos.
|
672 |
/*
|
673 |
* BufferedImage bi= new BufferedImage(5, 5,
|
674 |
* BufferedImage.TYPE_INT_ARGB); Graphics2D big =
|
675 |
* bi.createGraphics(); Color color=new Color(0,0,0,0);
|
676 |
* big.setBackground(color); big.clearRect(0, 0, 5, 5); Paint
|
677 |
* fillProv = null; Rectangle2D rProv = new Rectangle();
|
678 |
* rProv.setFrame(0, 0,5,5); fillProv = new TexturePaint(bi,rProv);
|
679 |
*/
|
680 |
|
681 |
for (long j = 0; j < rs.getRowCount(); j++) { |
682 |
clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR); |
683 |
if (defaultLegend.getSymbolByValue(clave) == null) { |
684 |
/*
|
685 |
theSymbol = new FSymbol(getShapeType());
|
686 |
theSymbol.setDescription(clave.toString());
|
687 |
theSymbol.setColor(AcadColor.getColor(clave.getValue()));
|
688 |
// theSymbol.setFill(fillProv);
|
689 |
// 050202, jmorell: Asigna los colores de Autocad a los
|
690 |
// bordes
|
691 |
// de los pol?gonos.
|
692 |
theSymbol.setOutlineColor(AcadColor.getColor(clave
|
693 |
.getValue()));
|
694 |
|
695 |
theSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL);
|
696 |
theSymbol.setSize(3);
|
697 |
theSymbol.setSizeInPixels(true);
|
698 |
*/
|
699 |
|
700 |
// jaume, moved to ISymbol
|
701 |
theSymbol = SymbologyFactory. |
702 |
createDefaultSymbolByShapeType( |
703 |
getShapeType(), |
704 |
AcadColor.getColor(clave.getValue())); |
705 |
theSymbol.setDescription(clave.toString()); |
706 |
// Asigna los colores de Autocad a los
|
707 |
// bordes
|
708 |
// de los pol?gonos.
|
709 |
if (theSymbol instanceof IFillSymbol) { |
710 |
((IFillSymbol) theSymbol).getOutline().setLineColor(AcadColor.getColor(clave |
711 |
.getValue())); |
712 |
|
713 |
} |
714 |
defaultLegend.addSymbol(clave, theSymbol); |
715 |
} |
716 |
} // for
|
717 |
} catch (ReadDriverException e) {
|
718 |
throw new InitializeDriverException(getName(),e); |
719 |
} |
720 |
} |
721 |
|
722 |
/*
|
723 |
* (non-Javadoc)
|
724 |
*
|
725 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
|
726 |
*/
|
727 |
public boolean accept(File f) { |
728 |
return f.getName().toUpperCase().endsWith("DXF"); |
729 |
} |
730 |
|
731 |
/*
|
732 |
* (non-Javadoc)
|
733 |
*
|
734 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getShapeType()
|
735 |
*/
|
736 |
public int getShapeType() { |
737 |
return FShape.MULTI;
|
738 |
} |
739 |
|
740 |
/*
|
741 |
* (non-Javadoc)
|
742 |
*
|
743 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getName()
|
744 |
*/
|
745 |
public String getName() { |
746 |
return "gvSIG DXF Memory Driver"; |
747 |
} |
748 |
|
749 |
/*
|
750 |
* (non-Javadoc)
|
751 |
*
|
752 |
* @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
|
753 |
*/
|
754 |
public ILegend getDefaultLegend() {
|
755 |
return defaultLegend;
|
756 |
} |
757 |
|
758 |
/*
|
759 |
* (non-Javadoc)
|
760 |
*
|
761 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
|
762 |
*/
|
763 |
public DriverAttributes getDriverAttributes() {
|
764 |
return attr;
|
765 |
} |
766 |
|
767 |
/**
|
768 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys()
|
769 |
*/
|
770 |
public int[] getPrimaryKeys() { |
771 |
return null; |
772 |
} |
773 |
|
774 |
/**
|
775 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#write(com.hardcode.gdbms.engine.data.edition.DataWare)
|
776 |
*/
|
777 |
public void write(DataWare arg0) { |
778 |
// TODO Auto-generated method stub
|
779 |
|
780 |
} |
781 |
|
782 |
/*
|
783 |
* (non-Javadoc)
|
784 |
*
|
785 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()
|
786 |
*/
|
787 |
public void close() { |
788 |
// TODO Auto-generated method stub
|
789 |
|
790 |
} |
791 |
|
792 |
public File getFile() { |
793 |
return m_Fich;
|
794 |
} |
795 |
|
796 |
public boolean canWriteGeometry(int gvSIGgeometryType) { |
797 |
return dxfWriter.canWriteGeometry(gvSIGgeometryType);
|
798 |
} |
799 |
|
800 |
public void initialize(ITableDefinition layerDef) throws InitializeWriterException { |
801 |
int aux = (int) (Math.random() * 1000); |
802 |
fTemp = new File(tempDirectoryPath + "/tmpDxf" + aux + ".dxf"); |
803 |
dxfWriter.setFile(fTemp); |
804 |
|
805 |
dxfWriter.initialize(layerDef); |
806 |
/*
|
807 |
* arrayFields.add("ID"); arrayFields.add("FShape");
|
808 |
* arrayFields.add("Entity"); arrayFields.add("Layer");
|
809 |
* arrayFields.add("Color"); arrayFields.add("Elevation");
|
810 |
* arrayFields.add("Thickness"); arrayFields.add("Text");
|
811 |
* arrayFields.add("HeightText"); arrayFields.add("RotationText");
|
812 |
*/
|
813 |
|
814 |
DxfFieldsMapping fieldsMapping = new DxfFieldsMapping();
|
815 |
fieldsMapping.setLayerField("Layer");
|
816 |
fieldsMapping.setColorField("Color");
|
817 |
fieldsMapping.setElevationField("Elevation");
|
818 |
fieldsMapping.setThicknessField("Thickness");
|
819 |
fieldsMapping.setTextField("Text");
|
820 |
fieldsMapping.setHeightText("HeightText");
|
821 |
fieldsMapping.setRotationText("Layer");
|
822 |
dxfWriter.setFieldMapping(fieldsMapping); |
823 |
dxfWriter.setProjection(((ILayerDefinition)layerDef).getProjection()); |
824 |
} |
825 |
|
826 |
public void preProcess() throws StartWriterVisitorException { |
827 |
dxfWriter.preProcess(); |
828 |
} |
829 |
|
830 |
public void process(IRowEdited row) throws ProcessWriterVisitorException { |
831 |
dxfWriter.process(row); |
832 |
} |
833 |
|
834 |
public void postProcess() throws StopWriterVisitorException { |
835 |
dxfWriter.postProcess(); |
836 |
try {
|
837 |
|
838 |
// close();
|
839 |
|
840 |
// Dxf
|
841 |
FileChannel fcinDxf = new FileInputStream(fTemp).getChannel(); |
842 |
FileChannel fcoutDxf = new FileOutputStream(m_Fich).getChannel(); |
843 |
DriverUtilities.copy(fcinDxf, fcoutDxf); |
844 |
|
845 |
// Borramos los temporales
|
846 |
fTemp.delete(); |
847 |
// reload();
|
848 |
|
849 |
} catch (FileNotFoundException e) { |
850 |
throw new StopWriterVisitorException(getName(),e); |
851 |
} catch (IOException e) { |
852 |
throw new StopWriterVisitorException(getName(),e); |
853 |
} |
854 |
|
855 |
} |
856 |
|
857 |
public String getCapability(String capability) { |
858 |
return dxfWriter.getCapability(capability);
|
859 |
} |
860 |
|
861 |
public void setCapabilities(Properties capabilities) { |
862 |
dxfWriter.setCapabilities(capabilities); |
863 |
|
864 |
} |
865 |
|
866 |
public boolean canWriteAttribute(int sqlType) { |
867 |
return dxfWriter.canWriteAttribute(sqlType);
|
868 |
} |
869 |
|
870 |
|
871 |
public void reload() throws ReloadDriverException { |
872 |
super.reload();
|
873 |
try {
|
874 |
initialize(); |
875 |
} catch (InitializeDriverException e) {
|
876 |
throw new ReloadDriverException(getName(),e); |
877 |
} catch (ReadDriverException e) {
|
878 |
throw new ReloadDriverException(getName(),e); |
879 |
} |
880 |
} |
881 |
|
882 |
public boolean isWritable() { |
883 |
return m_Fich.canWrite();
|
884 |
} |
885 |
|
886 |
public IWriter getWriter() {
|
887 |
return this; |
888 |
} |
889 |
|
890 |
public ITableDefinition getTableDefinition() {
|
891 |
return dxfWriter.getTableDefinition();
|
892 |
} |
893 |
|
894 |
public boolean canAlterTable() { |
895 |
return false; |
896 |
} |
897 |
|
898 |
public boolean canSaveEdits() { |
899 |
return dxfWriter.canSaveEdits();
|
900 |
} |
901 |
|
902 |
/**
|
903 |
* Returns the drawing entity associated to an FMap feature
|
904 |
* */
|
905 |
public Object getCadSource(int index) { |
906 |
IObjList.vector vector = (IObjList.vector) ((DxfFeatureMaker) featureMaker) |
907 |
.getObjects(); |
908 |
return vector.get(index);
|
909 |
} |
910 |
|
911 |
public boolean isWriteAll() { |
912 |
return true; |
913 |
} |
914 |
|
915 |
public ILabelingStrategy getDefaultLabelingStrategy() {
|
916 |
return labeling;
|
917 |
} |
918 |
public int getFieldType(int i) { |
919 |
DefaultTableModel dtm=getTableModel();
|
920 |
String columnName=dtm.getColumnName(i);
|
921 |
if (columnName.equals("ID")){ |
922 |
return Types.INTEGER; |
923 |
} else if (columnName.equals("FShape")){ |
924 |
return Types.VARCHAR; |
925 |
} else if (columnName.equals("Entity")){ |
926 |
return Types.VARCHAR; |
927 |
} else if (columnName.equals("Layer")){ |
928 |
return Types.VARCHAR; |
929 |
} else if (columnName.equals("Color")){ |
930 |
return Types.INTEGER; |
931 |
} else if (columnName.equals("Elevation")){ |
932 |
return Types.DOUBLE; |
933 |
} else if (columnName.equals("Thickness")){ |
934 |
return Types.DOUBLE; |
935 |
} else if (columnName.equals("HeightText")){ |
936 |
return Types.DOUBLE; |
937 |
} else if (columnName.equals("RotationText")){ |
938 |
return Types.DOUBLE; |
939 |
} else if (columnName.equals("Text")){ |
940 |
return Types.VARCHAR; |
941 |
} else{
|
942 |
return Types.VARCHAR; |
943 |
} |
944 |
} |
945 |
} |