Hi
I'm following the User Manual[1] to display a shapefile over a map. As
you can see I copy & paste the manual's example code but it doesn't work.
It fails with the following error:
--
PanelGeoMap.java:149: setWidth(org.geotools.filter.Expression) in
org.geotools.styling.Stroke cannot be applied to
(org.opengis.filter.expression.Literal)
symbolizer.getStroke().setWidth(filterFactory.literal(1));
PanelGeoMap.java:150: setColor(org.geotools.filter.Expression) in
org.geotools.styling.Stroke cannot be applied to
(org.opengis.filter.expression.Literal)
symbolizer.getStroke().setColor(filterFactory.literal(color));
2 errors
--
I've read the geotools and opengis javadocs[2] and I don't know how I can
fix the problem.
Any help will be appreciated. Thanks in advance.
[1] http://docs.codehaus.org/display/GEOTDOC/09+ShapeLab
[2] http://geoapi.sourceforge.net/snapshot/javadoc/
--- CODE START
public void addLayer(String strURL) {
Style style = createLineStyle(Color.BLUE);
DefaultMapLayer layer = new DefaultMapLayer(new
ShapefileDataStore(getClass().getResource(strURL)).getFeatureSource(),
style);
// Add "layer" to MapContext here
}
private static Style createLineStyle(Color color) {
Style style;
StyleFactory styleFactory = StyleFactoryFinder.createStyleFactory();
FilterFactory filterFactory =
FilterFactoryFinder.createFilterFactory();
LineSymbolizer symbolizer = styleFactory.createLineSymbolizer();
SLD.setLineColour(symbolizer, color);
symbolizer.getStroke().setWidth(filterFactory.literal(1)); // FAIL
symbolizer.getStroke().setColor(filterFactory.literal(color)); //
FAIL
Rule rule = styleFactory.createRule();
rule.setSymbolizers(new Symbolizer[]{symbolizer});
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
fts.setRules(new Rule[]{rule});
style = styleFactory.createStyle();
style.addFeatureTypeStyle(fts);
return style;
}
--- CODE END
--
Diego Fdez. Durán <[EMAIL PROTECTED]> | http://www.goedi.net
GPG : 925C 9A21 7A11 3B13 6E43 50DB F579 D119 90D2 66BB
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users