svn-gvsig-desktop / tags / v1_1_Build_1009 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / AbstractCadMemoryDriver.java @ 12649
History | View | Annotate | Download (5.78 KB)
1 |
/*
|
---|---|
2 |
* Created on 26-oct-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: AbstractCadMemoryDriver.java 12649 2007-07-17 12:20:01Z $
|
47 |
* $Log$
|
48 |
* Revision 1.1.2.2 2007-03-21 19:46:36 azabala
|
49 |
* added region of interest (rois)
|
50 |
*
|
51 |
* Revision 1.1.2.1 2006/11/15 04:11:12 jjdelcerro
|
52 |
* *** empty log message ***
|
53 |
*
|
54 |
* Revision 1.1 2006/10/26 17:05:30 azabala
|
55 |
* *** empty log message ***
|
56 |
*
|
57 |
*
|
58 |
*/
|
59 |
package com.iver.cit.gvsig.fmap.drivers; |
60 |
|
61 |
import java.awt.geom.Rectangle2D; |
62 |
import java.sql.Types; |
63 |
import java.util.ArrayList; |
64 |
import java.util.List; |
65 |
|
66 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
67 |
|
68 |
/**
|
69 |
* Abstract base class for CAD drivers (dxf, dwg) memory drivers.
|
70 |
*
|
71 |
* Features readed with these drivers share the same schema
|
72 |
* (static FieldDescription[])
|
73 |
*
|
74 |
*
|
75 |
* */
|
76 |
public abstract class AbstractCadMemoryDriver extends MemoryDriver { |
77 |
|
78 |
protected final static int ID_FIELD_ID = 0; |
79 |
|
80 |
protected final static int ID_FIELD_FSHAPE = 1; |
81 |
|
82 |
protected final static int ID_FIELD_ENTITY = 2; |
83 |
|
84 |
protected final static int ID_FIELD_LAYER = 3; |
85 |
|
86 |
protected final static int ID_FIELD_COLOR = 4; |
87 |
|
88 |
protected final static int ID_FIELD_ELEVATION = 5; |
89 |
|
90 |
protected final static int ID_FIELD_THICKNESS = 6; |
91 |
|
92 |
protected final static int ID_FIELD_TEXT = 7; |
93 |
|
94 |
protected final static int ID_FIELD_HEIGHTTEXT = 8; |
95 |
|
96 |
protected final static int ID_FIELD_ROTATIONTEXT = 9; |
97 |
|
98 |
protected final static FieldDescription[] fields = new FieldDescription[10]; |
99 |
static{
|
100 |
FieldDescription fieldDesc = new FieldDescription();
|
101 |
fieldDesc.setFieldName("ID");
|
102 |
fieldDesc.setFieldType(Types.INTEGER);
|
103 |
fieldDesc.setFieldLength(20);
|
104 |
fieldDesc.setFieldDecimalCount(0);
|
105 |
fields[0] = fieldDesc;
|
106 |
|
107 |
fieldDesc = new FieldDescription();
|
108 |
fieldDesc.setFieldName("FShape");
|
109 |
fieldDesc.setFieldType(Types.VARCHAR);
|
110 |
fieldDesc.setFieldLength(254);
|
111 |
fieldDesc.setFieldDecimalCount(0);
|
112 |
fields[1] = fieldDesc;
|
113 |
|
114 |
fieldDesc = new FieldDescription();
|
115 |
fieldDesc.setFieldName("Entity");
|
116 |
fieldDesc.setFieldType(Types.VARCHAR);
|
117 |
fieldDesc.setFieldLength(254);
|
118 |
fieldDesc.setFieldDecimalCount(0);
|
119 |
fields[2] = fieldDesc;
|
120 |
|
121 |
fieldDesc = new FieldDescription();
|
122 |
fieldDesc.setFieldName("Layer");
|
123 |
fieldDesc.setFieldType(Types.VARCHAR);
|
124 |
fieldDesc.setFieldLength(254);
|
125 |
fieldDesc.setFieldDecimalCount(0);
|
126 |
fields[3] = fieldDesc;
|
127 |
|
128 |
fieldDesc = new FieldDescription();
|
129 |
fieldDesc.setFieldName("Color");
|
130 |
fieldDesc.setFieldType(Types.DOUBLE);
|
131 |
fieldDesc.setFieldLength(20);
|
132 |
fieldDesc.setFieldDecimalCount(5);
|
133 |
fields[4] = fieldDesc;
|
134 |
|
135 |
fieldDesc = new FieldDescription();
|
136 |
fieldDesc.setFieldName("Elevation");
|
137 |
fieldDesc.setFieldType(Types.DOUBLE);
|
138 |
fieldDesc.setFieldLength(20);
|
139 |
fieldDesc.setFieldDecimalCount(5);
|
140 |
fields[5] = fieldDesc;
|
141 |
|
142 |
fieldDesc = new FieldDescription();
|
143 |
fieldDesc.setFieldName("Thickness");
|
144 |
fieldDesc.setFieldType(Types.DOUBLE);
|
145 |
fieldDesc.setFieldLength(20);
|
146 |
fieldDesc.setFieldDecimalCount(5);
|
147 |
fields[6] = fieldDesc;
|
148 |
|
149 |
fieldDesc = new FieldDescription();
|
150 |
fieldDesc.setFieldName("Text");
|
151 |
fieldDesc.setFieldType(Types.VARCHAR);
|
152 |
fieldDesc.setFieldLength(254);
|
153 |
fieldDesc.setFieldDecimalCount(0);
|
154 |
fields[7] = fieldDesc;
|
155 |
|
156 |
fieldDesc = new FieldDescription();
|
157 |
fieldDesc.setFieldName("Height");
|
158 |
fieldDesc.setFieldType(Types.DOUBLE);
|
159 |
fieldDesc.setFieldLength(20);
|
160 |
fieldDesc.setFieldDecimalCount(5);
|
161 |
fields[8] = fieldDesc;
|
162 |
|
163 |
fieldDesc = new FieldDescription();
|
164 |
fieldDesc.setFieldName("Rotation");
|
165 |
fieldDesc.setFieldType(Types.DOUBLE);
|
166 |
fieldDesc.setFieldLength(20);
|
167 |
fieldDesc.setFieldDecimalCount(5);
|
168 |
fields[9] = fieldDesc;
|
169 |
|
170 |
} |
171 |
|
172 |
protected List rois = new ArrayList(); |
173 |
|
174 |
/**
|
175 |
* Returns de field type of the specified field index.
|
176 |
* @return field type of i field
|
177 |
*/
|
178 |
public int getFieldType(int i) throws DriverException { |
179 |
//azabala: we overwrite MemoryDriver because type resolution
|
180 |
//is based in first register value (it could be null)
|
181 |
if(i >= fields.length)
|
182 |
throw new DriverException("Excedido el numero de campos del dxf"); |
183 |
return fields[i].getFieldType();
|
184 |
} |
185 |
|
186 |
|
187 |
|
188 |
|
189 |
/**
|
190 |
* As CAD files are designed primary to printing task,
|
191 |
* in a cad file (dwg, dgn, dxf, etc.) could exist real
|
192 |
* world entities (thinked to work in a GIS system) in real
|
193 |
* world coordinates (UTM, Lambert, etc.) and paper entities,
|
194 |
* like transversal profiles, electrical circuits, etc. thinked
|
195 |
* to do a final print.
|
196 |
* This region of interest allow to filter cad entities by a
|
197 |
* zone.
|
198 |
* */
|
199 |
public void addRegionOfInterest(Rectangle2D roi){ |
200 |
rois.add(roi); |
201 |
} |
202 |
public Rectangle2D getRegionOfInterest(int index){ |
203 |
return (Rectangle2D) rois.get(index); |
204 |
} |
205 |
public List getRois(){ |
206 |
return rois;
|
207 |
} |
208 |
public void setRois(List rois){ |
209 |
this.rois = rois;
|
210 |
} |
211 |
|
212 |
public int getNumOfRois(){ |
213 |
return rois.size();
|
214 |
} |
215 |
} |
216 |
|