Hi all,

I need to have my own custom labeling, which will place label near each feature using information about clusters of features (known to my application). In order to do it, I use my own function expression:
/*public class MyExpression extends FunctionExpressionImpl {
     private Set lineIDs = new HashSet();

     public MyExpression() {
       super("MyExpression");
     }

     @Override
     public int getArgCount() {
       return 0;
     }

     @Override
     public Object evaluate(Object objFeature) {
       SimpleFeature feature = (SimpleFeature)objFeature;
       Object attr1 = feature.getAttribute("Attr1");
*//*       return *//*"*//*Attr1=*//*"+attr1*//*;
     }
   }*/
Then I create my text symbolizer:

/*MyExpression myExp = new MyExpression();
TextSymbolizer textSym = sf.createTextSymbolizer(
sf.createFill(ff.literal(Color.BLACK)), new Font[]{sf.getDefaultFont()}, null, myExp , placement, null);*/

The problem that I run into is about feature passed to evaluate contains only geometry, no attributes at all (except FeatureId). So, /*feature.getAttribute("Attr1") */will always return null. However, in order to display my clustering information I need certain attributes of each feature.

Is this possible to do?

As a horrible workaround, I pass Map<FeautureId, SimpleFeature> to /*MyExpression*/, and use these attributes. Downsides of this solution are obvious.

Also I have another one question:
Is it possible to override behaviour of the default labeling in order to show only one label per cluster of features? To what properties should I pay my attention?
Are there some examples of creating custom labeling?

Any help would be appreciated....

Thanks in advance,
Sergey

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to