Hi Benoît,

I really struggle with styles for all but the simplest cases.  I
mostly want to set styles programmatically rather than use SLD files -
but often find myself stumped by how to avoid deprecated methods.

For simple, constant line and polygon styles I use methods like these:

   public Style createPolygonStyle(SimpleFeatureType type, Color
fill, Color outline, double width) throws IOException {
       Class<?> binding = type.getGeometryDescriptor().getType().getBinding();
       if (binding.isAssignableFrom(Polygon.class) ||
binding.isAssignableFrom(MultiPolygon.class)) {
           StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
           StyleBuilder sb = new StyleBuilder(factory);
           PolygonSymbolizer sym = sb.createPolygonSymbolizer(fill,
outline, width);
           Style style = sb.createStyle(type.getTypeName(), sym);
           return style;

       } else {
           throw new IllegalStateException("type doesn't have Polygon
geometry");
       }
   }

As an aside: I've only just discovered DynamicPolygonStyle2D and
related classes in org.geotools.renderer.style.  Does anyone use these
?

Michael


2009/2/17 Benoît Thiébault <thieba...@artenum.com>:
> Hi everyone,
>
> I'm using geotools 2.5 and I try to set styles programmatically, from
> examples provided on the geotools tutorials (like here 
> http://docs.codehaus.org/display/GEOTDOC/05+Style
>  or there http://docs.codehaus.org/display/GEOTDOC/09+ShapeLab)
>
> In both cases, a lot of methods seem to be deprecated and "will be
> replaced by live lists in 2.6.x". As Geotools 2.6 is not stable yet,
> what is the best solution to define styles without depending on these
> deprecated methods ?
>
> Any example of code would be greatly appreciated
>
> Benoît
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Geotools-gt2-users mailing list
> Geotools-gt2-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to