Hello,
I am reading in a shapefile, and displaying it as a layer in Worldwind
(using Geowind libraries, which make use of Geotools 2.6.x).
The individual shapes (features) in the shapefile are SimpleFeature
polygon objects, and I can easily access them as a
FeatureCollection<SimpleFeatureType, SimpleFeature>. This works just
fine.
I know how to set the fill color on the entire FeatureCollection by
utilizing rules and symbolizers.
For example:
--------
Style style = null;
StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer();
Fill fill = styleFactory.createFill(
filterFactory.literal(Color.ORANGE),
filterFactory.literal(1.0));
symbolizer.setFill(fill);
Rule rule = styleFactory.createRule();
rule.setSymbolizers(new Symbolizer[]{symbolizer});
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
fts.setRules(new Rule[]{rule});
style = styleFactory.createStyle();
style.addFeatureTypeStyle(fts);
--------
What I would like to do is find an easy and supported way of filling
individual shapes in the shapefile with a different fill color. The
Shapelab example on the Geotools page does show how to do this for
individual selected features, but this example uses deprecated methods and
it also only really works for one selected shape, though it could be
adapted to work for setting individual shapes (in a rather inefficient
manner).
I don't see an easy or efficient way to do this. To make matters worse,
my code snippet above uses a lot of deprecated methods, such as
setFill(.), setSymbolizers(.), setRules(.) and addFeatureTypeStyle(.).
Is there an easy way to do what I am trying to accomplish? The ideal end
state would be the ability to initialize (programmatically) each
SimpleFeature within a shapefile with a different fill color, then be able
to dynamically change those individual fill colors as needed.
Thanks,
John W. Graham
Raytheon Company
12001 Research Parkway
Suite 400
Orlando, Florida
32826 USA
321-281-1803 direct
[email protected]
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users