Hi, I used the example StyleFunctionLab to create different classes
for my shapefile, but now I wanna know how I can make a legend with
the colors created, for example, added one Shapefile with the states
of Brazil and drew each state of a color, right now I need something
saying that Sao Paulo is blue, Rio is green.How can I do this?
From: Development <martin.heidecker@gm...> - 2010-01-19 22:17:36
i am absolute not an expert of th geotools! But maybe i can help you but
to do so it would be nice if you atach your code !
I would suggest ( i assume you don`t store the ocolors of the states as
attribute in the shapfile!) you create an array or a list and store both
informations in it the name of the feature and the color you use!
Having that list it should be easy to display it in a panel!
Hope i helped you out!
From: Michael Bedward <michael.bedward@gm...> - 2010-01-21 05:30:19
As Martin suggests you can hack a custom solution to draw the legend
onto a map panel or a separate panel.
There is a SLD element "LegendGraphic" used with Rules in SLD docs.
Programmatically the Rule class has getLegend and setLegend methods.
But the renderer doesn't seem to do anything with these as far as I
can see. Perhaps Andrea or Jody can cast more light on that ?
There is also the org.geotools.legend package in the gt-render module
but the classes there are poorly documented and I don't know anything
about it. A brief look finds lots of bits that seem to duplicate
methods in other parts of GeoTools. Once again, one of the gurus here
might be able to cast more light on this.