Niranjan k ha scritto:
> Hi,
>
> I am working on a project using GT2.2.1. I am totally new to this
> environment, so please excuse my naive doubts!
> How do i display the polygon name along with each polygon when it gets
> displayed? I created two rules for that feature style, one
> PolygonSymbolizer, and one TextSymbolizer, and also added both to the
> same feature style. But even then, only the polygons get displayed, and
> not the names.
>
> Here is the code I used:
>
> StyleBuilder sb = new StyleBuilder();
> StyleFactory sf = StyleFactoryFinder.createStyleFactory();
>
> PolygonSymbolizer ps = sf.createPolygonSymbolizer ();
> Fill fill1 = sf.createFill(ff.createLiteralExpression("#00FF00"));
> Stroke stroke = sf.createStroke(
> ff.createLiteralExpression("#FF0000"),
> ff.createLiteralExpression(2));
> ps.setFill(fill1);
> ps.setStroke(stroke);
>
> org.geotools.styling.Font font = sb.createFont(new Font("Serif",
> Font.PLAIN, 8));
> org.geotools.styling.Font font1[] = new
> org.geotools.styling.Font[1];
> font1[0]= font;
> Fill fill2 = sf.createFill(ff.createLiteralExpression("#000000"));
> TextSymbolizer ts = sf.createTextSymbolizer ();
> ts.setFill(fill2);
> ts.setLabel(ff.createLiteralExpression(attrs[1].getName()));
Nope, the label should use an attribute expression. Literal expressions
are for constant strings, not for attributes.
Besides that, the renderer may not label all your polygons in order to
avoid label conflicts, should label be to big and overlap with each other.
Cheers
Andrea
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users