[Gvsig_english] How to import a legend file by a python script
Jose Manuel Vivó (Chema)
josemanuel.vivo at iver.es
Mon Mar 26 16:27:22 CEST 2007
Hi Antonio:
The method 'VectorialUniqueValueLegend' recive an instance of
'XMLEntity' (com.iver.utiles.XMLEntity) and not a string.
Normally this kind of errors prints a trace in the java console.
You can try to load a legend from a file using this function:
def loadLeyendFromFile(pathToFile):
# imports
from java.io import InputStreamReader, FileInputStream, File
from com.iver.utiles.xmlEntity.generate import XmlTag
LegendFactory =
gvSIG.classForName("com.iver.cit.gvsig.fmap.rendering.LegendFactory")
# code
reader = InputStreamReader( FileInputStream(File(pathToFile)),"UTF-8")
xml = XmlTag.unmarshal(reader)
return LegendFactory.createFromXML(xml)
Good Luck
Chema.
El Sábado 24 Marzo 2007 13:17, Antonio Falciano escribió:
> Hi list,
> I'm trying to import a legend file and then assign to a vectorial layer by
> a python script:
>
> [cut]
>
> # Add theme to the mapContext layer list of the view
> mapContext.getLayers().addLayer(myLayer)
>
> # Set theme legend file
>
> myLegendFileName=os.path.join(gvSIG.getScriptsDirectory(),"..","..","myExte
>nsion","myLegendFile.gvl")
> myLegend=gvSIG.classForName("com.iver.cit.gvsig.fmap.rendering.VectorialUni
>queValueLegend") myLegend.setXMLEntity(myLegendFileName)
> myLayer.setLegend(myLegend)
> #myLayer.setXMLEntity(myLegendFileName)
>
> # Refresh the mapContext
> mapContext.invalidate()
>
> ...but I obtain only my layer with a default single symbol legend. Where
> am I wrong? I'm using gvSIG 1.0.1 with both JCRS and Piloto Raster
> extensions not active.
>
> Best regards,
> Antonio Falciano
> freelancer engineer
> intern at Regional Rivers Authority of Basilicata, Italy
--
=============
Jose Manuel Vivó (Chema)
Equipo de gvSIG
IVER T.I. S.A.
C/ Salamanca, 50-52
46005-Valencia
Tlf.+34963163400
Spain
www.iver.es
www.gvsig.com
More information about the Gvsig_internacional
mailing list