Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java
DXFMemoryDriver.java | ||
---|---|---|
54 | 54 |
import java.io.FileOutputStream; |
55 | 55 |
import java.io.IOException; |
56 | 56 |
import java.nio.channels.FileChannel; |
57 |
import java.sql.Types; |
|
58 | 57 |
import java.util.ArrayList; |
59 |
import java.util.Date; |
|
60 | 58 |
import java.util.Properties; |
61 | 59 |
|
62 | 60 |
import org.cresques.cts.IProjection; |
... | ... | |
91 | 89 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
92 | 90 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
93 | 91 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
92 |
import com.iver.cit.gvsig.fmap.drivers.AbstractCadMemoryDriver; |
|
94 | 93 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
95 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
96 | 94 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
97 | 95 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
98 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
|
99 | 96 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
100 | 97 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
101 | 98 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
... | ... | |
111 | 108 |
|
112 | 109 |
/** |
113 | 110 |
* @author jmorell (jose.morell@gmail.com) |
111 |
* @author azabala |
|
114 | 112 |
* @version 29-dic-2004 |
115 | 113 |
*/ |
116 |
public class DXFMemoryDriver extends MemoryDriver implements |
|
114 |
public class DXFMemoryDriver extends AbstractCadMemoryDriver implements
|
|
117 | 115 |
VectorialFileDriver, WithDefaultLegend, ISpatialWriter, IWriteable { |
116 |
|
|
118 | 117 |
private static String tempDirectoryPath = System |
119 | 118 |
.getProperty("java.io.tmpdir"); |
120 | 119 |
|
121 |
/* |
|
122 |
* azabala, bug 666: |
|
123 |
* retoco los ID para que sean static, y a?ado un FieldDescription[] por |
|
124 |
* defecto, ya que todos los ficheros DXF comparten el mismo esquema. |
|
125 |
* TODO Unificar el mecanismo de FieldDescription con el de |
|
126 |
* arrayFields. ArrayList arrayFields es util para el TableModel, pero el |
|
127 |
* problema es que el tipo de dato de todas las columnas es Object.class, mientras |
|
128 |
* que LayerDefinition si que tiene una verdadera descripcion del esquema |
|
129 |
* a emplear |
|
130 |
* |
|
131 |
* arrayFields.add("ID"); |
|
132 |
arrayFields.add("FShape"); |
|
133 |
arrayFields.add("Entity"); |
|
134 |
arrayFields.add("Layer"); |
|
135 |
arrayFields.add("Color"); |
|
136 |
arrayFields.add("Elevation"); |
|
137 |
arrayFields.add("Thickness"); |
|
138 |
arrayFields.add("Text"); |
|
139 |
arrayFields.add("HeightText"); |
|
140 |
arrayFields.add("RotationText"); |
|
141 |
*/ |
|
142 |
private final static int ID_FIELD_ID = 0; |
|
143 | 120 |
|
144 |
private final static int ID_FIELD_FSHAPE = 1; |
|
145 |
|
|
146 |
private final static int ID_FIELD_ENTITY = 2; |
|
147 |
|
|
148 |
private final static int ID_FIELD_LAYER = 3; |
|
149 |
|
|
150 |
private final static int ID_FIELD_COLOR = 4; |
|
151 |
|
|
152 |
private final static int ID_FIELD_ELEVATION = 5; |
|
153 |
|
|
154 |
private final static int ID_FIELD_THICKNESS = 6; |
|
155 |
|
|
156 |
private final static int ID_FIELD_TEXT = 7; |
|
157 |
|
|
158 |
private final static int ID_FIELD_HEIGHTTEXT = 8; |
|
159 |
|
|
160 |
private final static int ID_FIELD_ROTATIONTEXT = 9; |
|
161 |
|
|
162 |
private final static FieldDescription[] fields = new FieldDescription[10]; |
|
163 |
static{ |
|
164 |
FieldDescription fieldDesc = new FieldDescription(); |
|
165 |
fieldDesc.setFieldName("ID"); |
|
166 |
fieldDesc.setFieldType(Types.INTEGER); |
|
167 |
fieldDesc.setFieldLength(20); |
|
168 |
fieldDesc.setFieldDecimalCount(0); |
|
169 |
fields[0] = fieldDesc; |
|
170 |
|
|
171 |
fieldDesc = new FieldDescription(); |
|
172 |
fieldDesc.setFieldName("FShape"); |
|
173 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
174 |
fieldDesc.setFieldLength(254); |
|
175 |
fieldDesc.setFieldDecimalCount(0); |
|
176 |
fields[1] = fieldDesc; |
|
177 |
|
|
178 |
fieldDesc = new FieldDescription(); |
|
179 |
fieldDesc.setFieldName("Entity"); |
|
180 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
181 |
fieldDesc.setFieldLength(254); |
|
182 |
fieldDesc.setFieldDecimalCount(0); |
|
183 |
fields[2] = fieldDesc; |
|
184 |
|
|
185 |
fieldDesc = new FieldDescription(); |
|
186 |
fieldDesc.setFieldName("Layer"); |
|
187 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
188 |
fieldDesc.setFieldLength(254); |
|
189 |
fieldDesc.setFieldDecimalCount(0); |
|
190 |
fields[3] = fieldDesc; |
|
191 |
|
|
192 |
fieldDesc = new FieldDescription(); |
|
193 |
fieldDesc.setFieldName("Color"); |
|
194 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
195 |
fieldDesc.setFieldLength(20); |
|
196 |
fieldDesc.setFieldDecimalCount(5); |
|
197 |
fields[4] = fieldDesc; |
|
198 |
|
|
199 |
fieldDesc = new FieldDescription(); |
|
200 |
fieldDesc.setFieldName("Elevation"); |
|
201 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
202 |
fieldDesc.setFieldLength(20); |
|
203 |
fieldDesc.setFieldDecimalCount(5); |
|
204 |
fields[5] = fieldDesc; |
|
205 |
|
|
206 |
fieldDesc = new FieldDescription(); |
|
207 |
fieldDesc.setFieldName("Thickness"); |
|
208 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
209 |
fieldDesc.setFieldLength(20); |
|
210 |
fieldDesc.setFieldDecimalCount(5); |
|
211 |
fields[6] = fieldDesc; |
|
212 |
|
|
213 |
fieldDesc = new FieldDescription(); |
|
214 |
fieldDesc.setFieldName("Text"); |
|
215 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
216 |
fieldDesc.setFieldLength(254); |
|
217 |
fieldDesc.setFieldDecimalCount(0); |
|
218 |
fields[7] = fieldDesc; |
|
219 |
|
|
220 |
fieldDesc = new FieldDescription(); |
|
221 |
fieldDesc.setFieldName("Height"); |
|
222 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
223 |
fieldDesc.setFieldLength(20); |
|
224 |
fieldDesc.setFieldDecimalCount(5); |
|
225 |
fields[8] = fieldDesc; |
|
226 |
|
|
227 |
fieldDesc = new FieldDescription(); |
|
228 |
fieldDesc.setFieldName("Rotation"); |
|
229 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
230 |
fieldDesc.setFieldLength(20); |
|
231 |
fieldDesc.setFieldDecimalCount(5); |
|
232 |
fields[9] = fieldDesc; |
|
233 |
|
|
234 |
} |
|
235 |
|
|
236 | 121 |
private DxfWriter dxfWriter = new DxfWriter(); |
237 | 122 |
|
238 | 123 |
private File fTemp; |
... | ... | |
748 | 633 |
.createVectorialUniqueValueLegend(getShapeType()); |
749 | 634 |
defaultLegend.setFieldName("Color"); |
750 | 635 |
defaultLegend.setLabelField("Text"); |
751 |
defaultLegend.setDefaultSymbol(new FSymbol(getShapeType())); |
|
752 |
defaultLegend.getDefaultSymbol().setShapeVisible(false); |
|
753 |
defaultLegend.getDefaultSymbol().setFontSizeInPixels(false); |
|
754 |
defaultLegend.getDefaultSymbol().setFont( |
|
755 |
new Font("SansSerif", Font.PLAIN, 9)); |
|
756 |
defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK); |
|
757 |
defaultLegend.getDefaultSymbol().setFontSize(heightText); |
|
758 |
defaultLegend.getDefaultSymbol().setStyle( |
|
759 |
FConstant.SYMBOL_STYLE_DGNSPECIAL); |
|
760 |
defaultLegend.getDefaultSymbol().setSize(3); |
|
761 |
defaultLegend.getDefaultSymbol().setSizeInPixels(true); |
|
636 |
|
|
637 |
FSymbol myDefaultSymbol = new FSymbol(getShapeType()); |
|
638 |
myDefaultSymbol.setShapeVisible(false); |
|
639 |
myDefaultSymbol.setFontSizeInPixels(false); |
|
640 |
myDefaultSymbol.setFont(new Font("SansSerif",Font.PLAIN, 9)); |
|
641 |
myDefaultSymbol.setFontColor(Color.BLACK); |
|
642 |
myDefaultSymbol.setFontSize(heightText); |
|
643 |
myDefaultSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL); |
|
644 |
myDefaultSymbol.setSize(3); |
|
645 |
myDefaultSymbol.setSizeInPixels(true); |
|
646 |
|
|
647 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
|
762 | 648 |
|
763 | 649 |
defaultLegend.setLabelHeightField("HeightText"); |
764 | 650 |
defaultLegend.setLabelRotationField("RotationText"); |
... | ... | |
958 | 844 |
return dxfWriter.canWriteAttribute(sqlType); |
959 | 845 |
} |
960 | 846 |
|
961 |
/** |
|
962 |
* Returns de field type of the specified field index. |
|
963 |
* @return field type of i field |
|
964 |
*/ |
|
965 |
public int getFieldType(int i) throws DriverException { |
|
966 |
//azabala: we overwrite MemoryDriver because type resolution |
|
967 |
//is based in first register value (it could be null) |
|
968 |
if(i >= fields.length) |
|
969 |
throw new DriverException("Excedido el numero de campos del dxf"); |
|
970 |
return fields[i].getFieldType(); |
|
971 |
} |
|
972 |
|
|
973 | 847 |
/* |
974 | 848 |
* (non-Javadoc) |
975 | 849 |
* |
... | ... | |
1010 | 884 |
return dxfWriter.canSaveEdits(); |
1011 | 885 |
} |
1012 | 886 |
|
887 |
public boolean isWriteAll() { |
|
888 |
return true; |
|
889 |
} |
|
890 |
|
|
1013 | 891 |
} |
Also available in: Unified diff