Michael Grain ha scritto:
> Hi,
> 
> Please somebody tell me whats wrong in my code! 
> Instead images in my application displayed gray squares (
> Here is my code:
> 
> 
> public static Style getPointStyle() {
>     StyleBuilder styleBuilder = new StyleBuilder();
>     Style style = styleBuilder.createStyle();
>     {
>         {   
>             PointSymbolizer pointSymbolizer =
> styleBuilder.createPointSymbolizer();
>             {    
>                 Graphic graphic = styleBuilder.createGraphic();

I think this is the problem. The style builder is meant to whip
up a style very quickly, it's not a factory that gives you
back empty objects, if you don't tell it what to do it fill in the
blanks.
In particular this will return a graphic with the default mark
inside, which is a gray square.
Since it can be rendered, the alternative graphics you're adding
after it won't even be considered (as per SLD rules, the first
mark/external that renders is used, usually the setup is
the opposite, first an external graphics that may fail to
be retrieved, then a Mark that will always render as a fallback).


>                 File file     =       new File( "d:/pan.png");
>                 if( !file.exists() )  logger.error("file not found");
>                 ExternalGraphic external =
> styleBuilder.createExternalGraphic( "file:///" + file, "image/png");
>                 graphic.graphicalSymbols().add( external );

Try graphic.graphicalSymbolols().clear and then add your external
graphic.

Cheers
Andrea


-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to