Revision 936 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java
DXFMemoryDriver.java | ||
---|---|---|
91 | 91 |
//System.out.println("initialize(): acadVersion = " + acadVersion); |
92 | 92 |
|
93 | 93 |
int nAtt = featureMaker.getAttributes().size(); |
94 |
/*Value[] auxRow = new Value[6+nAtt]; |
|
95 |
ArrayList arrayFields = new ArrayList(); |
|
96 |
arrayFields.add("ID"); |
|
97 |
arrayFields.add("Entity"); |
|
98 |
arrayFields.add("Layer"); |
|
99 |
arrayFields.add("Color"); |
|
100 |
arrayFields.add("Elevation"); |
|
101 |
arrayFields.add("Thickness"); |
|
102 |
for (int i=0;i<nAtt;i++) { |
|
103 |
String att[] = new String[2]; |
|
104 |
att = (String[])featureMaker.getAttributes().get(i); |
|
105 |
arrayFields.add(att[0]); |
|
106 |
}*/ |
|
107 | 94 |
|
108 | 95 |
// Campos de las MemoryLayer: |
109 | 96 |
Value[] auxRow = new Value[9+nAtt]; |
... | ... | |
123 | 110 |
arrayFields.add(att[0]); |
124 | 111 |
} |
125 | 112 |
|
126 |
// No coje arrayFieldsTxt, coje solo arrayFields ... |
|
127 |
//getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
|
128 | 113 |
getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
129 | 114 |
|
130 | 115 |
for (int i=0;i<features.size();i++) { |
... | ... | |
132 | 117 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0); |
133 | 118 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0); |
134 | 119 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
135 |
//auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(0); |
|
136 | 120 |
|
137 | 121 |
Feature fea = (Feature)features.get(i); |
138 | 122 |
if (fea.getGeometry() instanceof Point) { |
... | ... | |
141 | 125 |
pto = (Point2D.Double)point.get(0); |
142 | 126 |
FShape nuevoShp; |
143 | 127 |
if (point.isText) { |
144 |
//auxRow[ID_FIELD_ID] = new Integer(i); |
|
145 | 128 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
146 | 129 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
147 |
//System.out.println("initialize(): fea.getProp(dxfEntity) = " + fea.getProp("dxfEntity")); |
|
148 | 130 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
149 | 131 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
150 | 132 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
... | ... | |
166 | 148 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
167 | 149 |
} |
168 | 150 |
} |
169 |
//System.out.println("initialize(): pto.getX() = " + pto.getX()); |
|
170 | 151 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0); |
171 | 152 |
addShape(nuevoShp, auxRow); |
172 | 153 |
} else { |
... | ... | |
183 | 164 |
for (int j=0;j<nAtt;j++) { |
184 | 165 |
String[] attributes = new String[2]; |
185 | 166 |
attributes = (String[])featureMaker.getAttributes().get(j); |
186 |
auxRow[6+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
167 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
187 | 168 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
188 |
auxRow[6+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
169 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
189 | 170 |
} |
190 | 171 |
} |
191 | 172 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0); |
... | ... | |
200 | 181 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
201 | 182 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
202 | 183 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
203 |
//auxRow[4] = new String(fea.getProp("text")); |
|
204 | 184 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
205 | 185 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
206 | 186 |
// Attributes |
207 | 187 |
for (int j=0;j<nAtt;j++) { |
208 | 188 |
String[] attributes = new String[2]; |
209 | 189 |
attributes = (String[])featureMaker.getAttributes().get(j); |
210 |
auxRow[6+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
190 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
211 | 191 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
212 |
auxRow[6+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
192 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
213 | 193 |
} |
214 | 194 |
} |
215 | 195 |
FShape nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0); |
... | ... | |
237 | 217 |
for (int j=0;j<nAtt;j++) { |
238 | 218 |
String[] attributes = new String[2]; |
239 | 219 |
attributes = (String[])featureMaker.getAttributes().get(j); |
240 |
auxRow[6+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
220 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
241 | 221 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
242 |
auxRow[6+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
222 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
243 | 223 |
} |
244 | 224 |
} |
245 | 225 |
FShape nuevoShp = new FPolyline2D(genPathX); |
246 | 226 |
addShape(nuevoShp, auxRow); |
247 | 227 |
} else if (fea.getGeometry() instanceof Polygon) { |
248 | 228 |
GeneralPathX genPathX = new GeneralPathX(); |
249 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
|
229 |
// 050112: A?ado una posici?n m?s para el punto que cierra y |
|
230 |
// creo el objeto firstPt. |
|
231 |
Point2D firstPt = new Point2D.Double(); |
|
232 |
firstPt = (Point2D)fea.getGeometry().get(0); |
|
233 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()+1]; |
|
250 | 234 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
251 | 235 |
pts[j] = (Point2D)fea.getGeometry().get(j); |
252 | 236 |
} |
237 |
// 050112: A?ado el primer punto al final para cerrar los pol?gonos. |
|
238 |
pts[fea.getGeometry().pointNr()] = firstPt; |
|
253 | 239 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
254 | 240 |
for (int j=1; j < pts.length; j++) { |
255 | 241 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
... | ... | |
267 | 253 |
for (int j=0;j<nAtt;j++) { |
268 | 254 |
String[] attributes = new String[2]; |
269 | 255 |
attributes = (String[])featureMaker.getAttributes().get(j); |
270 |
auxRow[6+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
256 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
271 | 257 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
272 |
auxRow[6+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
258 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
273 | 259 |
} |
274 | 260 |
} |
275 | 261 |
FShape nuevoShp = new FPolygon2D(genPathX); |
... | ... | |
282 | 268 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(getShapeType()); |
283 | 269 |
defaultLegend.setFieldName("Color"); |
284 | 270 |
|
285 |
// Esta l?nea provoca una nullpointerexception en la carga del DXF ... |
|
286 |
//defaultLegend.setLabelField("Text"); |
|
271 |
defaultLegend.setLabelField("Text"); |
|
287 | 272 |
defaultLegend.setDefaultSymbol(new FSymbol(getShapeType())); |
288 | 273 |
defaultLegend.getDefaultSymbol().setShapeVisible(false); |
289 | 274 |
defaultLegend.getDefaultSymbol().setFontSizeInPixels(false); |
... | ... | |
301 | 286 |
try { |
302 | 287 |
for (long j = 0; j < rs.getRowCount(); j++) |
303 | 288 |
{ |
304 |
//System.out.println("initialize(): j = " + j); |
|
305 |
clave =(IntValue) rs.getFieldValue(j,ID_FIELD_COLOR); |
|
289 |
clave = (IntValue)rs.getFieldValue(j,ID_FIELD_COLOR); |
|
306 | 290 |
if (defaultLegend.getSymbolByValue(clave) == null) |
307 | 291 |
{ |
308 |
theSymbol = new FSymbol(getShapeType());
|
|
292 |
theSymbol = new FSymbol(getShapeType()); |
|
309 | 293 |
theSymbol.setDescription(clave.toString()); |
310 | 294 |
theSymbol.setColor(AcadColor.getColor(clave.getValue())); |
311 | 295 |
theSymbol.setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE); |
... | ... | |
314 | 298 |
} // for |
315 | 299 |
} catch (DriverException e) { |
316 | 300 |
e.printStackTrace(); |
317 |
throw new IOException("Error al poner la legenda por defecto en el DXF");
|
|
301 |
throw new IOException("Error al poner la leyenda por defecto en el DXF");
|
|
318 | 302 |
} |
319 | 303 |
} |
320 | 304 |
|
Also available in: Unified diff