Hi IceDice,

I'm taking this discussion back on to the list as it might be useful for others.

The good news is that I got your shapefile to display in JMapFrame
after making a few changes to your code.

The bad news is that I think there are problems with your SLD because
I can't get it to display either with JMapFrame or using uDig.

I'm still not certain why you were seeing the "method not found error"
for MapLayer.setSelected but I think it was probably a spurious
message caused by other problems.  The main problem was the use of the
deprecated DefaultMapContext constructor (it should really be removed
from GeoTools).  The map context needs a CRS to work properly
otherwise when it tries to retrieve bounds it will throw an exception.
 You'll see I've modified your code to load the CRS from the shapefile
and, if there isn't one, to use a default CRS.

I created a simple SLD file to prove that JMapFrame can display your
features :-)  I cheated and used uDig to generate this SLD. The app
loads the SLD file (simple.sld) from the resources folder. If you want
to work with SLD files rather than creating styles programmatically,
it's a lot easier to do it like this rather than have to edit them
into Java Strings.  Hopefully you can use simple.sld as a starting
point to get your desired style working.

I also added use of the new JFileDataStoreChooser to your app to
prompt for the shapefile.

I'll email the modified project to you directly after this. It's set
up as a maven project but you should be able to drop the source file
and the resources folder into your java project directly. Below is a
list of the jars that maven says the app requires.

Please let me know how you go.

Michael

[INFO] [dependency:tree]
[INFO] org.geotools.test:example:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.4:test
[INFO] +- org.geotools:gt-main:jar:2.6-SNAPSHOT:compile
[INFO] |  +- org.geotools:gt-api:jar:2.6-SNAPSHOT:compile
[INFO] |  +- com.vividsolutions:jts:jar:1.10:compile
[INFO] |  +- jdom:jdom:jar:1.0:compile
[INFO] |  \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] |     \- commons-logging:commons-logging:jar:1.0.3:compile
[INFO] +- org.geotools:gt-render:jar:2.6-SNAPSHOT:compile
[INFO] |  +- org.geotools:gt-coverage:jar:2.6-SNAPSHOT:compile
[INFO] |  +- org.geotools:gt-cql:jar:2.6-SNAPSHOT:compile
[INFO] |  \- org.apache.xmlgraphics:batik-transcoder:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:fop:jar:0.94:compile
[INFO] |     |  +- org.apache.xmlgraphics:xmlgraphics-commons:jar:1.2:compile
[INFO] |     |  \- commons-io:commons-io:jar:1.1:compile
[INFO] |     +- org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-parser:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-script:jar:1.7:compile
[INFO] |     |  \- xalan:xalan:jar:2.6.0:compile
[INFO] |     +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-svggen:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO] |     +- org.apache.xmlgraphics:batik-xml:jar:1.7:compile
[INFO] |     +- xml-apis:xml-apis:jar:1.3.04:compile
[INFO] |     \- xml-apis:xml-apis-ext:jar:1.3.04:compile
[INFO] +- org.geotools:gt-referencing:jar:2.6-SNAPSHOT:compile
[INFO] |  +- java3d:vecmath:jar:1.3.2:compile
[INFO] |  +- commons-pool:commons-pool:jar:1.3:compile
[INFO] |  \- org.geotools:gt-metadata:jar:2.6-SNAPSHOT:compile
[INFO] |     +- org.opengis:geoapi:jar:2.3-M1:compile
[INFO] |     +- org.opengis:geoapi-pending:jar:2.3-M1:compile
[INFO] |     \- net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2:compile
[INFO] +- org.geotools:gt-epsg-hsql:jar:2.6-SNAPSHOT:compile
[INFO] |  \- hsqldb:hsqldb:jar:1.8.0.7:compile
[INFO] +- org.geotools:gt-shapefile:jar:2.6-SNAPSHOT:compile
[INFO] \- org.geotools:gt-swing:jar:2.6-SNAPSHOT:compile
[INFO]    \- com.miglayout:miglayout:jar:swing:3.7:compile

------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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/devconf
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to