Hi Rax,
 
Thanks for your help.
 
I will try your method and see if it works. In the meantime, I read about a 
class called: org.geotools.gui.swing.Legend. Is this class not meant to create 
legends automatically? 
 
If it is the case, where could I download it or the package 
org.geotools.gui.swing from?
 
Many thanks Guys!
 
Kakpo
 



Date: Mon, 26 Mar 2012 21:07:49 +0800
From: [email protected]
Subject: Re: : [Geotools-gt2-users] Legend in geotools
To: [email protected]
CC: [email protected]



{Please also send mails to the mailing list too,so everyone can contribute and 
help us.}
 
Ahh. ,
Actually in my case, it was required to change the code of JMapFrame.
So I could not make it pluggable.
But I can give you an idea what it was doing :
- for the color expression, call one function which will create an 
HashMap<Object,Color>
Object : attribute which needs to be coloured
Color : the unique color generated according to value of attribute. .
Now, from the user, the system will ask about new values of Text to display in 
front of color and I created a Resizable and draggable JPanel which shows final 
result as a table with Color - String pairs which is having a transparent 
background.
So, that was my way of representing legend and by making a draggable and 
resizable JPanel, we could make it more user friendly.

Hope I was clear and my way helped you a bit.
Please let me know if I made any silly mistake or chose a longer way.

Thank you,
Rax






Best regards,Rakshit Majithiya
Techno geek, Web Developer,Code Lover
email : [email protected]

blog : http://thetechtime.com
skype : rakshit.majithiya






From: Kakpo Adoko <[email protected]>
To: [email protected] 
Sent: Monday, 26 March 2012 4:06 PM
Subject: RE: : [Geotools-gt2-users] Legend in geotools







Hi Rax,


Nice to hear from you. My approach for showing different colours to features 
was based:


1) Reading features attributes with Expression:


Expression expr = ff.property("attrName");
String  attrName  = expr.evaluate( feature, String.class );


2) And a between rule creation:


Filter filter = ff.between(ff.property(attrName), 
ff.literal(thres[i]),ff.literal(thres[i+1]));
rule.setFilter(filter);


* thres[i] being the integer array containing attribute values defining the 
bandwidths.


How did you develop the legend module? Can it be used as plug-in?


Thanks.


Regards,
Kakpo




> Date: Mon, 26 Mar 2012 18:07:52 +0800
> From: [email protected]
> Subject: Re:: [Geotools-gt2-users] Legend in geotools
> To: [email protected]
> 
> 
> hello !!
> I've developed legend module using geotools.
> For this purpose, basically I've used colour function.
> Can you let me know about your approach to show different colors according to 
> features ??
> 
> Thanks,
> Rax
> ------------------------------
> On Mon 26 Mar, 2012 3:05 PM IST Kakpo Adoko wrote:
> 
> >
> >Hi All,
> >I am trying to develop a small shapefile application with Geotools (version 
> >2.7.1). Currently, I am able to show the map colour-coded by polygon 
> >attributes (eg. population density, etc). 
> >How can I display the map's legend annotated by colour band?
> >I look forward to hearing from you.
> >Many thanks in advance,
> >Kakpo AdokoPhD researcher,TU DelftThe Netherlands


                                          
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to