180-legend.patch
src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java (working copy) | ||
---|---|---|
12 | 12 |
import org.exolab.castor.xml.Marshaller; |
13 | 13 |
import org.exolab.castor.xml.ValidationException; |
14 | 14 |
|
15 |
|
|
16 | 15 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
17 | 16 |
import com.iver.cit.gvsig.fmap.core.FShape; |
18 | 17 |
import com.iver.cit.gvsig.fmap.drivers.legend.IFMapLegendDriver; |
... | ... | |
40 | 39 |
String fName = f.getAbsolutePath(); |
41 | 40 |
if (fName!=null) { |
42 | 41 |
fName = fName.toLowerCase(); |
43 |
return fName.endsWith(".gvl");
|
|
42 |
return fName.endsWith("." + FILE_EXTENSION);
|
|
44 | 43 |
} |
45 | 44 |
return false; |
46 | 45 |
} |
... | ... | |
54 | 53 |
return FILE_EXTENSION; |
55 | 54 |
} |
56 | 55 |
|
57 |
public Hashtable read(FLayers layers,FLayer layer, File file) throws LegendDriverException { |
|
56 |
public Hashtable<FLayer, IVectorLegend> read(FLayers layers, |
|
57 |
FLayer layer, File file) throws LegendDriverException { |
|
58 | 58 |
|
59 |
Hashtable table = new Hashtable();
|
|
59 |
Hashtable<FLayer, IVectorLegend> table = new Hashtable<FLayer, IVectorLegend>();
|
|
60 | 60 |
File xmlFile = new File(file.getAbsolutePath()); |
61 | 61 |
FileReader reader = null; |
62 | 62 |
|
... | ... | |
64 | 64 |
reader = new FileReader(xmlFile); |
65 | 65 |
|
66 | 66 |
XmlTag tag = (XmlTag) XmlTag.unmarshal(reader); |
67 |
ILegend myLegend = LegendFactory.createFromXML(new XMLEntity(tag)); |
|
67 |
IVectorLegend myLegend = LegendFactory.createFromXML(new XMLEntity( |
|
68 |
tag)); |
|
68 | 69 |
|
69 | 70 |
if(myLegend != null ) { |
70 | 71 |
//CAPA DE LINEAS |
src/com/iver/cit/gvsig/fmap/drivers/legend/IFMapLegendDriver.java (working copy) | ||
---|---|---|
24 | 24 |
|
25 | 25 |
void write(FLayers layers, FLayer layer, ILegend legend, File file, String version) throws LegendDriverException; |
26 | 26 |
|
27 |
Hashtable<FLayer, ILegend> read(FLayers layers, FLayer layer, File file) throws LegendDriverException; |
|
27 |
Hashtable<FLayer, ? extends ILegend> read(FLayers layers, FLayer layer, |
|
28 |
File file) throws LegendDriverException; |
|
28 | 29 |
} |
src/com/iver/cit/gvsig/addlayer/fileopen/vectorial/VectorialFileOpen.java (working copy) | ||
---|---|---|
22 | 22 |
import java.io.File; |
23 | 23 |
import java.util.ArrayList; |
24 | 24 |
import java.util.Comparator; |
25 |
import java.util.Hashtable; |
|
25 | 26 |
import java.util.Iterator; |
26 | 27 |
import java.util.TreeSet; |
27 | 28 | |
... | ... | |
34 | 35 |
import com.iver.andami.messages.NotificationManager; |
35 | 36 |
import com.iver.cit.gvsig.AddLayer; |
36 | 37 |
import com.iver.cit.gvsig.addlayer.fileopen.AbstractFileOpen; |
38 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
|
37 | 39 |
import com.iver.cit.gvsig.fmap.MapControl; |
38 | 40 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
41 |
import com.iver.cit.gvsig.fmap.drivers.gvl.FMapGVLDriver; |
|
42 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
|
39 | 43 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
44 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
40 | 45 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
46 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
|
41 | 47 |
import com.iver.utiles.XMLEntity; |
42 | 48 |
/** |
43 | 49 |
* Clase que indicar� que ficheros puede tratar al panel de apertura de ficheros |
... | ... | |
138 | 144 |
AddLayer.checkProjection(lyr, mapControl.getViewPort()); |
139 | 145 |
mapControl.getMapContext().getLayers().addLayer(lyr); |
140 | 146 | |
147 |
String path = file.getAbsolutePath(); |
|
148 |
// last index + 1 because FmapGVLDriver.FILE_EXTENSION |
|
149 |
// does not contain the dot |
|
150 |
FMapGVLDriver legendDriver = new FMapGVLDriver(); |
|
151 |
File legendFile = new File(path.substring(0, |
|
152 |
path.lastIndexOf('.') + 1) |
|
153 |
+ legendDriver.getFileExtension()); |
|
154 | ||
155 |
if (legendFile.exists() && lyr instanceof FLyrVect) { |
|
156 |
FLyrVect lyrVect = (FLyrVect) lyr; |
|
157 |
Hashtable<FLayer, IVectorLegend> map = legendDriver.read( |
|
158 |
mapControl |
|
159 |
.getMapContext().getLayers(), lyr, legendFile); |
|
160 |
if (map.containsKey(lyr)) { |
|
161 |
lyrVect.setLegend(map.get(lyr)); |
|
162 |
} |
|
163 |
} |
|
141 | 164 |
return lyr.getFullExtent(); |
142 | 165 |
} |
143 | 166 |
} catch (ReadDriverException e) { |
144 | 167 |
errors.add(e); |
168 |
} catch (LegendDriverException e) { |
|
169 |
errors.add(e); |
|
170 |
} catch (LegendLayerException e) { |
|
171 |
errors.add(e); |
|
145 | 172 |
} |
146 | 173 |
return null; |
147 | 174 |
} |
src/com/iver/cit/gvsig/project/documents/view/legend/gui/LegendManager.java (working copy) | ||
---|---|---|
76 | 76 |
import com.iver.andami.PluginServices; |
77 | 77 |
import com.iver.andami.messages.NotificationManager; |
78 | 78 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
79 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
80 |
import com.iver.cit.gvsig.fmap.core.FShapeM; |
|
81 | 79 |
import com.iver.cit.gvsig.fmap.drivers.gvl.FMapGVLDriver; |
82 | 80 |
import com.iver.cit.gvsig.fmap.drivers.legend.IFMapLegendDriver; |
83 | 81 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
... | ... | |
121 | 119 |
private boolean isTreeListenerDisabled; |
122 | 120 |
private JButton btnSaveLegend; |
123 | 121 |
private JButton btnLoadLegend; |
124 |
private Hashtable<FLayer, ILegend> table = null; |
|
122 |
private Hashtable<FLayer, ? extends ILegend> table = null;
|
|
125 | 123 |
private boolean empty = true; |
126 | 124 |
private JLabel iconLabel; |
127 | 125 | |
... | ... | |
778 | 776 |
} |
779 | 777 |
} |
780 | 778 | |
781 |
private void applyRestOfLegends(Hashtable<FLayer, ILegend> table2,FLayers layers) { |
|
779 |
private void applyRestOfLegends( |
|
780 |
Hashtable<FLayer, ? extends ILegend> table2, FLayers layers) { |
|
782 | 781 | |
783 | 782 |
for(int i = 0; i < layers.getLayersCount(); i++) { |
784 | 783 |
FLayer my_layer= layers.getLayer(i); |