Hi, i was wondering whether you could help me with the error in the subject.
The thing is i copied an example from Rafal Rusin's blog at
http://rrusin.blogspot.com.ar/2011/06/visualizing-gis-data-in-javafx-20-beta.htmland
made jus a small change to it. As I'm new to both JavaFX and GeoTools
and I don't know how to set up Maven to use local libraries I started a new
JafaFX application and imported GeoTools library version 9.0-RC1 to the
project. I'm using netbeans under Windows 7 x 64 SP1 and I've installed
ImageIO and JAI as suggested in the quickstart tutorial.
Despite the GeoTools Quickstart example runs just fine the code from Rafal
Rusin throws a large list of warnings wich i'm uncapable of understand or
trace.
This is the code:
[code]
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Point;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.text.Text;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.simple.SimpleFeature;
/**
*
* @author agomez
*/
public class Quickstart extends Application {
Group root = new Group();
Group map1 = new Group();
Group map = new Group();
Group texts = new Group();
Scene scene;
private double dragBaseX, dragBaseY;
private double dragBase2X, dragBase2Y;
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Geotools FX test");
scene = new Scene(root,300,250,Color.LIGHTBLUE);
Color[] colors = new
Color[]{Color.YELLOW,Color.RED,Color.ORANGE,Color.VIOLET,Color.CHOCOLATE,Color.YELLOW,Color.AZURE};
int currentColor=0;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select SHAPE");
fileChooser.setInitialDirectory(new
File(System.getProperty("user.home")));
//fileChooser.getExtensionFilters().clear();
//fileChooser.getExtensionFilters().add(new
FileChooser.ExtensionFilter("SHape", new ArrayList<String>()));
File selectedFile = fileChooser.showOpenDialog(primaryStage);
if(selectedFile == null){
Platform.exit();
}
//iterates over so called "features" from within data files and
retrieves name attribute and shape geometry.
FileDataStore dataStore;
try {
dataStore = FileDataStoreFinder.getDataStore(selectedFile);
SimpleFeatureSource featureSource =
dataStore.getFeatureSource();
FeatureCollection featureCollection =
featureSource.getFeatures();
FeatureIterator<SimpleFeature> featureIterator =
featureCollection.features();
Coordinate[] coordinates;
Geometry polygon;
Point centroid;
Bounds bounds;
// create JavaFX polygons for each feature from iteration.
while(featureIterator.hasNext()){
SimpleFeature feature = featureIterator.next();
String name = (String) feature.getAttribute("NAME");
Object geometry = feature.getDefaultGeometry();
if(geometry instanceof MultiPolygon){
MultiPolygon multiPolygon = (MultiPolygon)geometry;
centroid = multiPolygon.getCentroid();
final Text text = new Text(name);
bounds = text.getBoundsInLocal();
text.getTransforms().add(new
Translate(centroid.getX(),centroid.getY()));
text.getTransforms().add(new Scale(0.1,-0.1));
text.getTransforms().add(new
Translate(-bounds.getWidth()/2,bounds.getHeight()/2));
texts.getChildren().add(text);
for(int geometryI =
0;geometryI<multiPolygon.getNumGeometries();geometryI++){
polygon = multiPolygon.getGeometryN(geometryI);
coordinates = polygon.getCoordinates();
Path path = new Path();
path.setStrokeWidth(0.05);
currentColor = (currentColor+1)%colors.length;
path.setFill(colors[currentColor]);
path.getElements().add(new
MoveTo(coordinates[0].x,coordinates[0].y));
for(int i=1;i<coordinates.length;i++){
path.getElements().add(new
LineTo(coordinates[i].x,coordinates[i].y));
}
path.getElements().add(new
LineTo(coordinates[0].x,coordinates[0].y));
map1.getChildren().add(path);
}
}
}
map.translateXProperty().set(600);
map.translateYProperty().set(300);
map.scaleXProperty().set(3);
map.scaleXProperty().set(-3);
map.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
scene.setCursor(Cursor.MOVE);
dragBaseX = map.translateXProperty().get();
dragBaseY = map.translateXProperty().get();
dragBase2X = t.getSceneX();
dragBase2Y = t.getSceneY();
}
});
map.getChildren().add(map1);
map.getChildren().add(texts);
root.getChildren().add(map);
VBox vBox = new VBox();
final Button plus = new Button("+");
plus.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
zoom(1.4);
}
});
vBox.getChildren().add(plus);
final Button minus = new Button("-");
minus.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
zoom(1./1.4);
}
});
vBox.getChildren().add(minus);
root.getChildren().add(vBox);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException ex) {
Logger.getLogger(Quickstart.class.getName()).log(Level.SEVERE,
null, ex);
}
}
private void zoom(double d){
map.scaleXProperty().set(map.scaleXProperty().get() * d);
map.scaleYProperty().set(map.scaleYProperty().get() * d);
}
/**
* The main() method is ignored in correctly deployed JavaFX
application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
[/code]
And these are some of the warnings it's throwing. All warnings have the
same semantics and change only the quoted category.
mar 14, 2013 9:47:59 PM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "FileDataStoreFactorySpi". Cause
is "ServiceConfigurationError: org.geotools.data.FileDataStoreFactorySpi:
Provider org.geotools.data.shapefile.ShapefileDataStoreFactory not a
subtype".
java.util.ServiceConfigurationError:
org.geotools.data.FileDataStoreFactorySpi: Provider
org.geotools.data.shapefile.ShapefileDataStoreFactory not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:231)
at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:826)
at
org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:772)
at
org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:805)
at
org.geotools.factory.FactoryRegistry.getServiceProviders(FactoryRegistry.java:196)
at
org.geotools.factory.CommonFactoryFinder.getFileDataStoreFactories(CommonFactoryFinder.java:202)
at
org.geotools.data.FileDataStoreFinder.getAvailableDataStores(FileDataStoreFinder.java:166)
at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:86)
at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:69)
at training.geotools.fx.Quickstart.start(Quickstart.java:79)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
mar 14, 2013 9:47:59 PM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "FilterFactory". Cause is
"ServiceConfigurationError: org.opengis.filter.FilterFactory: Provider
org.geotools.filter.FilterFactoryImpl not a subtype".
java.util.ServiceConfigurationError: org.opengis.filter.FilterFactory:
Provider org.geotools.filter.FilterFactoryImpl not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:231)
at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:826)
at
org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:772)
at
org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:805)
at
org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:230)
at
org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:430)
at
org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:365)
at
org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:145)
at
org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:346)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:300)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory2(CommonFactoryFinder.java:390)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory2(CommonFactoryFinder.java:404)
at org.geotools.data.DataUtilities.<clinit>(DataUtilities.java:200)
at
org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:406)
at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:95)
at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:69)
at training.geotools.fx.Quickstart.start(Quickstart.java:79)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
mar 14, 2013 9:47:59 PM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "CRSFactory". Cause is
"ServiceConfigurationError: org.opengis.referencing.crs.CRSFactory:
Provider org.geotools.referencing.factory.ReferencingObjectFactory not a
subtype".
java.util.ServiceConfigurationError:
org.opengis.referencing.crs.CRSFactory: Provider
org.geotools.referencing.factory.ReferencingObjectFactory not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:231)
at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:826)
at
org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:772)
at
org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:805)
at
org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:230)
at
org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:430)
at
org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:365)
at
org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:145)
at
org.geotools.referencing.ReferencingFactoryFinder.getFactory(ReferencingFactoryFinder.java:197)
at
org.geotools.referencing.ReferencingFactoryFinder.getCRSFactory(ReferencingFactoryFinder.java:288)
at
org.geotools.data.shapefile.prj.PrjFileReader.<init>(PrjFileReader.java:79)
at
org.geotools.data.shapefile.ShapefileDataStore.openPrjReader(ShapefileDataStore.java:678)
at
org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:832)
at
org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:784)
at
org.geotools.data.AbstractFileDataStore.getFeatureSource(AbstractFileDataStore.java:77)
at training.geotools.fx.Quickstart.start(Quickstart.java:80)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
mar 14, 2013 9:47:59 PM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "DatumFactory". Cause is
"ServiceConfigurationError: org.opengis.referencing.datum.DatumFactory:
Provider org.geotools.referencing.factory.ReferencingObjectFactory not a
subtype".
java.util.ServiceConfigurationError:
org.opengis.referencing.datum.DatumFactory: Provider
org.geotools.referencing.factory.ReferencingObjectFactory not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:231)
at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:826)
at
org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:772)
at
org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:805)
at
org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:230)
at
org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:430)
at
org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:365)
at
org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:145)
at
org.geotools.referencing.ReferencingFactoryFinder.getFactory(ReferencingFactoryFinder.java:197)
at
org.geotools.referencing.ReferencingFactoryFinder.getDatumFactory(ReferencingFactoryFinder.java:236)
at
org.geotools.referencing.factory.ReferencingObjectFactory.createFromWKT(ReferencingObjectFactory.java:1086)
at
org.geotools.data.shapefile.prj.PrjFileReader.<init>(PrjFileReader.java:79)
at
org.geotools.data.shapefile.ShapefileDataStore.openPrjReader(ShapefileDataStore.java:678)
at
org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:832)
at
org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:784)
at
org.geotools.data.AbstractFileDataStore.getFeatureSource(AbstractFileDataStore.java:77)
at training.geotools.fx.Quickstart.start(Quickstart.java:80)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
I hope you can enlight me on this matter or at least pont me in any
direcction to read rurther as I tried googling it and couldn't find a
suitable answer
Best Regards
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users