root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dwg / DwgMemoryDriver.java @ 1888
History | View | Annotate | Download (72 KB)
1 |
/*
|
---|---|
2 |
* Created on 14-abr-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.fmap.drivers.dwg; |
45 |
|
46 |
import java.awt.Color; |
47 |
import java.awt.Font; |
48 |
import java.awt.geom.Point2D; |
49 |
import java.io.File; |
50 |
import java.io.IOException; |
51 |
import java.util.ArrayList; |
52 |
import java.util.Vector; |
53 |
|
54 |
import net.jmorell.javacad.util.ArcFromBulgeCalculator; |
55 |
import net.jmorell.jdwglib.dwg.DwgFile; |
56 |
import net.jmorell.jdwglib.dwg.DwgObject; |
57 |
import net.jmorell.jdwglib.dwg.DwgObjectSpecificDataItem; |
58 |
import net.jmorell.jdwglib.dwg.DxfName; |
59 |
|
60 |
import org.cresques.px.dxf.AcadColor; |
61 |
import org.cresques.px.dxf.DxfCalArcs; |
62 |
import org.cresques.px.dxf.DxfInsert; |
63 |
|
64 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
65 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
66 |
import com.hardcode.gdbms.engine.values.IntValue; |
67 |
import com.hardcode.gdbms.engine.values.Value; |
68 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
69 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
70 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
71 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
72 |
import com.iver.cit.gvsig.fmap.core.FShape; |
73 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
74 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
75 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
76 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
77 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
78 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
79 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
80 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
81 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
82 |
|
83 |
import com.iver.cit.gvsig.fmap.drivers.dgn.ByteUtils; |
84 |
|
85 |
public class DwgMemoryDriver extends MemoryDriver implements WithDefaultLegend { |
86 |
private final int ID_FIELD_ID=0; |
87 |
private final int ID_FIELD_ENTITY=1; |
88 |
private final int ID_FIELD_LAYER=2; |
89 |
private final int ID_FIELD_COLOR=3; |
90 |
private final int ID_FIELD_ELEVATION=4; |
91 |
private final int ID_FIELD_THICKNESS=5; |
92 |
private final int ID_FIELD_TEXT=6; |
93 |
private final int ID_FIELD_HEIGHTTEXT=7; |
94 |
private final int ID_FIELD_ROTATIONTEXT=8; |
95 |
|
96 |
VectorialUniqueValueLegend defaultLegend; |
97 |
private String path; |
98 |
private File m_Fich; |
99 |
|
100 |
private DwgFile dwg;
|
101 |
private Vector dwgObjects; |
102 |
private DriverAttributes attr = new DriverAttributes(); |
103 |
|
104 |
/* (non-Javadoc)
|
105 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#open(java.io.File)
|
106 |
*/
|
107 |
public void open(File f) throws IOException { |
108 |
m_Fich = f; |
109 |
} |
110 |
|
111 |
public void initialize() throws IOException { |
112 |
float heightText = 10; |
113 |
|
114 |
attr.setLoadedInMemory(true);
|
115 |
|
116 |
dwg = new DwgFile();
|
117 |
long time = System.currentTimeMillis(); |
118 |
dwg.read(m_Fich.getAbsolutePath()); |
119 |
long timeElapsed = System.currentTimeMillis()-time; |
120 |
System.out.println("Tiempo empleado en leer el fichero dwg = " + timeElapsed); |
121 |
dwgObjects = dwg.getDwgObjects(); |
122 |
|
123 |
//int nAtt = featureMaker.getAttributes().size();
|
124 |
|
125 |
// Campos de las MemoryLayer:
|
126 |
//Value[] auxRow = new Value[9+nAtt];
|
127 |
Value[] auxRow = new Value[9]; |
128 |
ArrayList arrayFields = new ArrayList(); |
129 |
arrayFields.add("ID");
|
130 |
arrayFields.add("Entity");
|
131 |
arrayFields.add("Layer");
|
132 |
arrayFields.add("Color");
|
133 |
arrayFields.add("Elevation");
|
134 |
arrayFields.add("Thickness");
|
135 |
arrayFields.add("Text");
|
136 |
arrayFields.add("HeightText");
|
137 |
arrayFields.add("RotationText");
|
138 |
/*for (int i=0;i<nAtt;i++) {
|
139 |
String att[] = new String[2];
|
140 |
att = (String[])featureMaker.getAttributes().get(i);
|
141 |
arrayFields.add(att[0]);
|
142 |
}*/
|
143 |
|
144 |
getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
145 |
|
146 |
boolean addingToBlock = false; |
147 |
|
148 |
time = System.currentTimeMillis();
|
149 |
|
150 |
// Para intentar entender la manera de asignar la layer a cada elemento ...
|
151 |
/*for (int i=0;i<dwgObjects.size();i++) {
|
152 |
DwgObject obj = (DwgObject)dwgObjects.get(i);
|
153 |
if (obj.getType()==0x33) {
|
154 |
System.out.println("obj.getHandle().get(0) = " + obj.getHandle().get(0));
|
155 |
System.out.println("obj.getHandle().get(1) = " + obj.getHandle().get(1));
|
156 |
if (obj.getHandle().size()>2) System.out.println("obj.getHandle().get(2) = " + obj.getHandle().get(2));
|
157 |
if (obj.getHandle().size()>3) System.out.println("obj.getHandle().get(3) = " + obj.getHandle().get(3));
|
158 |
}
|
159 |
}*/
|
160 |
|
161 |
Vector layerTable = createLayerTable(dwgObjects);
|
162 |
|
163 |
for (int i=0;i<dwgObjects.size();i++) { |
164 |
|
165 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0);
|
166 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0);
|
167 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
168 |
|
169 |
DwgObject entity = (DwgObject)dwgObjects.get(i); |
170 |
if (entity.getType()==0x11 && !addingToBlock) { |
171 |
//System.out.println("Encuentra un Arc ...");
|
172 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
|
173 |
double[] coord = (double[])data.getValue(); |
174 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
175 |
data = entity.getDwgObjectSpecificDataItem("RADIUS");
|
176 |
double radius = ((Double)data.getValue()).doubleValue(); |
177 |
data = entity.getDwgObjectSpecificDataItem("START_ANGLE");
|
178 |
double startAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
179 |
data = entity.getDwgObjectSpecificDataItem("END_ANGLE");
|
180 |
double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
181 |
Point2D[] arc = createArc(center, radius, startAngle, endAngle); |
182 |
FPolyline2D arcc = createPolyline3D(arc); |
183 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
184 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc")); |
185 |
//int[] layerHandle = (int[])entity.getLayer();
|
186 |
String layerName = getLayerName(entity, layerTable);
|
187 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
188 |
int color = entity.getColor();
|
189 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
190 |
//if (color==0) color ByBlock
|
191 |
if (color==256) color = colorByLayer; |
192 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
193 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
194 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
195 |
// Attributes
|
196 |
/*for (int j=0;j<nAtt;j++) {
|
197 |
String[] attributes = new String[2];
|
198 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
199 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
200 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
201 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
202 |
}
|
203 |
}*/
|
204 |
addShape(arcc, auxRow); |
205 |
} else if (entity.getType()==0x12 && !addingToBlock) { |
206 |
//System.out.println("Encuentra un Circle ...");
|
207 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
|
208 |
double[] coord = (double[])data.getValue(); |
209 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
210 |
data = entity.getDwgObjectSpecificDataItem("RADIUS");
|
211 |
double radius = ((Double)data.getValue()).doubleValue(); |
212 |
FPolyline2D circle = createCircle(center, radius); |
213 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
214 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle")); |
215 |
//int[] layerHandle = (int[])entity.getLayer();
|
216 |
String layerName = getLayerName(entity, layerTable);
|
217 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
218 |
int color = entity.getColor();
|
219 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
220 |
//if (color==0) color ByBlock
|
221 |
if (color==256) color = colorByLayer; |
222 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
223 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
224 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
225 |
// Attributes
|
226 |
/*for (int j=0;j<nAtt;j++) {
|
227 |
String[] attributes = new String[2];
|
228 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
229 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
230 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
231 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
232 |
}
|
233 |
}*/
|
234 |
addShape(circle, auxRow); |
235 |
} else if (entity.getType()==0x13 && !addingToBlock) { |
236 |
//System.out.println("Encuentra una Line ...");
|
237 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("P1");
|
238 |
double[] coord = (double[])data.getValue(); |
239 |
Point2D p1 = new Point2D.Double(coord[0], coord[1]); |
240 |
data = entity.getDwgObjectSpecificDataItem("P2");
|
241 |
coord = (double[])data.getValue(); |
242 |
Point2D p2 = new Point2D.Double(coord[0], coord[1]); |
243 |
FPolyline2D line = createLine(p1, p2); |
244 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
245 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line")); |
246 |
//int[] layerHandle = (int[])entity.getLayer();
|
247 |
String layerName = getLayerName(entity, layerTable);
|
248 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
249 |
int color = entity.getColor();
|
250 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
251 |
//if (color==0) color ByBlock
|
252 |
if (color==256) color = colorByLayer; |
253 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
254 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
255 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
256 |
// Attributes
|
257 |
/*for (int j=0;j<nAtt;j++) {
|
258 |
String[] attributes = new String[2];
|
259 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
260 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
261 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
262 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
263 |
}
|
264 |
}*/
|
265 |
addShape(line, auxRow); |
266 |
} else if (entity.getType()==0x1B && !addingToBlock) { |
267 |
//System.out.println("Encuentra un Point ...");
|
268 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("POINT");
|
269 |
double[] coord = (double[])data.getValue(); |
270 |
Point2D p = new Point2D.Double(coord[0], coord[1]); |
271 |
FPoint2D point = createPoint(p); |
272 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
273 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Point")); |
274 |
//int[] layerHandle = (int[])entity.getLayer();
|
275 |
String layerName = getLayerName(entity, layerTable);
|
276 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
277 |
int color = entity.getColor();
|
278 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
279 |
//if (color==0) color ByBlock
|
280 |
if (color==256) color = colorByLayer; |
281 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
282 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
283 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
284 |
// Attributes
|
285 |
/*for (int j=0;j<nAtt;j++) {
|
286 |
String[] attributes = new String[2];
|
287 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
288 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
289 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
290 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
291 |
}
|
292 |
}*/
|
293 |
addShape(point, auxRow); |
294 |
} else if (entity.getType()==0x0F && !addingToBlock) { |
295 |
//System.out.println("Encuentra una Polyline2D ...");
|
296 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("FLAGS");
|
297 |
int flags = ((Integer)data.getValue()).intValue(); |
298 |
data = entity.getDwgObjectSpecificDataItem("FIRST_VERTEX_HANDLE");
|
299 |
int[] firstVertexHandle = (int[])data.getValue(); |
300 |
byte[] firstHandleBytes = new byte[]{0,0,0,0}; |
301 |
if (firstVertexHandle.length>2) firstHandleBytes[3] = (byte)firstVertexHandle[2]; |
302 |
if (firstVertexHandle.length>3) firstHandleBytes[2] = (byte)firstVertexHandle[3]; |
303 |
if (firstVertexHandle.length>4) firstHandleBytes[1] = (byte)firstVertexHandle[4]; |
304 |
if (firstVertexHandle.length>5) firstHandleBytes[0] = (byte)firstVertexHandle[5]; |
305 |
int firstHandle = ByteUtils.bytesToInt(firstHandleBytes, new int[]{0}); |
306 |
data = entity.getDwgObjectSpecificDataItem("LAST_VERTEX_HANDLE");
|
307 |
int[] lastVertexHandle = (int[])data.getValue(); |
308 |
byte[] lastHandleBytes = new byte[]{0,0,0,0}; |
309 |
if (lastVertexHandle.length>2) lastHandleBytes[3] = (byte)lastVertexHandle[2]; |
310 |
if (lastVertexHandle.length>3) lastHandleBytes[2] = (byte)lastVertexHandle[3]; |
311 |
if (lastVertexHandle.length>4) lastHandleBytes[1] = (byte)lastVertexHandle[4]; |
312 |
if (lastVertexHandle.length>5) lastHandleBytes[0] = (byte)lastVertexHandle[5]; |
313 |
int lastHandle = ByteUtils.bytesToInt(lastHandleBytes, new int[]{0}); |
314 |
Vector pts = new Vector(); |
315 |
Vector bulges = new Vector(); |
316 |
double[] pt = new double[2]; |
317 |
|
318 |
for (int j=0;j<dwgObjects.size();j++) { |
319 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
320 |
Vector handle = obj.getHandle();
|
321 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
322 |
if (handle.size()>2) handleBytes[3] = ((Integer)handle.get(2)).byteValue(); |
323 |
if (handle.size()>3) handleBytes[2] = ((Integer)handle.get(3)).byteValue(); |
324 |
if (handle.size()>4) handleBytes[1] = ((Integer)handle.get(4)).byteValue(); |
325 |
if (handle.size()>5) handleBytes[0] = ((Integer)handle.get(5)).byteValue(); |
326 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
327 |
if (objHandle==firstHandle && ((Integer)handle.get(1)).intValue()==firstVertexHandle[1]) { |
328 |
int k=0; |
329 |
while (true) { |
330 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
331 |
Vector vertexHandle = vertex.getHandle();
|
332 |
byte[] vHandleBytes = new byte[]{0,0,0,0}; |
333 |
if (vertexHandle.size()>2) vHandleBytes[3] = ((Integer)vertexHandle.get(2)).byteValue(); |
334 |
if (vertexHandle.size()>3) vHandleBytes[2] = ((Integer)vertexHandle.get(3)).byteValue(); |
335 |
if (vertexHandle.size()>4) vHandleBytes[1] = ((Integer)vertexHandle.get(4)).byteValue(); |
336 |
if (vertexHandle.size()>5) vHandleBytes[0] = ((Integer)vertexHandle.get(5)).byteValue(); |
337 |
int vHandle = ByteUtils.bytesToInt(vHandleBytes, new int[]{0}); |
338 |
data = vertex.getDwgObjectSpecificDataItem("POINT");
|
339 |
pt = (double[])data.getValue(); |
340 |
pts.add(new Point2D.Double(pt[0], pt[1])); |
341 |
data = vertex.getDwgObjectSpecificDataItem("BULGE");
|
342 |
double bulge = ((Double)data.getValue()).doubleValue(); |
343 |
bulges.add(new Double(bulge)); |
344 |
k++; |
345 |
if (vHandle==lastHandle && ((Integer)vertexHandle.get(1)).intValue()==lastVertexHandle[1]) { |
346 |
break;
|
347 |
} |
348 |
} |
349 |
} |
350 |
} |
351 |
|
352 |
Point2D[] newPts = new Point2D[pts.size()]; |
353 |
if (flags==0 || flags==2 || flags==4 || flags==8 || flags==16 || flags==32 || flags==64 || flags==128) { |
354 |
for (int j=0;j<pts.size();j++) { |
355 |
newPts[j] = (Point2D)pts.get(j);
|
356 |
} |
357 |
} else if (flags==1 || flags==3 || flags==5 || flags==9 || flags==17 || flags==33 || flags==65 || flags==129) { |
358 |
newPts = new Point2D[pts.size()+1]; |
359 |
for (int j=0;j<pts.size();j++) { |
360 |
newPts[j] = (Point2D)pts.get(j);
|
361 |
} |
362 |
newPts[pts.size()] = (Point2D)pts.get(0); |
363 |
bulges.add(new Double(0)); |
364 |
} |
365 |
FPolyline2D pline = createPolyline2D(newPts, bulges); |
366 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
367 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D")); |
368 |
//int[] layerHandle = (int[])entity.getLayer();
|
369 |
String layerName = getLayerName(entity, layerTable);
|
370 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
371 |
int color = entity.getColor();
|
372 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
373 |
//if (color==0) color ByBlock
|
374 |
if (color==256) color = colorByLayer; |
375 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
376 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
377 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
378 |
// Attributes
|
379 |
/*for (int j=0;j<nAtt;j++) {
|
380 |
String[] attributes = new String[2];
|
381 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
382 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
383 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
384 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
385 |
}
|
386 |
}*/
|
387 |
addShape(pline, auxRow); |
388 |
// Implementaci?n parcial ...
|
389 |
} else if (entity.getType()==0x10 && !addingToBlock) { |
390 |
//System.out.println("Encuentra una Polyline3D ...");
|
391 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CLOSED_FLAGS");
|
392 |
int flags = ((Integer)data.getValue()).intValue(); |
393 |
data = entity.getDwgObjectSpecificDataItem("FIRST_VERTEX_HANDLE");
|
394 |
int[] firstVertexHandle = (int[])data.getValue(); |
395 |
data = entity.getDwgObjectSpecificDataItem("LAST_VERTEX_HANDLE");
|
396 |
int[] lastVertexHandle = (int[])data.getValue(); |
397 |
data = entity.getDwgObjectSpecificDataItem("SEQEND_HANDLE");
|
398 |
int[] seqendHandle = (int[])data.getValue(); |
399 |
int vertexNumber = calculateVertexNumber(firstVertexHandle, lastVertexHandle);
|
400 |
Point2D[] pts = new Point2D[vertexNumber]; |
401 |
double[] pt = new double[2]; |
402 |
|
403 |
for (int j=0;j<dwgObjects.size();j++) { |
404 |
DwgObject v = (DwgObject)dwgObjects.get(j); |
405 |
Vector handle = v.getHandle();
|
406 |
if (((Integer)handle.get(handle.size()-2)).intValue()==firstVertexHandle[handle.size()-2] && ((Integer)handle.get(handle.size()-1)).intValue()==firstVertexHandle[handle.size()-1]) { |
407 |
for (int k=0; k<vertexNumber; k++) { |
408 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
409 |
data = vertex.getDwgObjectSpecificDataItem("POINT");
|
410 |
pt = (double[])data.getValue(); |
411 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
412 |
} |
413 |
} |
414 |
} |
415 |
Point2D[] newPts = new Point2D[pts.length]; |
416 |
if (flags==0 || flags==2 || flags==4 || flags==8 || flags==16 || flags==32 || flags==64 || flags==128) { |
417 |
newPts = pts; |
418 |
} else if (flags==1 || flags==3 || flags==5 || flags==9 || flags==17 || flags==33 || flags==65 || flags==129) { |
419 |
newPts = new Point2D[pts.length+1]; |
420 |
for (int j=0;j<pts.length;j++) { |
421 |
newPts[j] = pts[j]; |
422 |
} |
423 |
newPts[pts.length] = pts[0];
|
424 |
} |
425 |
FPolyline2D pline3d = createPolyline3D(newPts); |
426 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
427 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline3D")); |
428 |
//int[] layerHandle = (int[])entity.getLayer();
|
429 |
String layerName = getLayerName(entity, layerTable);
|
430 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
431 |
int color = entity.getColor();
|
432 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
433 |
//if (color==0) color ByBlock
|
434 |
if (color==256) color = colorByLayer; |
435 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
436 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
437 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
438 |
// Attributes
|
439 |
/*for (int j=0;j<nAtt;j++) {
|
440 |
String[] attributes = new String[2];
|
441 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
442 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
443 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
444 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
445 |
}
|
446 |
}*/
|
447 |
addShape(pline3d, auxRow); |
448 |
} else if (entity.getType()==0x1 && !addingToBlock) { |
449 |
//System.out.println("Encuentra un Text ...");
|
450 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
|
451 |
Point2D p = (Point2D)data.getValue(); |
452 |
FPoint2D point = createPoint(p); |
453 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
454 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Text")); |
455 |
//int[] layerHandle = (int[])entity.getLayer();
|
456 |
String layerName = getLayerName(entity, layerTable);
|
457 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
458 |
int color = entity.getColor();
|
459 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
460 |
//if (color==0) color ByBlock
|
461 |
if (color==256) color = colorByLayer; |
462 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
463 |
data = entity.getDwgObjectSpecificDataItem("TEXT");
|
464 |
String text = (String)data.getValue(); |
465 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(new String(text)); |
466 |
data = entity.getDwgObjectSpecificDataItem("HEIGHT");
|
467 |
heightText = ((Float)data.getValue()).floatValue();
|
468 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText); |
469 |
data = entity.getDwgObjectSpecificDataItem("DATA_FLAG");
|
470 |
int dflag = ((Integer)data.getValue()).intValue(); |
471 |
if ((dflag & 0x8) == 0) { |
472 |
data = entity.getDwgObjectSpecificDataItem("ROTATION_ANGLE");
|
473 |
double textRot = ((Double)data.getValue()).doubleValue(); |
474 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(Math.toDegrees(textRot));
|
475 |
} else {
|
476 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0.0);
|
477 |
} |
478 |
if ((dflag & 0x1)==0) { |
479 |
data = entity.getDwgObjectSpecificDataItem("ELEVATION");
|
480 |
double elev = ((Double)data.getValue()).doubleValue(); |
481 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(elev); |
482 |
} |
483 |
data = entity.getDwgObjectSpecificDataItem("THICKNESS");
|
484 |
double thickness = ((Double)data.getValue()).doubleValue(); |
485 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(thickness); |
486 |
// Attributes
|
487 |
/*for (int j=0;j<nAtt;j++) {
|
488 |
String[] attributes = new String[2];
|
489 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
490 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
491 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
492 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
493 |
}
|
494 |
}*/
|
495 |
addShape(point, auxRow); |
496 |
} else if (entity.getType()==0x4) { |
497 |
//System.out.println("Encuentra un Block ...");
|
498 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("NAME");
|
499 |
String blockName = (String)data.getValue(); |
500 |
addingToBlock = true;
|
501 |
//pto = (Point2D.Double)point.get(0);
|
502 |
//FShape nuevoShp;
|
503 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
504 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block")); |
505 |
//int[] layerHandle = (int[])entity.getLayer();
|
506 |
String layerName = getLayerName(entity, layerTable);
|
507 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
508 |
int color = entity.getColor();
|
509 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
510 |
//if (color==0) color ByBlock
|
511 |
if (color==256) color = colorByLayer; |
512 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
513 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
514 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
515 |
// Attributes
|
516 |
/*for (int j=0;j<nAtt;j++) {
|
517 |
String[] attributes = new String[2];
|
518 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
519 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
520 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
521 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
522 |
}
|
523 |
}*/
|
524 |
//addShape(point, auxRow);
|
525 |
} else if (entity.getType()==0x5) { |
526 |
//System.out.println("Encuentra un Endblk ...");
|
527 |
addingToBlock = false;
|
528 |
//pto = (Point2D.Double)point.get(0);
|
529 |
//FShape nuevoShp;
|
530 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
531 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("EndBlk")); |
532 |
//int[] layerHandle = (int[])entity.getLayer();
|
533 |
String layerName = getLayerName(entity, layerTable);
|
534 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
535 |
int color = entity.getColor();
|
536 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
537 |
//if (color==0) color ByBlock
|
538 |
if (color==256) color = colorByLayer; |
539 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
540 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
541 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
542 |
// Attributes
|
543 |
/*for (int j=0;j<nAtt;j++) {
|
544 |
String[] attributes = new String[2];
|
545 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
546 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
547 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
548 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
549 |
}
|
550 |
}*/
|
551 |
//addShape(point, auxRow);
|
552 |
} else if (entity.getType()==0x30) { |
553 |
//System.out.println("Encuentra un Block Control Object ...");
|
554 |
//addingToBlock = false;
|
555 |
//pto = (Point2D.Double)point.get(0);
|
556 |
//FShape nuevoShp;
|
557 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
558 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Control Object")); |
559 |
//int[] layerHandle = (int[])entity.getLayer();
|
560 |
String layerName = getLayerName(entity, layerTable);
|
561 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
562 |
int color = entity.getColor();
|
563 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
564 |
//if (color==0) color ByBlock
|
565 |
if (color==256) color = colorByLayer; |
566 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
567 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
568 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
569 |
// Attributes
|
570 |
/*for (int j=0;j<nAtt;j++) {
|
571 |
String[] attributes = new String[2];
|
572 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
573 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
574 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
575 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
576 |
}
|
577 |
}*/
|
578 |
//addShape(point, auxRow);
|
579 |
} else if (entity.getType()==0x31) { |
580 |
//System.out.println("Encuentra un Block Header ...");
|
581 |
addingToBlock = true;
|
582 |
//pto = (Point2D.Double)point.get(0);
|
583 |
//FShape nuevoShp;
|
584 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
585 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Header")); |
586 |
//int[] layerHandle = (int[])entity.getLayer();
|
587 |
String layerName = getLayerName(entity, layerTable);
|
588 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
589 |
int color = entity.getColor();
|
590 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
591 |
//if (color==0) color ByBlock
|
592 |
if (color==256) color = colorByLayer; |
593 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
594 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
595 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
596 |
// Attributes
|
597 |
/*for (int j=0;j<nAtt;j++) {
|
598 |
String[] attributes = new String[2];
|
599 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
600 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
601 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
602 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
603 |
}
|
604 |
}*/
|
605 |
//addShape(point, auxRow);
|
606 |
} else if (entity.getType()==0x7 && !addingToBlock) { |
607 |
//System.out.println("Encuentra un Insert ...");
|
608 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
|
609 |
double[] p = (double[])data.getValue(); |
610 |
Point2D point = new Point2D.Double(p[0], p[1]); |
611 |
data = entity.getDwgObjectSpecificDataItem("SCALE");
|
612 |
double[] scale = (double[])data.getValue(); |
613 |
data = entity.getDwgObjectSpecificDataItem("ROTATION");
|
614 |
double rot = ((Double)data.getValue()).doubleValue(); |
615 |
data = entity.getDwgObjectSpecificDataItem("BLOCK_HEADER_HANDLE");
|
616 |
int[] blockHandle = (int[])data.getValue(); |
617 |
|
618 |
manageInsert(dwgObjects, layerTable, point, scale, rot, blockHandle, i, auxRow); |
619 |
|
620 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
621 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Insert")); |
622 |
//int[] layerHandle = (int[])entity.getLayer();
|
623 |
String layerName = getLayerName(entity, layerTable);
|
624 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
625 |
int color = entity.getColor();
|
626 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
627 |
//if (color==0) color ByBlock
|
628 |
if (color==256) color = colorByLayer; |
629 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
630 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
631 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
632 |
// Attributes
|
633 |
/*for (int j=0;j<nAtt;j++) {
|
634 |
String[] attributes = new String[2];
|
635 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
636 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
637 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
638 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
639 |
}
|
640 |
}*/
|
641 |
FPoint2D fPoint = createPoint(point); |
642 |
addShape(fPoint, auxRow); |
643 |
} else if (entity.getType()==0x2C && !addingToBlock) { |
644 |
//System.out.println("Encuentra un MText ...");
|
645 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
|
646 |
double[] coord = (double[])data.getValue(); |
647 |
Point2D p = new Point2D.Double(coord[0], coord[1]); |
648 |
FPoint2D point = createPoint(p); |
649 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
650 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("MText")); |
651 |
//int[] layerHandle = (int[])entity.getLayer();
|
652 |
String layerName = getLayerName(entity, layerTable);
|
653 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
654 |
int color = entity.getColor();
|
655 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
656 |
//if (color==0) color ByBlock
|
657 |
if (color==256) color = colorByLayer; |
658 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
659 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
660 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
661 |
// Attributes
|
662 |
/*for (int j=0;j<nAtt;j++) {
|
663 |
String[] attributes = new String[2];
|
664 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
665 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
666 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
667 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
668 |
}
|
669 |
}*/
|
670 |
addShape(point, auxRow); |
671 |
} else if (entity.getType()==0x1F && !addingToBlock) { |
672 |
//System.out.println("Encuentra un Solid ...");
|
673 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CORNER1");
|
674 |
double[] coord = (double[])data.getValue(); |
675 |
Point2D p1 = new Point2D.Double(coord[0], coord[1]); |
676 |
data = entity.getDwgObjectSpecificDataItem("CORNER2");
|
677 |
coord = (double[])data.getValue(); |
678 |
Point2D p2 = new Point2D.Double(coord[0], coord[1]); |
679 |
data = entity.getDwgObjectSpecificDataItem("CORNER3");
|
680 |
coord = (double[])data.getValue(); |
681 |
Point2D p3 = new Point2D.Double(coord[0], coord[1]); |
682 |
data = entity.getDwgObjectSpecificDataItem("CORNER4");
|
683 |
coord = (double[])data.getValue(); |
684 |
Point2D p4 = new Point2D.Double(coord[0], coord[1]); |
685 |
FPolygon2D solid = createSolid(new Point2D[]{p1, p2, p4, p3}); |
686 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
687 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Solid")); |
688 |
//int[] layerHandle = (int[])entity.getLayer();
|
689 |
String layerName = getLayerName(entity, layerTable);
|
690 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
691 |
int color = entity.getColor();
|
692 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
693 |
//if (color==0) color ByBlock
|
694 |
if (color==256) color = colorByLayer; |
695 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
696 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
697 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
698 |
// Attributes
|
699 |
/*for (int j=0;j<nAtt;j++) {
|
700 |
String[] attributes = new String[2];
|
701 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
702 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
703 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
704 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
705 |
}
|
706 |
}*/
|
707 |
addShape(solid, auxRow); |
708 |
} else if (entity.getType()==0x2 && !addingToBlock) { |
709 |
//System.out.println("Encuentra un Attrib ...");
|
710 |
/*} else if (entity.getType()==0x3 && !addingToBlock) {
|
711 |
System.out.println("Encuentra un Attdef ...");*/
|
712 |
} else if (dwg.getDxfNames().size()>0) { |
713 |
int type = 0; |
714 |
for (int j=0; j<dwg.getDxfNames().size(); j++) { |
715 |
String dxfName = ((DxfName)dwg.getDxfNames().get(j)).getDxfName();
|
716 |
if (dxfName.equals("LWPOLYLINE")) { |
717 |
type = ((DxfName)dwg.getDxfNames().get(j)).getKey(); |
718 |
break;
|
719 |
} |
720 |
} |
721 |
if (entity.getType()==type) {
|
722 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("VERTICES");
|
723 |
Vector vertices = (Vector)data.getValue(); |
724 |
Point2D[] pts = new Point2D[vertices.size()]; |
725 |
double[] pt = new double[2]; |
726 |
for (int j=0; j<vertices.size(); j++) { |
727 |
pt = (double[])vertices.get(j); |
728 |
pts[j] = new Point2D.Double(pt[0], pt[1]); |
729 |
} |
730 |
FPolyline2D lwpline = createLwPolyline(pts); |
731 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
732 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("LwPolyline")); |
733 |
//int[] layerHandle = (int[])entity.getLayer();
|
734 |
String layerName = getLayerName(entity, layerTable);
|
735 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
736 |
int color = entity.getColor();
|
737 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
738 |
//if (color==0) color ByBlock
|
739 |
if (color==256) color = colorByLayer; |
740 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
741 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
742 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
743 |
// Attributes
|
744 |
/*for (int j=0;j<nAtt;j++) {
|
745 |
String[] attributes = new String[2];
|
746 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
747 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
748 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
749 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
750 |
}
|
751 |
}*/
|
752 |
addShape(lwpline, auxRow); |
753 |
} |
754 |
} else {
|
755 |
System.out.println("Detectado dwgObject pendiente de implementar"); |
756 |
} |
757 |
} |
758 |
timeElapsed = System.currentTimeMillis()-time;
|
759 |
System.out.println("Tiempo empleado por el driver en importar el contenido del dwg = " + timeElapsed); |
760 |
|
761 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(getShapeType()); |
762 |
defaultLegend.setFieldName("Color");
|
763 |
defaultLegend.setLabelField("Text");
|
764 |
defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
|
765 |
defaultLegend.getDefaultSymbol().setShapeVisible(false);
|
766 |
defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
|
767 |
defaultLegend.getDefaultSymbol().setFont(new Font("SansSerif", Font.PLAIN, 9)); |
768 |
defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
|
769 |
defaultLegend.getDefaultSymbol().setFontSize(heightText); |
770 |
defaultLegend.getDefaultSymbol().setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL); |
771 |
defaultLegend.getDefaultSymbol().setSize(3);
|
772 |
defaultLegend.getDefaultSymbol().setSizeInPixels(true);
|
773 |
|
774 |
defaultLegend.setLabelHeightField("HeightText");
|
775 |
defaultLegend.setLabelRotationField("RotationText");
|
776 |
|
777 |
ObjectDriver rs = this;
|
778 |
IntValue clave; |
779 |
FSymbol theSymbol = null;
|
780 |
|
781 |
try {
|
782 |
// TODO: Provisional hasta que cambiemos los s?mbolos.
|
783 |
/* BufferedImage bi= new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
|
784 |
Graphics2D big = bi.createGraphics();
|
785 |
Color color=new Color(0,0,0,0);
|
786 |
big.setBackground(color);
|
787 |
big.clearRect(0, 0, 5, 5);
|
788 |
Paint fillProv = null;
|
789 |
Rectangle2D rProv = new Rectangle();
|
790 |
rProv.setFrame(0, 0,5,5);
|
791 |
fillProv = new TexturePaint(bi,rProv); */
|
792 |
|
793 |
for (long j = 0; j < rs.getRowCount(); j++) |
794 |
{ |
795 |
clave = (IntValue)rs.getFieldValue(j,ID_FIELD_COLOR); |
796 |
if (defaultLegend.getSymbolByValue(clave) == null) |
797 |
{ |
798 |
theSymbol = new FSymbol(getShapeType());
|
799 |
theSymbol.setDescription(clave.toString()); |
800 |
theSymbol.setColor(AcadColor.getColor(clave.getValue())); |
801 |
// theSymbol.setFill(fillProv);
|
802 |
// 050202, jmorell: Asigna los colores de Autocad a los bordes
|
803 |
// de los pol?gonos.
|
804 |
theSymbol.setOutlineColor(AcadColor.getColor(clave.getValue())); |
805 |
|
806 |
theSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL); |
807 |
theSymbol.setSize(3);
|
808 |
theSymbol.setSizeInPixels(true);
|
809 |
|
810 |
defaultLegend.addSymbol(clave, theSymbol); |
811 |
} |
812 |
} // for
|
813 |
} catch (DriverException e) {
|
814 |
e.printStackTrace(); |
815 |
throw new IOException("Error al poner la leyenda por defecto en el Dwg"); |
816 |
} |
817 |
} |
818 |
|
819 |
/**
|
820 |
* En principio exportamos a FPolyline2D, despues estudiaremos la conveniencia
|
821 |
* de exportar a FPolygon2D, o a las dos cosas ...
|
822 |
* Esta clase construye el circle del mismo modo que en DxfFeatureMaker.
|
823 |
* Se podr?a renombrar esta clase a createCircleFeature y a?adir otra
|
824 |
* createCircleEntity ...
|
825 |
* La parte de creaci?n de la FPolyline2D est? sacada del DxfMemoryDriver ...
|
826 |
* @param center
|
827 |
* @param radius
|
828 |
* @return
|
829 |
*/
|
830 |
private FPolyline2D createCircle(Point2D c, double r) { |
831 |
Point2D[] pts = new Point2D[360]; |
832 |
int angulo = 0; |
833 |
for (angulo=0; angulo<360; angulo++) { |
834 |
pts[angulo] = new Point2D.Double(c.getX(), c.getY()); |
835 |
pts[angulo].setLocation(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
836 |
} |
837 |
GeneralPathX genPathX = new GeneralPathX();
|
838 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
839 |
for (int i=1; i<pts.length; i++) { |
840 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
841 |
} |
842 |
return new FPolyline2D(genPathX); |
843 |
} |
844 |
|
845 |
/**
|
846 |
* Como createCircle ...
|
847 |
* @param c
|
848 |
* @param r
|
849 |
* @param sa
|
850 |
* @param ea
|
851 |
* @return
|
852 |
*/
|
853 |
private Point2D[] createArc(Point2D c, double r, double sa, double ea) { |
854 |
int isa = (int)sa; |
855 |
int iea = (int)ea; |
856 |
double angulo;
|
857 |
Point2D[] pts; |
858 |
if (sa <= ea) {
|
859 |
pts = new Point2D[(iea-isa)+2]; |
860 |
angulo = sa; |
861 |
pts[0] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
862 |
for (int i=1; i<=(iea-isa)+1; i++) { |
863 |
angulo = (double)(isa+i);
|
864 |
pts[i] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
865 |
} |
866 |
angulo = ea; |
867 |
pts[(iea-isa)+1] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
868 |
} else {
|
869 |
pts = new Point2D[(360-isa)+iea+2]; |
870 |
angulo = sa; |
871 |
pts[0] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
872 |
for (int i=1; i<=(360-isa); i++) { |
873 |
angulo = (double)(isa+i);
|
874 |
pts[i] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
875 |
} |
876 |
for (int i=(360-isa)+1; i<=(360-isa)+iea; i++) { |
877 |
angulo = (double)(i-(360-isa)); |
878 |
pts[i] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
879 |
} |
880 |
angulo = ea; |
881 |
pts[(360-isa)+iea+1] = new Point2D.Double(c.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), c.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
882 |
} |
883 |
return pts;
|
884 |
/*GeneralPathX genPathX = new GeneralPathX();
|
885 |
genPathX.moveTo(pts[0].getX(), pts[0].getY());
|
886 |
for (int i=1; i<pts.length; i++) {
|
887 |
genPathX.lineTo(pts[i].getX(), pts[i].getY());
|
888 |
}
|
889 |
return new FPolyline2D(genPathX);*/
|
890 |
} |
891 |
|
892 |
/**
|
893 |
* Los nombres de estos m?todos pueden cambiarse por otros m?s apropiados, por
|
894 |
* ejemplo:
|
895 |
* createLine --> dwgLineToFPolyline2D ... ?mejor as?? ...
|
896 |
* @param p1
|
897 |
* @param p2
|
898 |
* @return
|
899 |
*/
|
900 |
private FPolyline2D createLine(Point2D p1, Point2D p2) { |
901 |
Point2D[] pts = new Point2D[]{p1, p2}; |
902 |
GeneralPathX genPathX = new GeneralPathX();
|
903 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
904 |
for (int i=1; i<pts.length; i++) { |
905 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
906 |
} |
907 |
return new FPolyline2D(genPathX); |
908 |
} |
909 |
|
910 |
private FPoint2D createPoint(Point2D p) { |
911 |
return new FPoint2D(p.getX(), p.getY()); |
912 |
} |
913 |
|
914 |
private FPolyline2D createLwPolyline(Point2D[] pts) { |
915 |
GeneralPathX genPathX = new GeneralPathX();
|
916 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
917 |
for (int i=1; i<pts.length; i++) { |
918 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
919 |
} |
920 |
return new FPolyline2D(genPathX); |
921 |
} |
922 |
|
923 |
private FPolyline2D createPolyline3D(Point2D[] pts) { |
924 |
GeneralPathX genPathX = new GeneralPathX();
|
925 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
926 |
for (int i=1; i<pts.length; i++) { |
927 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
928 |
} |
929 |
return new FPolyline2D(genPathX); |
930 |
} |
931 |
|
932 |
private FPolyline2D createPolyline2D(Point2D[] inPts, Vector bulges) { |
933 |
Vector pts = new Vector(); |
934 |
Point2D init = new Point2D.Double(); |
935 |
Point2D end = new Point2D.Double(); |
936 |
for (int i=0; i<inPts.length; i++) { |
937 |
init = inPts[i]; |
938 |
if (i!=inPts.length-1) end = inPts[i+1]; |
939 |
if (((Double)bulges.get(i)).doubleValue()==0 || i==inPts.length-1) { |
940 |
pts.add(init); |
941 |
} else {
|
942 |
ArcFromBulgeCalculator arcCalculator = new ArcFromBulgeCalculator(init, end, ((Double)bulges.get(i)).doubleValue()); |
943 |
Vector arc = arcCalculator.getPoints(1); |
944 |
for (int j=0;j<arc.size();j++) { |
945 |
pts.add(arc.get(j)); |
946 |
} |
947 |
pts.remove(pts.size()-1);
|
948 |
} |
949 |
} |
950 |
GeneralPathX genPathX = new GeneralPathX();
|
951 |
genPathX.moveTo(((Point2D)pts.get(0)).getX(), ((Point2D)pts.get(0)).getY()); |
952 |
for (int i=1; i<pts.size(); i++) { |
953 |
genPathX.lineTo(((Point2D)pts.get(i)).getX(), ((Point2D)pts.get(i)).getY()); |
954 |
} |
955 |
return new FPolyline2D(genPathX); |
956 |
} |
957 |
|
958 |
private FPolygon2D createSolid(Point2D[] pts) { |
959 |
GeneralPathX genPathX = new GeneralPathX();
|
960 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
961 |
for (int i=1; i<pts.length; i++) { |
962 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
963 |
} |
964 |
genPathX.closePath(); |
965 |
return new FPolygon2D(genPathX); |
966 |
} |
967 |
|
968 |
private int calculateVertexNumber(int[] firstVertexHandle, int[] lastVertexHandle) { |
969 |
if (firstVertexHandle.length==lastVertexHandle.length) {
|
970 |
if (firstVertexHandle[firstVertexHandle.length-2]==lastVertexHandle[firstVertexHandle.length-2]) { |
971 |
return (lastVertexHandle[firstVertexHandle.length-1]-firstVertexHandle[firstVertexHandle.length-1]+1); |
972 |
} else {
|
973 |
int aux = 255-firstVertexHandle[firstVertexHandle.length-1]+1; |
974 |
int aux2 = lastVertexHandle[firstVertexHandle.length-1]+1; |
975 |
int aux3 = (lastVertexHandle[firstVertexHandle.length-2]-firstVertexHandle[firstVertexHandle.length-2]-1)*255; |
976 |
int vn = aux + aux2 + aux3;
|
977 |
return vn;
|
978 |
} |
979 |
} else if (firstVertexHandle.length==(lastVertexHandle.length-1)) { |
980 |
int aux = 255-firstVertexHandle[firstVertexHandle.length-1]+1; |
981 |
int aux2 = lastVertexHandle[firstVertexHandle.length]+1; |
982 |
int aux3 = (lastVertexHandle[lastVertexHandle.length-2]-1)*255; |
983 |
int vn = aux + aux2 + aux3;
|
984 |
return vn;
|
985 |
} else {
|
986 |
System.out.println("ERROR: firstVertexHandle y lastVertexHandle tienen tama?os inesperados"); |
987 |
return 0; |
988 |
} |
989 |
} |
990 |
|
991 |
private void manageInsert(Vector dwgObjects, Vector layerTable, Point2D insPoint, double[] scale, double rot, int[] blockHandle, int id, Value[] auxRow) { |
992 |
byte[] blockHandleBytes = new byte[]{0,0,0,0}; |
993 |
if (blockHandle.length>2) blockHandleBytes[3] = (byte)blockHandle[2]; |
994 |
if (blockHandle.length>3) blockHandleBytes[2] = (byte)blockHandle[3]; |
995 |
if (blockHandle.length>4) blockHandleBytes[1] = (byte)blockHandle[4]; |
996 |
if (blockHandle.length>5) blockHandleBytes[0] = (byte)blockHandle[5]; |
997 |
int bHandle = ByteUtils.bytesToInt(blockHandleBytes, new int[]{0}); |
998 |
for (int j=0;j<dwgObjects.size();j++) { |
999 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
1000 |
DwgObjectSpecificDataItem dataa = obj.getDwgObjectSpecificDataItem("BLOCK_ENTITY_HANDLE");
|
1001 |
//System.out.println("obj.getType() = " + obj.getType());
|
1002 |
//System.out.println("dataa = " + dataa);
|
1003 |
if (dataa!=null) { |
1004 |
int[] handle = (int[])dataa.getValue(); |
1005 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
1006 |
if (handle.length>2) handleBytes[3] = (byte)handle[2]; |
1007 |
if (handle.length>3) handleBytes[2] = (byte)handle[3]; |
1008 |
if (handle.length>4) handleBytes[1] = (byte)handle[4]; |
1009 |
if (handle.length>5) handleBytes[0] = (byte)handle[5]; |
1010 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
1011 |
//System.out.println("objHandle = " + objHandle);
|
1012 |
//System.out.println("bHandle = " + bHandle);
|
1013 |
if (objHandle==bHandle+1 && handle[1]==blockHandle[1]) { |
1014 |
//obj = (DwgObject)dwgObjects.get(j+1);
|
1015 |
//System.out.println("Hemos encontrado el bloque");
|
1016 |
//System.out.println("obj.getType() = " + obj.getType());
|
1017 |
DwgObjectSpecificDataItem data = obj.getDwgObjectSpecificDataItem("BASE_POINT");
|
1018 |
double[] bPoint = (double[])data.getValue(); |
1019 |
//System.out.println("bPoint[0] = " + bPoint[0]);
|
1020 |
//System.out.println("bPoint[1] = " + bPoint[1]);
|
1021 |
data = obj.getDwgObjectSpecificDataItem("FIRST_ENTITY_HANDLE");
|
1022 |
int[] firstEntityHandle = (int[])data.getValue(); |
1023 |
//System.out.println("firstEntityHandle[0] = " + firstEntityHandle[0]);
|
1024 |
//System.out.println("firstEntityHandle[1] = " + firstEntityHandle[1]);
|
1025 |
//if (firstEntityHandle.length>2) System.out.println("firstEntityHandle[2] = " + firstEntityHandle[2]);
|
1026 |
//if (firstEntityHandle.length>3) System.out.println("firstEntityHandle[3] = " + firstEntityHandle[3]);
|
1027 |
byte[] firstEntityBytes = new byte[]{0,0,0,0}; |
1028 |
if (firstEntityHandle.length>2) firstEntityBytes[3] = (byte)firstEntityHandle[2]; |
1029 |
if (firstEntityHandle.length>3) firstEntityBytes[2] = (byte)firstEntityHandle[3]; |
1030 |
if (firstEntityHandle.length>4) firstEntityBytes[1] = (byte)firstEntityHandle[4]; |
1031 |
if (firstEntityHandle.length>5) firstEntityBytes[0] = (byte)firstEntityHandle[5]; |
1032 |
int firstHandle = ByteUtils.bytesToInt(firstEntityBytes, new int[]{0}); |
1033 |
//System.out.println("firstHandle = " + firstHandle);
|
1034 |
data = obj.getDwgObjectSpecificDataItem("LAST_ENTITY_HANDLE");
|
1035 |
int[] lastEntityHandle = (int[])data.getValue(); |
1036 |
byte[] lastEntityBytes = new byte[]{0,0,0,0}; |
1037 |
if (lastEntityHandle.length>2) lastEntityBytes[3] = (byte)lastEntityHandle[2]; |
1038 |
if (lastEntityHandle.length>3) lastEntityBytes[2] = (byte)lastEntityHandle[3]; |
1039 |
if (lastEntityHandle.length>4) lastEntityBytes[1] = (byte)lastEntityHandle[4]; |
1040 |
if (lastEntityHandle.length>5) lastEntityBytes[0] = (byte)lastEntityHandle[5]; |
1041 |
int lastHandle = ByteUtils.bytesToInt(lastEntityBytes, new int[]{0}); |
1042 |
//System.out.println("lastHandle = " + lastHandle);
|
1043 |
// Buscando la capa y el color del bloque ...
|
1044 |
String bname = (String)obj.getDwgObjectSpecificDataItem("NAME").getValue(); |
1045 |
//int[] blockHandleLayer = null;
|
1046 |
//int blockColor = 0;
|
1047 |
DwgObject block = null;
|
1048 |
for (int k=0;k<dwgObjects.size();k++) { |
1049 |
DwgObject ent = (DwgObject)dwgObjects.get(k); |
1050 |
if (ent.getType()==0x4) { |
1051 |
String name = (String)obj.getDwgObjectSpecificDataItem("NAME").getValue(); |
1052 |
if (bname.equals(name)) {
|
1053 |
//blockHandleLayer = ent.getLayer();
|
1054 |
//blockColor = ent.getColor();
|
1055 |
block = ent; |
1056 |
} |
1057 |
} |
1058 |
} |
1059 |
|
1060 |
for (int k=0;k<dwgObjects.size();k++) { |
1061 |
DwgObject ent = (DwgObject)dwgObjects.get(k); |
1062 |
Vector entHandle = ent.getHandle();
|
1063 |
byte[] entHandleBytes = new byte[]{0,0,0,0}; |
1064 |
if (entHandle.size()>2) entHandleBytes[3] = ((Integer)entHandle.get(2)).byteValue(); |
1065 |
if (entHandle.size()>3) entHandleBytes[2] = ((Integer)entHandle.get(3)).byteValue(); |
1066 |
if (entHandle.size()>4) entHandleBytes[1] = ((Integer)entHandle.get(4)).byteValue(); |
1067 |
if (entHandle.size()>5) entHandleBytes[0] = ((Integer)entHandle.get(5)).byteValue(); |
1068 |
int eHandle = ByteUtils.bytesToInt(entHandleBytes, new int[]{0}); |
1069 |
//System.out.println("eHandle = " + eHandle);
|
1070 |
if (eHandle==firstHandle && ((Integer)entHandle.get(1)).intValue()==firstEntityHandle[1]) { |
1071 |
//System.out.println("Hemos encontrado el primer elemento");
|
1072 |
int l=0; |
1073 |
while (true) { |
1074 |
DwgObject blockEntity = (DwgObject)dwgObjects.get(k+l); |
1075 |
Vector blockEntityHandle = blockEntity.getHandle();
|
1076 |
byte[] blockEntityHandleBytes = new byte[]{0,0,0,0}; |
1077 |
if (blockEntityHandle.size()>2) blockEntityHandleBytes[3] = ((Integer)blockEntityHandle.get(2)).byteValue(); |
1078 |
if (blockEntityHandle.size()>3) blockEntityHandleBytes[2] = ((Integer)blockEntityHandle.get(3)).byteValue(); |
1079 |
if (blockEntityHandle.size()>4) blockEntityHandleBytes[1] = ((Integer)blockEntityHandle.get(4)).byteValue(); |
1080 |
if (blockEntityHandle.size()>5) blockEntityHandleBytes[0] = ((Integer)blockEntityHandle.get(5)).byteValue(); |
1081 |
int bEntityHandle = ByteUtils.bytesToInt(blockEntityHandleBytes, new int[]{0}); |
1082 |
manageBlockEntity(blockEntity, layerTable, bPoint, insPoint, scale, rot, block, id, auxRow); |
1083 |
l++; |
1084 |
if (bEntityHandle==lastHandle && ((Integer)entHandle.get(1)).intValue()==lastEntityHandle[1]) { |
1085 |
break;
|
1086 |
} |
1087 |
} |
1088 |
} |
1089 |
} |
1090 |
} |
1091 |
} |
1092 |
} |
1093 |
} |
1094 |
|
1095 |
private void manageBlockEntity(DwgObject entity, Vector layerTable, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, int id, Value[] auxRow) { |
1096 |
if (entity.getType()==0x11) { |
1097 |
//System.out.println("Encuentra un arco dentro de un bloque ...");
|
1098 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
|
1099 |
double[] coord = (double[])data.getValue(); |
1100 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
1101 |
data = entity.getDwgObjectSpecificDataItem("RADIUS");
|
1102 |
double radius = ((Double)data.getValue()).doubleValue(); |
1103 |
data = entity.getDwgObjectSpecificDataItem("START_ANGLE");
|
1104 |
double startAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
1105 |
data = entity.getDwgObjectSpecificDataItem("END_ANGLE");
|
1106 |
double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
1107 |
//FPolyline2D arc = createArc(center, radius, startAngle, endAngle);
|
1108 |
Point2D[] arc = createArc(center, radius, startAngle, endAngle); |
1109 |
for (int i=0;i<arc.length;i++) { |
1110 |
Point2D pointAux = new Point2D.Double(arc[i].getX() - bPoint[0], arc[i].getY() - bPoint[1]); |
1111 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(rot) + (pointAux.getY()*scale[1])*(-1)*Math.sin(rot)); |
1112 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot)); |
1113 |
arc[i] = new Point2D.Double(laX, laY); |
1114 |
} |
1115 |
FPolyline2D arcc = createPolyline3D(arc); |
1116 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(id); |
1117 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc")); |
1118 |
String layerName = getLayerName(block, layerTable);
|
1119 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
1120 |
int color = entity.getColor();
|
1121 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
1122 |
int colorByBlock = getColorByLayer(block, layerTable);
|
1123 |
if (color==0) color = colorByBlock; |
1124 |
if (color==256) color = colorByLayer; |
1125 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
1126 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
1127 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
1128 |
// Attributes
|
1129 |
/*for (int j=0;j<nAtt;j++) {
|
1130 |
String[] attributes = new String[2];
|
1131 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
1132 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
1133 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
1134 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
1135 |
}
|
1136 |
}*/
|
1137 |
addShape(arcc, auxRow); |
1138 |
} else if (entity.getType()==0x12) { |
1139 |
//System.out.println("Encuentra un c?rculo dentro de un bloque ...");
|
1140 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
|
1141 |
double[] coord = (double[])data.getValue(); |
1142 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
1143 |
data = entity.getDwgObjectSpecificDataItem("RADIUS");
|
1144 |
double radius = ((Double)data.getValue()).doubleValue(); |
1145 |
|
1146 |
Point2D pointAux = new Point2D.Double(center.getX() - bPoint[0], center.getY() - bPoint[1]); |
1147 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*(-1)*Math.sin(Math.toRadians(rot))); |
1148 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*Math.cos(Math.toRadians(rot))); |
1149 |
center = new Point2D.Double(laX, laY); |
1150 |
// Escala en X = escala en Y ...
|
1151 |
radius = radius * scale[0];
|
1152 |
|
1153 |
FPolyline2D circle = createCircle(center, radius); |
1154 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(id); |
1155 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle")); |
1156 |
String layerName = getLayerName(block, layerTable);
|
1157 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
1158 |
int color = entity.getColor();
|
1159 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
1160 |
int colorByBlock = getColorByLayer(block, layerTable);
|
1161 |
if (color==0) color = colorByBlock; |
1162 |
if (color==256) color = colorByLayer; |
1163 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
1164 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
1165 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
1166 |
// Attributes
|
1167 |
/*for (int j=0;j<nAtt;j++) {
|
1168 |
String[] attributes = new String[2];
|
1169 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
1170 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
1171 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
1172 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
1173 |
}
|
1174 |
}*/
|
1175 |
addShape(circle, auxRow); |
1176 |
} else if (entity.getType()==0x13) { |
1177 |
//System.out.println("Encuentra una l?nea dentro de un bloque ...");
|
1178 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("P1");
|
1179 |
double[] coord = (double[])data.getValue(); |
1180 |
Point2D p1 = new Point2D.Double(coord[0], coord[1]); |
1181 |
data = entity.getDwgObjectSpecificDataItem("P2");
|
1182 |
coord = (double[])data.getValue(); |
1183 |
Point2D p2 = new Point2D.Double(coord[0], coord[1]); |
1184 |
|
1185 |
Point2D pointAux = new Point2D.Double(p1.getX() - bPoint[0], p1.getY() - bPoint[1]); |
1186 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(rot) + (pointAux.getY()*scale[1])*(-1)*Math.sin(rot)); |
1187 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot)); |
1188 |
p1 = new Point2D.Double(laX, laY); |
1189 |
pointAux = new Point2D.Double(p2.getX() - bPoint[0], p2.getY() - bPoint[1]); |
1190 |
laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(rot) + (pointAux.getY()*scale[1])*(-1)*Math.sin(rot)); |
1191 |
laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot)); |
1192 |
p2 = new Point2D.Double(laX, laY); |
1193 |
|
1194 |
FPolyline2D line = createLine(p1, p2); |
1195 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(id); |
1196 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line")); |
1197 |
String layerName = getLayerName(block, layerTable);
|
1198 |
//System.out.println("layerName = " + layerName);
|
1199 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
1200 |
int color = entity.getColor();
|
1201 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
1202 |
int colorByBlock = getColorByLayer(block, layerTable);
|
1203 |
if (color==0) color = colorByBlock; |
1204 |
if (color==256) color = colorByLayer; |
1205 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
1206 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
1207 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
1208 |
// Attributes
|
1209 |
/*for (int j=0;j<nAtt;j++) {
|
1210 |
String[] attributes = new String[2];
|
1211 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
1212 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
1213 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
1214 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
1215 |
}
|
1216 |
}*/
|
1217 |
addShape(line, auxRow); |
1218 |
} else if (entity.getType()==0x7) { |
1219 |
//System.out.println("Encuentra un insert dentro de un bloque ...");
|
1220 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
|
1221 |
double[] p = (double[])data.getValue(); |
1222 |
Point2D newInsPoint = new Point2D.Double(p[0], p[1]); |
1223 |
data = entity.getDwgObjectSpecificDataItem("SCALE");
|
1224 |
double[] newScale = (double[])data.getValue(); |
1225 |
data = entity.getDwgObjectSpecificDataItem("ROTATION");
|
1226 |
double newRot = ((Double)data.getValue()).doubleValue(); |
1227 |
data = entity.getDwgObjectSpecificDataItem("BLOCK_HEADER_HANDLE");
|
1228 |
int[] newBlockHandle = (int[])data.getValue(); |
1229 |
|
1230 |
Point2D pointAux = new Point2D.Double(newInsPoint.getX() - bPoint[0], newInsPoint.getY() - bPoint[1]); |
1231 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(rot) + (pointAux.getY()*scale[1])*(-1)*Math.sin(rot)); |
1232 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot)); |
1233 |
newInsPoint = new Point2D.Double(laX, laY); |
1234 |
|
1235 |
newScale = new double[]{scale[0]*newScale[0], scale[1]*newScale[1], scale[2]*newScale[2]}; |
1236 |
|
1237 |
manageInsert(dwgObjects, layerTable, newInsPoint, newScale, newRot, newBlockHandle, id, auxRow); |
1238 |
|
1239 |
/*auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
|
1240 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
|
1241 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
|
1242 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0);
|
1243 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
1244 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
|
1245 |
// Attributes
|
1246 |
/*for (int j=0;j<nAtt;j++) {
|
1247 |
String[] attributes = new String[2];
|
1248 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
1249 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
1250 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
1251 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
1252 |
}
|
1253 |
}*/
|
1254 |
/*FPoint2D fPoint = createPoint(newInsPoint);
|
1255 |
addShape(fPoint, auxRow);*/
|
1256 |
} else if (entity.getType()==0x0F) { |
1257 |
//System.out.println("Encuentra una polil?nea dentro de un bloque ...");
|
1258 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("FLAGS");
|
1259 |
int flags = ((Integer)data.getValue()).intValue(); |
1260 |
data = entity.getDwgObjectSpecificDataItem("FIRST_VERTEX_HANDLE");
|
1261 |
int[] firstVertexHandle = (int[])data.getValue(); |
1262 |
byte[] firstHandleBytes = new byte[]{0,0,0,0}; |
1263 |
if (firstVertexHandle.length>2) firstHandleBytes[3] = (byte)firstVertexHandle[2]; |
1264 |
if (firstVertexHandle.length>3) firstHandleBytes[2] = (byte)firstVertexHandle[3]; |
1265 |
if (firstVertexHandle.length>4) firstHandleBytes[1] = (byte)firstVertexHandle[4]; |
1266 |
if (firstVertexHandle.length>5) firstHandleBytes[0] = (byte)firstVertexHandle[5]; |
1267 |
int firstHandle = ByteUtils.bytesToInt(firstHandleBytes, new int[]{0}); |
1268 |
data = entity.getDwgObjectSpecificDataItem("LAST_VERTEX_HANDLE");
|
1269 |
int[] lastVertexHandle = (int[])data.getValue(); |
1270 |
byte[] lastHandleBytes = new byte[]{0,0,0,0}; |
1271 |
if (lastVertexHandle.length>2) lastHandleBytes[3] = (byte)lastVertexHandle[2]; |
1272 |
if (lastVertexHandle.length>3) lastHandleBytes[2] = (byte)lastVertexHandle[3]; |
1273 |
if (lastVertexHandle.length>4) lastHandleBytes[1] = (byte)lastVertexHandle[4]; |
1274 |
if (lastVertexHandle.length>5) lastHandleBytes[0] = (byte)lastVertexHandle[5]; |
1275 |
int lastHandle = ByteUtils.bytesToInt(lastHandleBytes, new int[]{0}); |
1276 |
Vector pts = new Vector(); |
1277 |
Vector bulges = new Vector(); |
1278 |
double[] pt = new double[2]; |
1279 |
|
1280 |
for (int j=0;j<dwgObjects.size();j++) { |
1281 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
1282 |
Vector handle = obj.getHandle();
|
1283 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
1284 |
if (handle.size()>2) handleBytes[3] = ((Integer)handle.get(2)).byteValue(); |
1285 |
if (handle.size()>3) handleBytes[2] = ((Integer)handle.get(3)).byteValue(); |
1286 |
if (handle.size()>4) handleBytes[1] = ((Integer)handle.get(4)).byteValue(); |
1287 |
if (handle.size()>5) handleBytes[0] = ((Integer)handle.get(5)).byteValue(); |
1288 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
1289 |
if (objHandle==firstHandle && ((Integer)handle.get(1)).intValue()==firstVertexHandle[1]) { |
1290 |
int k=0; |
1291 |
while (true) { |
1292 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
1293 |
Vector vertexHandle = vertex.getHandle();
|
1294 |
byte[] vHandleBytes = new byte[]{0,0,0,0}; |
1295 |
if (vertexHandle.size()>2) vHandleBytes[3] = ((Integer)vertexHandle.get(2)).byteValue(); |
1296 |
if (vertexHandle.size()>3) vHandleBytes[2] = ((Integer)vertexHandle.get(3)).byteValue(); |
1297 |
if (vertexHandle.size()>4) vHandleBytes[1] = ((Integer)vertexHandle.get(4)).byteValue(); |
1298 |
if (vertexHandle.size()>5) vHandleBytes[0] = ((Integer)vertexHandle.get(5)).byteValue(); |
1299 |
int vHandle = ByteUtils.bytesToInt(vHandleBytes, new int[]{0}); |
1300 |
data = vertex.getDwgObjectSpecificDataItem("POINT");
|
1301 |
pt = (double[])data.getValue(); |
1302 |
pts.add(new Point2D.Double(pt[0], pt[1])); |
1303 |
data = vertex.getDwgObjectSpecificDataItem("BULGE");
|
1304 |
double bulge = ((Double)data.getValue()).doubleValue(); |
1305 |
bulges.add(new Double(bulge)); |
1306 |
k++; |
1307 |
if (vHandle==lastHandle && ((Integer)vertexHandle.get(1)).intValue()==lastVertexHandle[1]) { |
1308 |
break;
|
1309 |
} |
1310 |
} |
1311 |
} |
1312 |
} |
1313 |
|
1314 |
Point2D[] newPts = new Point2D[pts.size()]; |
1315 |
if (flags==0 || flags==2 || flags==4 || flags==8 || flags==16 || flags==32 || flags==64 || flags==128) { |
1316 |
for (int j=0;j<pts.size();j++) { |
1317 |
newPts[j] = (Point2D)pts.get(j);
|
1318 |
} |
1319 |
} else if (flags==1 || flags==3 || flags==5 || flags==9 || flags==17 || flags==33 || flags==65 || flags==129) { |
1320 |
newPts = new Point2D[pts.size()+1]; |
1321 |
for (int j=0;j<pts.size();j++) { |
1322 |
newPts[j] = (Point2D)pts.get(j);
|
1323 |
} |
1324 |
newPts[pts.size()] = (Point2D)pts.get(0); |
1325 |
bulges.add(new Double(0)); |
1326 |
} |
1327 |
|
1328 |
for (int i=0;i<newPts.length;i++) { |
1329 |
Point2D pointAux = new Point2D.Double(newPts[i].getX() - bPoint[0], newPts[i].getY() - bPoint[1]); |
1330 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(rot) + (pointAux.getY()*scale[1])*(-1)*Math.sin(rot)); |
1331 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot)); |
1332 |
newPts[i] = new Point2D.Double(laX, laY); |
1333 |
} |
1334 |
|
1335 |
FPolyline2D pline = createPolyline2D(newPts, bulges); |
1336 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(id); |
1337 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D")); |
1338 |
String layerName = getLayerName(block, layerTable);
|
1339 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
1340 |
int color = entity.getColor();
|
1341 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
1342 |
int colorByBlock = getColorByLayer(block, layerTable);
|
1343 |
if (color==0) color = colorByBlock; |
1344 |
if (color==256) color = colorByLayer; |
1345 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
1346 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
|
1347 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
|
1348 |
// Attributes
|
1349 |
/*for (int j=0;j<nAtt;j++) {
|
1350 |
String[] attributes = new String[2];
|
1351 |
attributes = (String[])featureMaker.getAttributes().get(j);
|
1352 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
1353 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) {
|
1354 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
1355 |
}
|
1356 |
}*/
|
1357 |
addShape(pline, auxRow); |
1358 |
} else if (entity.getType()==0x2) { |
1359 |
//System.out.println("Encuentra un Attrib dentro de un bloque ...");
|
1360 |
} else if (entity.getType()==0x3) { |
1361 |
//System.out.println("Encuentra un Attdef dentro de un bloque ...");
|
1362 |
} |
1363 |
} |
1364 |
|
1365 |
/**
|
1366 |
* LayerTable podr?a ser un objeto y LayerTableRecord tambi?n ...
|
1367 |
* @param dwgObjects
|
1368 |
* @return
|
1369 |
*/
|
1370 |
private Vector createLayerTable(Vector dwgObjects) { |
1371 |
Vector layerTable = new Vector(); |
1372 |
for (int i=0;i<dwgObjects.size();i++) { |
1373 |
DwgObject obj = (DwgObject)dwgObjects.get(i); |
1374 |
if (obj.getType()==0x33) { |
1375 |
//System.out.println("Encuentra un objeto layer ...");
|
1376 |
Vector layerTableRecord = new Vector(); |
1377 |
layerTableRecord.add(obj.getHandle()); |
1378 |
layerTableRecord.add(((String)obj.getDwgObjectSpecificDataItem("NAME").getValue())); |
1379 |
//System.out.println("((Integer)obj.getDwgObjectSpecificDataItem(COLOR).getValue()).intValue() = " + ((Integer)obj.getDwgObjectSpecificDataItem("COLOR").getValue()).intValue());
|
1380 |
layerTableRecord.add(((Integer)obj.getDwgObjectSpecificDataItem("COLOR").getValue())); |
1381 |
//layerTableRecord.add(obj.getDwgObjectSpecificDataItem("LAYER_CONTROL_HANDLE").getValue());
|
1382 |
layerTable.add(layerTableRecord); |
1383 |
} |
1384 |
} |
1385 |
return layerTable;
|
1386 |
} |
1387 |
|
1388 |
//private String setLayerName(int[] layerHandle, Vector layerTable) {
|
1389 |
private String getLayerName(DwgObject entity, Vector layerTable) { |
1390 |
String layerName = ""; |
1391 |
int[] layerHandle = (int[])entity.getLayer(); |
1392 |
/*System.out.println("layerHandle[0] = " + layerHandle[0]);
|
1393 |
if (layerHandle.length>1) System.out.println("layerHandle[1] = " + layerHandle[1]);
|
1394 |
if (layerHandle.length>2) System.out.println("layerHandle[2] = " + layerHandle[2]);
|
1395 |
if (layerHandle.length>3) System.out.println("layerHandle[3] = " + layerHandle[3]);*/
|
1396 |
byte[] layerBytes = new byte[]{0,0,0,0}; |
1397 |
if (layerHandle.length>2) layerBytes[3] = (byte)layerHandle[2]; |
1398 |
if (layerHandle.length>3) layerBytes[2] = (byte)layerHandle[3]; |
1399 |
if (layerHandle.length>4) layerBytes[1] = (byte)layerHandle[4]; |
1400 |
if (layerHandle.length>5) layerBytes[0] = (byte)layerHandle[5]; |
1401 |
int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0}); |
1402 |
for (int j=0;j<layerTable.size();j++) { |
1403 |
Vector layerTableRecord = (Vector)layerTable.get(j); |
1404 |
Vector layerHandleVect = (Vector)layerTableRecord.get(0); |
1405 |
/*System.out.println("layerHandleVect.get(0) = " + layerHandleVect.get(0));
|
1406 |
if (layerHandleVect.size()>1) System.out.println("layerHandleVect.get(1) = " + layerHandleVect.get(1));
|
1407 |
if (layerHandleVect.size()>2) System.out.println("layerHandleVect.get(2) = " + layerHandleVect.get(2));
|
1408 |
if (layerHandleVect.size()>3) System.out.println("layerHandleVect.get(3) = " + layerHandleVect.get(3));*/
|
1409 |
byte[] layerHandleBytes = new byte[]{0,0,0,0}; |
1410 |
if (layerHandleVect.size()>2) layerHandleBytes[3] = (byte)((Integer)layerHandleVect.get(2)).intValue(); |
1411 |
if (layerHandleVect.size()>3) layerHandleBytes[2] = (byte)((Integer)layerHandleVect.get(3)).intValue(); |
1412 |
if (layerHandleVect.size()>4) layerHandleBytes[1] = (byte)((Integer)layerHandleVect.get(4)).intValue(); |
1413 |
if (layerHandleVect.size()>5) layerHandleBytes[0] = (byte)((Integer)layerHandleVect.get(5)).intValue(); |
1414 |
int lHandle = ByteUtils.bytesToInt(layerHandleBytes, new int[]{0}); |
1415 |
//System.out.println("lHandle = " + lHandle);
|
1416 |
//System.out.println("layer = " + layer);
|
1417 |
if (lHandle==layer) {
|
1418 |
layerName = (String)layerTableRecord.get(1); |
1419 |
//System.out.println("layerName = " + layerName);
|
1420 |
} |
1421 |
} |
1422 |
return layerName;
|
1423 |
} |
1424 |
|
1425 |
private int getColorByLayer(DwgObject entity, Vector layerTable) { |
1426 |
int[] layerHandle = (int[])entity.getLayer(); |
1427 |
int colorByLayer = 0; |
1428 |
byte[] layerBytes = new byte[]{0,0,0,0}; |
1429 |
if (layerHandle.length>2) layerBytes[3] = (byte)layerHandle[2]; |
1430 |
if (layerHandle.length>3) layerBytes[2] = (byte)layerHandle[3]; |
1431 |
if (layerHandle.length>4) layerBytes[1] = (byte)layerHandle[4]; |
1432 |
if (layerHandle.length>5) layerBytes[0] = (byte)layerHandle[5]; |
1433 |
int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0}); |
1434 |
for (int j=0;j<layerTable.size();j++) { |
1435 |
Vector layerTableRecord = (Vector)layerTable.get(j); |
1436 |
Vector layerHandleVect = (Vector)layerTableRecord.get(0); |
1437 |
byte[] layerHandleBytes = new byte[]{0,0,0,0}; |
1438 |
if (layerHandleVect.size()>2) layerHandleBytes[3] = (byte)((Integer)layerHandleVect.get(2)).intValue(); |
1439 |
if (layerHandleVect.size()>3) layerHandleBytes[2] = (byte)((Integer)layerHandleVect.get(3)).intValue(); |
1440 |
if (layerHandleVect.size()>4) layerHandleBytes[1] = (byte)((Integer)layerHandleVect.get(4)).intValue(); |
1441 |
if (layerHandleVect.size()>5) layerHandleBytes[0] = (byte)((Integer)layerHandleVect.get(5)).intValue(); |
1442 |
int lHandle = ByteUtils.bytesToInt(layerHandleBytes, new int[]{0}); |
1443 |
//System.out.println("layerHandle = " + layerHandle);
|
1444 |
//System.out.println("layer = " + layer);
|
1445 |
if (lHandle==layer) {
|
1446 |
colorByLayer = ((Integer)layerTableRecord.get(2)).intValue(); |
1447 |
//System.out.println("colorByLayer = " + colorByLayerObj.intValue());
|
1448 |
} |
1449 |
} |
1450 |
return colorByLayer;
|
1451 |
} |
1452 |
|
1453 |
/* (non-Javadoc)
|
1454 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
|
1455 |
*/
|
1456 |
public boolean accept(File f) { |
1457 |
return f.getName().toUpperCase().endsWith("DWG"); |
1458 |
} |
1459 |
|
1460 |
/* (non-Javadoc)
|
1461 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getShapeType()
|
1462 |
*/
|
1463 |
public int getShapeType() { |
1464 |
return FShape.MULTI;
|
1465 |
} |
1466 |
|
1467 |
/* (non-Javadoc)
|
1468 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getName()
|
1469 |
*/
|
1470 |
public String getName() { |
1471 |
return "gvSIG DWG Memory Driver"; |
1472 |
} |
1473 |
|
1474 |
/* (non-Javadoc)
|
1475 |
* @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
|
1476 |
*/
|
1477 |
public Legend getDefaultLegend() {
|
1478 |
return defaultLegend;
|
1479 |
} |
1480 |
|
1481 |
/* (non-Javadoc)
|
1482 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
|
1483 |
*/
|
1484 |
public DriverAttributes getDriverAttributes() {
|
1485 |
return attr;
|
1486 |
} |
1487 |
|
1488 |
} |