root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dgn / DgnMemoryDriver.java @ 1100
History | View | Annotate | Download (19.5 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.drivers.dgn; |
42 |
|
43 |
import com.hardcode.gdbms.engine.data.DriverException; |
44 |
import com.hardcode.gdbms.engine.data.ReadDriver; |
45 |
import com.hardcode.gdbms.engine.values.IntValue; |
46 |
import com.hardcode.gdbms.engine.values.Value; |
47 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
48 |
|
49 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
50 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
51 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
52 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
53 |
import com.iver.cit.gvsig.fmap.core.FShape; |
54 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
55 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
56 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
57 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
58 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
59 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
60 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
61 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
62 |
|
63 |
import java.awt.Color; |
64 |
import java.awt.Font; |
65 |
import java.awt.geom.AffineTransform; |
66 |
import java.awt.geom.Arc2D; |
67 |
|
68 |
import java.io.File; |
69 |
import java.io.IOException; |
70 |
|
71 |
import java.util.ArrayList; |
72 |
|
73 |
|
74 |
/**
|
75 |
* Driver DGN que trabaja directamente cargando el fichero en memoria.
|
76 |
*
|
77 |
* @author Vicente Caballero Navarro
|
78 |
*/
|
79 |
public class DgnMemoryDriver extends MemoryDriver implements WithDefaultLegend { |
80 |
private final int ID_FIELD_ID = 0; |
81 |
private final int ID_FIELD_ENTITY = 1; |
82 |
private final int ID_FIELD_LAYER = 2; |
83 |
private final int ID_FIELD_COLOR = 3; |
84 |
private final int ID_FIELD_HEIGHTTEXT = 4; |
85 |
private final int ID_FIELD_ROTATIONTEXT = 5; |
86 |
private final int ID_FIELD_TEXT = 6; |
87 |
DGNReader m_DgnReader; |
88 |
VectorialUniqueValueLegend defaultLegend; |
89 |
private String path; |
90 |
private File m_Fich; |
91 |
|
92 |
/**
|
93 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)
|
94 |
*/
|
95 |
public void open(File f) throws IOException { |
96 |
m_Fich = f; |
97 |
} |
98 |
|
99 |
/**
|
100 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()
|
101 |
*/
|
102 |
public void initialize() throws IOException { |
103 |
float heightText = 10; |
104 |
|
105 |
m_DgnReader = new DGNReader(m_Fich.getAbsolutePath());
|
106 |
|
107 |
Value[] auxRow = new Value[7]; |
108 |
Value[] cellRow = new Value[7]; |
109 |
Value[] complexRow = new Value[7]; |
110 |
ArrayList arrayFields = new ArrayList(); |
111 |
arrayFields.add("ID");
|
112 |
arrayFields.add("Entity");
|
113 |
arrayFields.add("Layer");
|
114 |
arrayFields.add("Color");
|
115 |
arrayFields.add("HeightText");
|
116 |
arrayFields.add("RotationText");
|
117 |
arrayFields.add("Text");
|
118 |
|
119 |
getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
120 |
|
121 |
// Ahora las rellenamos.
|
122 |
FShape aux; |
123 |
boolean bElementoCompuesto = false; |
124 |
boolean bEsPoligono = false; |
125 |
boolean bInsideCell = false; |
126 |
boolean bFirstHoleEntity = false; |
127 |
boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas |
128 |
int contadorSubElementos = 0; |
129 |
int numSubElementos = 0; |
130 |
int complex_index_fill_color = -1; |
131 |
int nClass; // Para filtrar los elementos de construcci?n, etc. |
132 |
GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
133 |
|
134 |
for (int id = 0; id < m_DgnReader.getNumEntities(); id++) { |
135 |
// System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities());
|
136 |
m_DgnReader.DGNGotoElement(id); |
137 |
|
138 |
DGNElemCore elemento = m_DgnReader.DGNReadElement(); |
139 |
nClass = 0;
|
140 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0);
|
141 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0);
|
142 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
143 |
|
144 |
if (elemento.properties != 0) { |
145 |
nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS; |
146 |
} |
147 |
|
148 |
if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento |
149 |
{ |
150 |
aux = null;
|
151 |
|
152 |
// if ((elemento.element_id > 3800) && (elemento.element_id < 3850))
|
153 |
// m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,"");
|
154 |
if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) ||
|
155 |
(elemento.stype == DGNFileHeader.DGNST_ARC) || |
156 |
(elemento.stype == DGNFileHeader.DGNST_CELL_HEADER) || |
157 |
(elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN) || |
158 |
(elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) { |
159 |
if (elemento.complex != 0) { |
160 |
bElementoCompuesto = true;
|
161 |
} else {
|
162 |
if (bElementoCompuesto) {
|
163 |
if (bInsideCell) {
|
164 |
auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY]; |
165 |
} else {
|
166 |
auxRow = complexRow; |
167 |
} |
168 |
|
169 |
// System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
|
170 |
addShape(new FPolyline2D(elementoCompuesto), auxRow);
|
171 |
|
172 |
if (bEsPoligono) {
|
173 |
if (complex_index_fill_color != -1) { |
174 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color); |
175 |
} |
176 |
|
177 |
addShape(new FPolygon2D(elementoCompuesto),
|
178 |
auxRow); |
179 |
} |
180 |
|
181 |
elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
182 |
} |
183 |
|
184 |
// System.err.println("Entidad simple");
|
185 |
bElementoCompuesto = false;
|
186 |
bEsPoligono = false;
|
187 |
bConnect = false;
|
188 |
|
189 |
// elementoCompuesto = new GeneralPathX();
|
190 |
bInsideCell = false;
|
191 |
} |
192 |
} |
193 |
|
194 |
switch (elemento.stype) {
|
195 |
case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
|
196 |
bInsideCell = true;
|
197 |
cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
198 |
cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
199 |
cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
200 |
cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
201 |
"Shared Cell");
|
202 |
|
203 |
break;
|
204 |
|
205 |
case DGNFileHeader.DGNST_CELL_HEADER:
|
206 |
bInsideCell = true;
|
207 |
|
208 |
DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento; |
209 |
cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
210 |
cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
211 |
cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
212 |
cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
213 |
"Cell");
|
214 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
215 |
|
216 |
// System.err.println("Cell Header " + complex_index_fill_color);
|
217 |
break;
|
218 |
|
219 |
case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
220 |
|
221 |
// bElementoCompuesto = true;
|
222 |
// System.err.println("Complex Header");
|
223 |
contadorSubElementos = 0;
|
224 |
|
225 |
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento; |
226 |
numSubElementos = psComplexHeader.numelems; |
227 |
complexRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
228 |
complexRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
229 |
complexRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
230 |
complexRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
231 |
"Complex");
|
232 |
|
233 |
if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) {
|
234 |
bEsPoligono = true;
|
235 |
|
236 |
// Si es un agujero, no conectamos con el anterior
|
237 |
if ((psComplexHeader.properties & 0x8000) != 0) { |
238 |
bFirstHoleEntity = true;
|
239 |
} else {
|
240 |
// Miramos si tiene color de relleno
|
241 |
// complex_index_fill_color = -1;
|
242 |
// if (elemento.attr_bytes > 0) {
|
243 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
244 |
|
245 |
// System.err.println("complex shape fill color = " + elemento.color);
|
246 |
// }
|
247 |
} |
248 |
|
249 |
bConnect = true;
|
250 |
} else {
|
251 |
bEsPoligono = false;
|
252 |
bConnect = false;
|
253 |
} |
254 |
|
255 |
break;
|
256 |
|
257 |
case DGNFileHeader.DGNST_MULTIPOINT:
|
258 |
|
259 |
// OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric
|
260 |
// spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos
|
261 |
// y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran.
|
262 |
// TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora.
|
263 |
// Es posible que tenga que ver con lo de los arcos (arco distorsionado), que
|
264 |
// todav?a no est? metido.
|
265 |
DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento; |
266 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
267 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
268 |
|
269 |
if ((psLine.num_vertices == 2) && |
270 |
(psLine.vertices[0].x == psLine.vertices[1].x) && |
271 |
(psLine.vertices[0].y == psLine.vertices[1].y)) { |
272 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
273 |
"Point");
|
274 |
addShape(new FPoint3D(psLine.vertices[0].x, |
275 |
psLine.vertices[0].y, psLine.vertices[0].z), |
276 |
auxRow); |
277 |
} else {
|
278 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
279 |
|
280 |
if (psLine.type == DGNFileHeader.DGNT_CURVE) {
|
281 |
psLine.num_vertices = psLine.num_vertices - 4;
|
282 |
|
283 |
for (int aux_n = 0; |
284 |
aux_n < psLine.num_vertices; aux_n++) { |
285 |
psLine.vertices[aux_n] = psLine.vertices[aux_n + |
286 |
2];
|
287 |
} |
288 |
} |
289 |
|
290 |
if ((psLine.type == DGNFileHeader.DGNT_SHAPE) &&
|
291 |
((psLine.properties & 0x8000) != 0)) { |
292 |
// Invertimos el orden porque es un agujero
|
293 |
elShape.moveTo(psLine.vertices[psLine.num_vertices - |
294 |
1].x,
|
295 |
psLine.vertices[psLine.num_vertices - 1].y);
|
296 |
|
297 |
for (int i = psLine.num_vertices - 2; i >= 0; |
298 |
i--) |
299 |
elShape.lineTo(psLine.vertices[i].x, |
300 |
psLine.vertices[i].y); |
301 |
} else {
|
302 |
elShape.moveTo(psLine.vertices[0].x,
|
303 |
psLine.vertices[0].y);
|
304 |
|
305 |
for (int i = 1; i < psLine.num_vertices; i++) |
306 |
elShape.lineTo(psLine.vertices[i].x, |
307 |
psLine.vertices[i].y); |
308 |
} |
309 |
|
310 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
311 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
312 |
"Multipoint");
|
313 |
|
314 |
if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - |
315 |
1].x) &&
|
316 |
(psLine.vertices[0].y == psLine.vertices[psLine.num_vertices -
|
317 |
1].y)) {
|
318 |
// Lo a?adimos tambi?n como pol?gono
|
319 |
bEsPoligono = true;
|
320 |
|
321 |
// Miramos si tiene color de relleno
|
322 |
if (elemento.attr_bytes > 0) { |
323 |
elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
324 |
|
325 |
// System.err.println("fill color = " + elemento.color);
|
326 |
if (elemento.color != -1) { |
327 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
328 |
} |
329 |
} |
330 |
|
331 |
if (elemento.complex == 0) { |
332 |
addShape(new FPolygon2D(elShape), auxRow);
|
333 |
} |
334 |
} |
335 |
|
336 |
if (elemento.complex != 0) { |
337 |
// Si es un agujero o
|
338 |
// es la primera entidad del agujero, lo a?adimos sin unir al anterior
|
339 |
if (bFirstHoleEntity ||
|
340 |
((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
341 |
((psLine.properties & 0x8000) != 0))) { |
342 |
elementoCompuesto.append(elShape, false);
|
343 |
bFirstHoleEntity = false;
|
344 |
} else {
|
345 |
elementoCompuesto.append(elShape, bConnect); |
346 |
} |
347 |
} else {
|
348 |
addShape(new FPolyline2D(elShape), auxRow);
|
349 |
} |
350 |
} |
351 |
|
352 |
break;
|
353 |
|
354 |
case DGNFileHeader.DGNST_ARC:
|
355 |
|
356 |
// m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento,"");
|
357 |
DGNElemArc psArc = (DGNElemArc) elemento; |
358 |
|
359 |
// La definici?n de arco de MicroStation es distinta a la de Java.
|
360 |
// En el dgn el origin se entiende que es el centro del arco,
|
361 |
// y a la hora de crear un Arc2D las 2 primeras coordenadas son
|
362 |
// la esquina inferior izquierda del rect?ngulo que rodea al arco.
|
363 |
// 1.- Creamos la elipse sin rotaci?n.
|
364 |
// 2.- Creamos el arco
|
365 |
// 3.- Rotamos el resultado
|
366 |
|
367 |
/* System.out.println("Arco con primari axis: " + psArc.primary_axis +
|
368 |
" start angle: " + psArc.startang + " sweepang = " + psArc.sweepang);
|
369 |
System.out.println("secondaria axis: " + psArc.secondary_axis +
|
370 |
" rotation = " + psArc.rotation); */
|
371 |
AffineTransform mT = AffineTransform.getRotateInstance(Math.toRadians( |
372 |
psArc.rotation), psArc.origin.x, |
373 |
psArc.origin.y); |
374 |
|
375 |
// mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
|
376 |
Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x - |
377 |
psArc.primary_axis, |
378 |
psArc.origin.y - psArc.secondary_axis, |
379 |
2.0 * psArc.primary_axis,
|
380 |
2.0 * psArc.secondary_axis, -psArc.startang,
|
381 |
-psArc.sweepang, Arc2D.OPEN);
|
382 |
|
383 |
// Ellipse2D.Double elArco = new Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
|
384 |
// psArc.origin.y - psArc.secondary_axis,2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis);
|
385 |
GeneralPathX elShapeArc = new GeneralPathX(elArco);
|
386 |
|
387 |
// Transformamos el GeneralPahtX porque si transformamos elArco nos lo convierte
|
388 |
// a GeneralPath y nos guarda las coordenadas en float, con la correspondiente p?rdida de precisi?n
|
389 |
elShapeArc.transform(mT); |
390 |
|
391 |
if (m_DgnReader.getInfo().dimension == 3) { |
392 |
//Aqu? podr?amos hacer cosas con la coordenada Z
|
393 |
} |
394 |
|
395 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
396 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
397 |
"Arc");
|
398 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
399 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
400 |
|
401 |
/* Line2D.Double ejeMayor = new Line2D.Double(psArc.origin.x - psArc.primary_axis, psArc.origin.y,
|
402 |
psArc.origin.x + psArc.primary_axis, psArc.origin.y);
|
403 |
|
404 |
lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, new GeneralPathX(ejeMayor)), auxRow); */
|
405 |
|
406 |
// lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow);
|
407 |
if (elemento.complex != 0) { |
408 |
// Esto es una posible fuente de fallos si detr?s de una
|
409 |
// elipse vienen m?s cosas pegadas. Deber?amos volver
|
410 |
// a conectar una vez pasada la elipse.
|
411 |
if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) {
|
412 |
bConnect = false;
|
413 |
} |
414 |
|
415 |
// SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
|
416 |
// Y EL ELEMENTO ES UN POLIGONO
|
417 |
if (bFirstHoleEntity ||
|
418 |
((elemento.type == DGNFileHeader.DGNT_SHAPE) && |
419 |
((elemento.properties & 0x8000) != 0))) { |
420 |
elementoCompuesto.append(elShapeArc, false);
|
421 |
bFirstHoleEntity = false;
|
422 |
} else {
|
423 |
elementoCompuesto.append(elShapeArc, bConnect); |
424 |
} |
425 |
} else {
|
426 |
addShape(new FPolyline2D(elShapeArc), auxRow);
|
427 |
|
428 |
if (psArc.type == DGNFileHeader.DGNT_ELLIPSE) {
|
429 |
addShape(new FPolygon2D(elShapeArc), auxRow);
|
430 |
} |
431 |
} |
432 |
|
433 |
// System.err.println("Entra un Arco");
|
434 |
break;
|
435 |
|
436 |
case DGNFileHeader.DGNST_TEXT:
|
437 |
|
438 |
DGNElemText psText = (DGNElemText) elemento; |
439 |
FPoint2D elShapeTxt = new FPoint3D(psText.origin.x,
|
440 |
psText.origin.y, psText.origin.z); |
441 |
|
442 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
443 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
444 |
"Text");
|
445 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
446 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
447 |
heightText = (float) psText.height_mult;
|
448 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText); |
449 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(psText.rotation); |
450 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(psText.string); // .trim();
|
451 |
addShape(elShapeTxt, auxRow); |
452 |
|
453 |
// System.out.println("Rotaci?n texto: " + psText.rotation + "Altura Texto = " + heightText);
|
454 |
|
455 |
/* System.out.println(" origin=(" + psText.origin.x +
|
456 |
", " + psText.origin.y + ") rotation=" +
|
457 |
psText.rotation + "\n" + " font=" +
|
458 |
psText.font_id + " just=" +
|
459 |
psText.justification + "length_mult=" +
|
460 |
psText.length_mult + " height_mult=" +
|
461 |
psText.height_mult + "\n" + " string =" +
|
462 |
new String(psText.string).toString().trim() +
|
463 |
"\n"); */
|
464 |
break;
|
465 |
|
466 |
/* default:
|
467 |
m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, "");
|
468 |
*/
|
469 |
} // switch
|
470 |
} // if
|
471 |
} // for
|
472 |
|
473 |
if (bElementoCompuesto) {
|
474 |
if (bInsideCell) {
|
475 |
auxRow = cellRow; |
476 |
} else {
|
477 |
auxRow = complexRow; |
478 |
} |
479 |
|
480 |
// System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
|
481 |
addShape(new FPolyline2D(elementoCompuesto), auxRow);
|
482 |
|
483 |
if (bEsPoligono) {
|
484 |
if (complex_index_fill_color != -1) { |
485 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color); |
486 |
} |
487 |
|
488 |
addShape(new FPolygon2D(elementoCompuesto), auxRow);
|
489 |
} |
490 |
} |
491 |
|
492 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(getShapeType()); |
493 |
defaultLegend.setFieldName("Color");
|
494 |
defaultLegend.setLabelField("Text");
|
495 |
defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
|
496 |
defaultLegend.getDefaultSymbol().setShapeVisible(false);
|
497 |
defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
|
498 |
defaultLegend.getDefaultSymbol().setFont(new Font("SansSerif", |
499 |
Font.PLAIN, 9)); |
500 |
defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
|
501 |
defaultLegend.getDefaultSymbol().setFontSize(heightText); |
502 |
defaultLegend.getDefaultSymbol().setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE); |
503 |
|
504 |
defaultLegend.setLabelHeightField("HeightText");
|
505 |
defaultLegend.setLabelRotationField("RotationText");
|
506 |
|
507 |
ReadDriver rs = this;
|
508 |
IntValue clave; |
509 |
FSymbol theSymbol = null;
|
510 |
|
511 |
try {
|
512 |
for (long j = 0; j < rs.getRowCount(); j++) { |
513 |
clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR); |
514 |
|
515 |
if (defaultLegend.getSymbolByValue(clave) == null) { |
516 |
theSymbol = new FSymbol(getShapeType());
|
517 |
theSymbol.setDescription(clave.toString()); |
518 |
theSymbol.setColor(m_DgnReader.DGNLookupColor( |
519 |
clave.getValue())); |
520 |
theSymbol.setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE); |
521 |
defaultLegend.addSymbol(clave, theSymbol); |
522 |
} |
523 |
} // for
|
524 |
} catch (DriverException e) {
|
525 |
e.printStackTrace(); |
526 |
throw new IOException( |
527 |
"Error al poner la legenda por defecto en el DGN");
|
528 |
} |
529 |
} |
530 |
|
531 |
/**
|
532 |
* Devuelve el tipo de shape que contiene el formato DGN.
|
533 |
*
|
534 |
* @return Entero que representa el tipo de shape.
|
535 |
*/
|
536 |
public int getShapeType() { |
537 |
return FShape.MULTI;
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* @see com.hardcode.driverManager.Driver#getType()
|
542 |
*/
|
543 |
public String getName() { |
544 |
return "gvSIG DGN Memory Driver"; |
545 |
} |
546 |
|
547 |
/**
|
548 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)
|
549 |
*/
|
550 |
public boolean accept(File f) { |
551 |
return f.getName().toUpperCase().endsWith("DGN"); |
552 |
} |
553 |
|
554 |
/* (non-Javadoc)
|
555 |
* @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
|
556 |
*/
|
557 |
public Legend getDefaultLegend() {
|
558 |
return defaultLegend;
|
559 |
} |
560 |
} |