root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / DwgObjectFactory.java @ 10054
History | View | Annotate | Download (10.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-dic-2006
|
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 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: DwgObjectFactory.java 10054 2007-02-01 20:03:21Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.8 2007-02-01 20:00:27 azabala
|
49 |
* *** empty log message ***
|
50 |
*
|
51 |
* Revision 1.7 2007/01/31 18:20:58 fdiaz
|
52 |
* A?adido un return null al final de metodo create por si no entra en ninguna de las condiciones.
|
53 |
*
|
54 |
* Revision 1.6 2007/01/31 10:01:11 fdiaz
|
55 |
* A?adido el DwgDictionary.
|
56 |
*
|
57 |
* Revision 1.5 2007/01/30 19:40:23 azabala
|
58 |
* *** empty log message ***
|
59 |
*
|
60 |
* Revision 1.4 2007/01/30 12:37:18 azabala
|
61 |
* *** empty log message ***
|
62 |
*
|
63 |
* Revision 1.3 2007/01/24 20:14:31 azabala
|
64 |
* implementation of reader of V14
|
65 |
*
|
66 |
* Revision 1.2 2007/01/12 19:35:00 azabala
|
67 |
* *** empty log message ***
|
68 |
*
|
69 |
* Revision 1.1 2007/01/09 15:39:15 azabala
|
70 |
* *** empty log message ***
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
package com.iver.cit.jdwglib.dwg; |
75 |
|
76 |
import com.iver.cit.jdwglib.dwg.objects.DwgArc; |
77 |
import com.iver.cit.jdwglib.dwg.objects.DwgAttdef; |
78 |
import com.iver.cit.jdwglib.dwg.objects.DwgAttrib; |
79 |
import com.iver.cit.jdwglib.dwg.objects.DwgBlock; |
80 |
import com.iver.cit.jdwglib.dwg.objects.DwgBlockControl; |
81 |
import com.iver.cit.jdwglib.dwg.objects.DwgBlockHeader; |
82 |
import com.iver.cit.jdwglib.dwg.objects.DwgCircle; |
83 |
import com.iver.cit.jdwglib.dwg.objects.DwgDictionary; |
84 |
import com.iver.cit.jdwglib.dwg.objects.DwgDictionaryVar; |
85 |
import com.iver.cit.jdwglib.dwg.objects.DwgEllipse; |
86 |
import com.iver.cit.jdwglib.dwg.objects.DwgEndblk; |
87 |
import com.iver.cit.jdwglib.dwg.objects.DwgHatch; |
88 |
import com.iver.cit.jdwglib.dwg.objects.DwgInsert; |
89 |
import com.iver.cit.jdwglib.dwg.objects.DwgLayer; |
90 |
import com.iver.cit.jdwglib.dwg.objects.DwgLayerControl; |
91 |
import com.iver.cit.jdwglib.dwg.objects.DwgLine; |
92 |
import com.iver.cit.jdwglib.dwg.objects.DwgLinearDimension; |
93 |
import com.iver.cit.jdwglib.dwg.objects.DwgLwPolyline; |
94 |
import com.iver.cit.jdwglib.dwg.objects.DwgMText; |
95 |
import com.iver.cit.jdwglib.dwg.objects.DwgPoint; |
96 |
import com.iver.cit.jdwglib.dwg.objects.DwgPolyline2D; |
97 |
import com.iver.cit.jdwglib.dwg.objects.DwgPolyline3D; |
98 |
import com.iver.cit.jdwglib.dwg.objects.DwgSeqend; |
99 |
import com.iver.cit.jdwglib.dwg.objects.DwgSolid; |
100 |
import com.iver.cit.jdwglib.dwg.objects.DwgSpline; |
101 |
import com.iver.cit.jdwglib.dwg.objects.DwgText; |
102 |
import com.iver.cit.jdwglib.dwg.objects.DwgVertex2D; |
103 |
import com.iver.cit.jdwglib.dwg.objects.DwgVertex3D; |
104 |
|
105 |
/**
|
106 |
* Factory that creates dwg entities from its code.
|
107 |
*
|
108 |
* It's a singleton
|
109 |
*
|
110 |
*/
|
111 |
public class DwgObjectFactory { |
112 |
|
113 |
private static DwgObjectFactory _instance = new DwgObjectFactory(); |
114 |
|
115 |
private DwgObjectFactory() {
|
116 |
} |
117 |
|
118 |
public static final DwgObjectFactory getInstance() { |
119 |
return _instance;
|
120 |
} |
121 |
/*
|
122 |
* _objprops = [
|
123 |
(True, None), # Unused [0x00]
|
124 |
(True, text_reader), # Text
|
125 |
(True, attrib_reader), # Attrib
|
126 |
(True, attdef_reader), # Attdef
|
127 |
(True, block_reader), # Block
|
128 |
(True, endblk_reader), # Endblk
|
129 |
(True, seqend_reader), # Seqend
|
130 |
(True, insert_reader), # Insert
|
131 |
(True, minsert_reader), # Minsert [0x08]
|
132 |
(False, None), # Skipped [0x09]
|
133 |
(True, vertex2d_reader), # Vertex_2D
|
134 |
(True, vertex3d_reader), # Vertex_3D
|
135 |
(True, vertex_mesh_reader), # Vertex_mesh
|
136 |
(True, vertex_pface_reader), # Vertex_pface
|
137 |
(True, vertex_pface_face_reader), # Vertex_pface_face
|
138 |
(True, polyline2d_reader), # Polyline_2D
|
139 |
(True, polyline3d_reader), # Polyline_3D [0x10]
|
140 |
(True, arc_reader), # Arc,
|
141 |
(True, circle_reader), # Circle,
|
142 |
(True, line_reader), # Line
|
143 |
(True, dimord_reader), # Dimension_ord
|
144 |
(True, dimlin_reader), # Dimension_lin
|
145 |
(True, dimalign_reader), # Dimension_align
|
146 |
(True, dimang3p_reader), # Dimension_angle_3pt
|
147 |
(True, dimang2l_reader), # Dimension_angle_2ln [0x18]
|
148 |
(True, dimrad_reader), # Dimension_radius
|
149 |
(True, dimdia_reader), # Dimension_diameter
|
150 |
(True, point_reader), # Point
|
151 |
(True, face3d_reader), # Face3D
|
152 |
(True, pface_reader), # Polyline_pface
|
153 |
(True, mesh_reader), # Polyline_mesh
|
154 |
(True, solid_reader), # Solid
|
155 |
(True, trace_reader), # Trace [0x20]
|
156 |
(True, shape_reader), # Shape
|
157 |
(True, viewport_reader), # Viewport
|
158 |
(True, ellipse_reader), # Ellipse
|
159 |
(True, spline_reader), # Spline
|
160 |
(True, rsb_reader), # Region
|
161 |
(True, rsb_reader), # Solid3D
|
162 |
(True, rsb_reader), # Body
|
163 |
(True, ray_reader), # Ray [0x28]
|
164 |
(True, xline_reader), # Xline
|
165 |
(False, dict_reader), # Dictionary
|
166 |
(False, None), # Skipped [0x2b]
|
167 |
(True, mtext_reader), # Mtext
|
168 |
(True, leader_reader), # Leader
|
169 |
(True, tolerance_reader), # Tolerance
|
170 |
(True, mline_reader), # Mline
|
171 |
(False, block_control_reader), # Block control [0x30]
|
172 |
(False, block_header_reader), # Block header
|
173 |
(False, layer_control_reader), # Layer control
|
174 |
(False, layer_reader), # Layer
|
175 |
(False, shapefile_control_reader), # Style control
|
176 |
(False, shapefile_reader), # Style
|
177 |
(False, None), # Skipped [0x36]
|
178 |
(False, None), # Skipped [0x37]
|
179 |
(False, linetype_control_reader), # Linetype control [0x38]
|
180 |
(False, linetype_reader), # Linetype
|
181 |
(False, None), # Skipped [0x3a]
|
182 |
(False, None), # Skipped [0x3b]
|
183 |
(False, view_control_reader), # View control [0x3c]
|
184 |
(False, view_reader), # View
|
185 |
(False, ucs_control_reader), # UCS control,
|
186 |
(False, ucs_reader), # UCS
|
187 |
(False, vport_control_reader), # Vport control [0x40]
|
188 |
(False, vport_reader), # Vport
|
189 |
(False, appid_control_reader), # Appid control
|
190 |
(False, appid_reader), # Appid
|
191 |
(False, dimstyle_control_reader), # Dimstyle control
|
192 |
(False, dimstyle_reader), # Dimstyle
|
193 |
(False, vpentity_control_reader), # VP ENT HDR control
|
194 |
(False, vpentity_reader), # VP ENT HDR
|
195 |
(False, group_reader), # Group [0x48]
|
196 |
(False, mlinestyle_reader), # Mlinestyle
|
197 |
]
|
198 |
*
|
199 |
*
|
200 |
*
|
201 |
*
|
202 |
*
|
203 |
* */
|
204 |
public DwgObject create(int type, int index) { |
205 |
DwgObject obj = null;
|
206 |
|
207 |
if (type == 0x11) { |
208 |
obj = new DwgArc(index);
|
209 |
obj.setGraphicsFlag(true);
|
210 |
} else if (type == 0x12) { |
211 |
obj = new DwgCircle(index);
|
212 |
obj.setGraphicsFlag(true);
|
213 |
} else if (type == 0x13) { |
214 |
obj = new DwgLine(index);
|
215 |
obj.setGraphicsFlag(true);
|
216 |
} else if (type == 0x1B) { |
217 |
obj = new DwgPoint(index);
|
218 |
obj.setGraphicsFlag(true);
|
219 |
} else if (type == 0x0F) { |
220 |
obj = new DwgPolyline2D(index);
|
221 |
obj.setGraphicsFlag(true);
|
222 |
} else if (type == 0x10) { |
223 |
obj = new DwgPolyline3D(index);
|
224 |
obj.setGraphicsFlag(true);
|
225 |
} else if (type == 0x0A) { |
226 |
obj = new DwgVertex2D(index);
|
227 |
obj.setGraphicsFlag(true);
|
228 |
} else if (type == 0x0B) { |
229 |
obj = new DwgVertex3D(index);
|
230 |
obj.setGraphicsFlag(true);
|
231 |
} else if (type == 0x6) { |
232 |
obj = new DwgSeqend(index);
|
233 |
obj.setGraphicsFlag(true);
|
234 |
} else if (type == 0x1) { |
235 |
obj = new DwgText(index);
|
236 |
obj.setGraphicsFlag(true);
|
237 |
} else if (type == 0x2) { |
238 |
obj = new DwgAttrib(index);
|
239 |
obj.setGraphicsFlag(true);
|
240 |
} else if (type == 0x3) { |
241 |
obj = new DwgAttdef(index);
|
242 |
obj.setGraphicsFlag(true);
|
243 |
} else if (type == 0x4) { |
244 |
obj = new DwgBlock(index);
|
245 |
obj.setGraphicsFlag(true);
|
246 |
} else if (type == 0x5) { |
247 |
obj = new DwgEndblk(index);
|
248 |
obj.setGraphicsFlag(true);
|
249 |
} else if (type == 0x2A) { |
250 |
obj = new DwgDictionary(index);
|
251 |
// System.out.println("DwgObjectFactory.create: CREANDO UN DICTIONARY");
|
252 |
obj.setGraphicsFlag(false);
|
253 |
} else if (type == 0x30) { |
254 |
obj = new DwgBlockControl(index);
|
255 |
obj.setGraphicsFlag(false);
|
256 |
} else if (type == 0x31) { |
257 |
obj = new DwgBlockHeader(index);
|
258 |
obj.setGraphicsFlag(false);
|
259 |
} else if (type == 0x32) { |
260 |
obj = new DwgLayerControl(index);
|
261 |
obj.setGraphicsFlag(false);
|
262 |
} else if (type == 0x33) { |
263 |
obj = new DwgLayer(index);
|
264 |
obj.setGraphicsFlag(false);
|
265 |
} else if (type == 0x7) { |
266 |
obj = new DwgInsert(index);
|
267 |
obj.setGraphicsFlag(true);
|
268 |
} else if (type == 0x2C) { |
269 |
obj = new DwgMText(index);
|
270 |
obj.setGraphicsFlag(true);
|
271 |
} else if (type == 0x1F) { |
272 |
obj = new DwgSolid(index);
|
273 |
obj.setGraphicsFlag(true);
|
274 |
} else if (type == 0x23) { |
275 |
obj = new DwgEllipse(index);
|
276 |
obj.setGraphicsFlag(true);
|
277 |
} else if (type == 0x24) { |
278 |
obj = new DwgSpline(index);
|
279 |
obj.setGraphicsFlag(true);
|
280 |
} else if (type == 0x15) { |
281 |
obj = new DwgLinearDimension(index);
|
282 |
obj.setGraphicsFlag(true);
|
283 |
} else if (type == 0x4D) { |
284 |
obj = new DwgLwPolyline(index);
|
285 |
obj.setGraphicsFlag(true);
|
286 |
} else if (type == 0x4E) { |
287 |
obj = new DwgLwPolyline(index);
|
288 |
obj.setGraphicsFlag(true);
|
289 |
} else if (type == 0x4F) { |
290 |
obj = new DwgLwPolyline(index);
|
291 |
obj.setGraphicsFlag(true);
|
292 |
} else if (type == 0x50) { |
293 |
obj = new DwgLwPolyline(index);
|
294 |
obj.setGraphicsFlag(true);
|
295 |
} else if (type == 0x51) { |
296 |
obj = new DwgLwPolyline(index);
|
297 |
obj.setGraphicsFlag(true);
|
298 |
} else if (type == 0x52) { |
299 |
obj = new DwgLwPolyline(index);
|
300 |
obj.setGraphicsFlag(true);
|
301 |
} else if (type == 0x53) { |
302 |
obj = new DwgLwPolyline(index);
|
303 |
obj.setGraphicsFlag(true);
|
304 |
} else {
|
305 |
// System.out.println("Type=" + Integer.toHexString(type)
|
306 |
// + " desconocido");
|
307 |
obj = new DwgObject(index);
|
308 |
} |
309 |
obj.setType(type); |
310 |
return obj;
|
311 |
} |
312 |
|
313 |
public DwgObject create(String dxfName, int index){ |
314 |
if(dxfName.equalsIgnoreCase("DICTIONARYVAR")) |
315 |
return new DwgDictionaryVar(index); |
316 |
else if(dxfName.equalsIgnoreCase("HATCH")) |
317 |
return new DwgHatch(index); |
318 |
return null; |
319 |
} |
320 |
/*
|
321 |
'DICTIONARYVAR' : dictionaryvar_reader,
|
322 |
'HATCH' : hatch_reader,
|
323 |
'IDBUFFER' : idbuffer_reader,
|
324 |
'IMAGE' : image_reader,
|
325 |
'IMAGEDEF' : imagedef_reader,
|
326 |
'IMAGEDEFREACTOR' : imagedefreactor_reader,
|
327 |
'LAYER_INDEX' : layer_index_reader,
|
328 |
'LWPLINE' : lwpline_reader,
|
329 |
# 'OLE2FRAME' : ole2frame_reader,
|
330 |
'RASTERVARIABLES' : rastervariables_reader,
|
331 |
'SORTENTSTABLE' : sortentstable_reader,
|
332 |
'SPATIAL_FILTER' : spatial_filter_reader,
|
333 |
'SPATIAL_INDEX' : spatial_index_reader,
|
334 |
'XRECORD' : xrecord_reader
|
335 |
* */
|
336 |
} |