Revision 21356 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java
FMapGVLDriver.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.drivers.gvl;
|
|
1 |
package org.gvsig.fmap.mapcontext.rendering.legend.driver.gvl;
|
|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.FileNotFoundException; |
... | ... | |
10 | 10 |
import org.exolab.castor.xml.MarshalException; |
11 | 11 |
import org.exolab.castor.xml.Marshaller; |
12 | 12 |
import org.exolab.castor.xml.ValidationException; |
13 |
import org.gvsig.data.ReadException; |
|
14 |
import org.gvsig.data.vectorial.FeatureAttributeDescriptor; |
|
15 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
16 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
17 |
import org.gvsig.fmap.mapcontext.layers.XMLException; |
|
18 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
19 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend; |
|
20 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
21 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
22 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
|
23 |
import org.gvsig.fmap.mapcontext.rendering.legend.driver.IFMapLegendDriver; |
|
24 |
import org.gvsig.fmap.mapcontext.rendering.legend.driver.LegendDriverException; |
|
13 | 25 |
|
14 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
15 |
import com.iver.cit.gvsig.fmap.drivers.legend.IFMapLegendDriver; |
|
16 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
|
17 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
18 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
19 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
20 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
21 |
import com.iver.cit.gvsig.fmap.rendering.IClassifiedVectorLegend; |
|
22 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
|
23 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
|
24 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
25 | 26 |
import com.iver.utiles.XMLEntity; |
26 | 27 |
import com.iver.utiles.xmlEntity.generate.XmlTag; |
27 | 28 |
|
... | ... | |
55 | 56 |
Hashtable table = new Hashtable(); |
56 | 57 |
File xmlFile = new File(file.getAbsolutePath()); |
57 | 58 |
FileReader reader = null; |
58 |
|
|
59 |
|
|
59 | 60 |
try { |
60 | 61 |
reader = new FileReader(xmlFile); |
61 | 62 |
|
... | ... | |
64 | 65 |
|
65 | 66 |
if(myLegend != null ) { |
66 | 67 |
//CAPA DE LINEAS |
67 |
if (layer instanceof FLyrVect) {
|
|
68 |
if (layer instanceof FLyrVect) { |
|
68 | 69 |
FLyrVect m = (FLyrVect) layer; |
69 | 70 |
IVectorLegend l = (IVectorLegend) myLegend; |
70 | 71 |
int errors = 0; |
71 |
|
|
72 |
|
|
72 | 73 |
// check general conditions for IVectorLegend |
73 | 74 |
try { |
74 | 75 |
|
... | ... | |
79 | 80 |
errors |= LegendDriverException.LAYER_SHAPETYPE_MISMATCH; |
80 | 81 |
} |
81 | 82 |
|
82 |
} catch (ReadDriverException e) {
|
|
83 |
} catch (ReadException e) { |
|
83 | 84 |
errors |= LegendDriverException.READ_DRIVER_EXCEPTION; |
84 | 85 |
} |
85 | 86 |
|
... | ... | |
88 | 89 |
IClassifiedVectorLegend cl = (IClassifiedVectorLegend) myLegend; |
89 | 90 |
|
90 | 91 |
String[] fNames = cl.getClassifyingFieldNames(); |
91 |
int[] fTypes = cl.getClassifyingFieldTypes();
|
|
92 |
String[] fTypes = cl.getClassifyingFieldTypes();
|
|
92 | 93 |
|
93 | 94 |
|
94 | 95 |
try { |
95 | 96 |
for (int i = 0; i < fNames.length; i++) { |
96 |
int fieldIndex = m.getSource().getRecordset().getFieldIndexByName(fNames[i]); |
|
97 |
|
|
98 |
int fieldIndex = m.getFeatureStore().getDefaultFeatureType().getFieldIndex(fNames[i]); |
|
97 | 99 |
if (fieldIndex != -1) { |
98 | 100 |
if(fTypes != null) |
99 |
if(fTypes[i] != m.getSource().getRecordset().getFieldType(fieldIndex)) {
|
|
101 |
if(!fTypes[i].equals(((FeatureAttributeDescriptor)m.getFeatureStore().getDefaultFeatureType().get(fieldIndex)).getDataType())) {
|
|
100 | 102 |
errors |= LegendDriverException.CLASSIFICATION_FIELDS_TYPE_MISMATCH; |
101 | 103 |
} |
102 | 104 |
} else { |
103 | 105 |
errors |= LegendDriverException.CLASSIFICATION_FIELDS_NOT_FOUND; |
104 | 106 |
} |
105 | 107 |
} |
106 |
} catch (ReadDriverException e) {
|
|
108 |
} catch (ReadException e) { |
|
107 | 109 |
errors |= LegendDriverException.READ_DRIVER_EXCEPTION; |
108 |
}
|
|
110 |
} |
|
109 | 111 |
} |
110 | 112 |
if (errors == 0) { |
111 | 113 |
table.put(layer, myLegend); |
... | ... | |
118 | 120 |
} catch (FileNotFoundException e) { |
119 | 121 |
// should be unreachable code |
120 | 122 |
throw new Error ("file_not_found"); |
121 |
} catch (MarshalException e) { |
|
123 |
} catch (org.exolab.castor.xml.MarshalException e) {
|
|
122 | 124 |
throw new Error ("file_corrupt"); |
123 | 125 |
} catch (ValidationException e) { |
124 | 126 |
// should be unreachable code |
... | ... | |
150 | 152 |
} catch (MarshalException e) { |
151 | 153 |
errors |= LegendDriverException.SAVE_LEGEND_ERROR; |
152 | 154 |
} catch (ValidationException e) { |
153 |
errors |= LegendDriverException.SAVE_LEGEND_ERROR;
|
|
155 |
errors |= LegendDriverException.SAVE_LEGEND_ERROR; |
|
154 | 156 |
} catch (IOException e) { |
155 |
errors |= LegendDriverException.SYSTEM_ERROR;
|
|
157 |
errors |= LegendDriverException.SYSTEM_ERROR; |
|
156 | 158 |
} |
157 | 159 |
if (errors != 0) throw new LegendDriverException(errors); |
158 |
|
|
160 |
|
|
159 | 161 |
} |
160 | 162 |
|
161 | 163 |
|
Also available in: Unified diff