[geotk] Need some help to work with geotoolkit-pending module

theuns theunsheydenrych at gmail.com
Tue Aug 25 06:05:27 EDT 2009


HI haven't used the postgis code yet, so far just displaying shapefiles.

But if i look at your code, it looks like you add the layer in the code
a bit late.

Try to move the line
context.layers().add( MapBuilder.createFeatureLayer(fs, new
DefaultMutableStyle()));

to right after you created the MapContext, that way you add the postgis
layer before you set the context to the mapwidget.

I dont know if this will be the solution, but worth a try.

 
On Tue, 2009-08-25 at 14:53 +0530, suneesh kumar wrote:
> 
> Thanks a lot for your reply. 
> I could go ahead following your suggestion.
> Initially I just wanted to show a map in JFrame after words I will go
> ahead. Sorry again if I am asking some stupid question.
> 
> I have the following code :
> 
>  JMap2D mapWidget;
>             MapContext context =
> MapBuilder.createContext(DefaultEngineeringCRS.CARTESIAN_2D);
>             setTitle("Test Frame");
>             mapWidget = new JMap2D();
>             mapWidget.getContainer().setContext(context);
> 
> mapWidget.getCanvas().setRenderingHint(GO2Hints.KEY_MULTI_THREAD,
> GO2Hints.MULTI_THREAD_OFF);
> 
> mapWidget.getCanvas().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
> 
> mapWidget.getCanvas().getController().setAutoRepaint(true);
>             add(mapWidget);
> 
>             java.util.Map params = new java.util.HashMap();
> 
>             params.put("host", "localhost");
>             params.put("port", 5432);
>             params.put("database", "bhunaksha_hry");
>             params.put("user", "postgres");
>             params.put("passwd", "postgres");
>             JDBCDataStore ds = new
> PostgisNGDataStoreFactory().createDataStore(params);
> 
>             FeatureSource fs = ds.getFeatureSource("khasramap");
>          
>             context..layers().add( MapBuilder.createFeatureLayer(fs,
> new DefaultMutableStyle()));
> 
> -------------------------------------------
> 
> But I am getting the following exception. I will be very helpful if
> anybody can help me to figure out where I am wrong..
> 
> ---------------------------------------------------------------------------
> Exception in thread "AWT-EventQueue-0"
> java.lang.IllegalArgumentException: Illegal argument: "crs=null".
>         at
> org.geotoolkit.display.primitive.AbstractReferencedGraphic.<init>(AbstractReferencedGraphic.java:92)
>         at
> org.geotoolkit.display.primitive.AbstractReferencedGraphic2D.<init>(AbstractReferencedGraphic2D.java:138)
>         at
> org.geotoolkit.display2d.primitive.AbstractGraphicJ2D.<init>(AbstractGraphicJ2D.java:45)
>         at
> org.geotoolkit.display2d.container.stateless.AbstractLayerJ2D.<init>(AbstractLayerJ2D.java:62)
>         at
> org.geotoolkit.display2d.container.stateless.StatelessFeatureLayerJ2D.<init>(StatelessFeatureLayerJ2D.java:87)
>         at
> org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.parseLayer(StatelessContextJ2D.java:159)
>         at
> org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.access$100(StatelessContextJ2D.java:56)
>         at
> org.geotoolkit.display2d.container.stateless.StatelessContextJ2D
> $1.layerChange(StatelessContextJ2D.java:74)
>         at
> org.geotoolkit.map.DefaultMapContext.fireLayerChange(DefaultMapContext.java:308)
>         at org..geotoolkit.map.DefaultMapContext
> $1.notifyAdd(DefaultMapContext.java:67)
>         at org.geotoolkit.map.DefaultMapContext
> $1.notifyAdd(DefaultMapContext.java:58)
>         at
> org.geotoolkit.util.collection.NotifiedCheckedList.add(NotifiedCheckedList..java:53)
>         at NewJFrame.<init>(NewJFrame.java:67)
>         at NewJFrame$1.run(NewJFrame.java:109)
>         at
> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
>         at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread..java:269)
>         at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
>         at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
>         at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
>         at
> java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
> 
> 
> 
> --- On Mon, 24/8/09, theuns <theunsheydenrych at gmail.com> wrote:
>         
>         From: theuns <theunsheydenrych at gmail.com>
>         Subject: Re: [geotk] Need some help to work with
>         geotoolkit-pending module
>         To: "suneesh kumar" <suni_durg at yahoo.com>
>         Cc: geotoolkit at lists.osgeo.org
>         Date: Monday, 24 August, 2009, 7:52 PM
>         
>         HI Sunish
>         
>         I have used the the widget for a while now.
>         I compile the geotoolit-pending library with mvn install
>         -Dmaven.test.skip
>         
>         After a successful build i use the widget in a JFrame as
>         follows.
>         The code below will not necessary compile because i copied it
>         out
>         quickly from my current project.
>         
>         The the the usage idea is there.
>         Hope it helps. 
>         
>         public class TestFrame extends javax.swing.JFrame {
>         
>             //Map widget stuff
>             private JMap2D mapWidget;
>             private MapContext contextSA =
>         ContextBuilder.buildSouthAfricaContext();
>             
>             public TestFrame() {
>                 setTitle("Test Frame");
>                 
>                 mapWidget = new JMap2D();
>                 mapWidget.getContainer().setContext(contextSA);
>         
>         
>         mapWidget.getCanvas()..setRenderingHint(GO2Hints.KEY_MULTI_THREAD,
>         GO2Hints.MULTI_THREAD_OFF);
>         
>         mapWidget.getCanvas().setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
>         
>         mapWidget.getCanvas().getController().setAutoRepaint(true);
>         
>                 add(mapWidget) ;
>         
>                 ....
>             }
>         
>             /**
>              * @param args the command line arguments
>              */
>             public static void main(String args[]) {
>                 try {
>         
>         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
>                 } catch (ClassNotFoundException ex) {
>         
>         Logger.getLogger(UserOverlayFrame.class.getName()).log(Level.SEVERE,
>         null, ex);
>                 } catch (InstantiationException ex) {
>         
>         Logger.getLogger(UserOverlayFrame.class.getName()).log(Level.SEVERE,
>         null, ex);
>                 } catch (IllegalAccessException ex) {
>         
>         Logger.getLogger(UserOverlayFrame.class..getName()).log(Level.SEVERE,
>         null, ex);
>                 } catch (UnsupportedLookAndFeelException ex) {
>         
>         Logger.getLogger(UserOverlayFrame.class.getName()).log(Level.SEVERE,
>         null, ex);
>                 }
>         
>                 java.awt.EventQueue.invokeLater(new Runnable() {
>         
>                     public void run() {
>                         new TestFrame().setVisible(true);
>                     }
>                 });
>             }
>         }
>         
>         
>         On Mon, 2009-08-24 at 16:06 +0530, suneesh kumar wrote:
>         > Hello,
>         > 
>         >  I was trying to add JMap2D to a JFrame. At some point of
>         time I am
>         > getting the following error. It is unable to locate
>         FilterFactory.
>         > Please help me in proceeding further. I compiled the pending
>         module
>         > using command mvn -fn install. 
>         > Will I have to add some other dependency jars?
>         > 
>         > A descriptor is already registered against the name
>         > "org.geotoolkit.SilhouetteMask" under registry mode
>         "rendered"
>         > Error in registry file at line number #33
>         > A descriptor is already registered against the name
>         > "org.geotoolkit.Mask" under registry mode "rendered"
>         > Exception in thread "AWT-EventQueue-0"
>         > java.lang.ExceptionInInitializerError
>         >         at java.lang.Class..forName0(Native Method)
>         >         at java.lang.Class.forName(Class.java:247)
>         >         at sun.misc.Service
>         $LazyIterator.next(Service.java:271)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.register(FactoryRegistry.java:900)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:816)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:866)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:291)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:544)
>         >         at
>         >
>         org.geotoolkit.factory.DynamicFactoryRegistry.getServiceImplementation(DynamicFactoryRegistry.java:326)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.getOrCreateServiceProvider(FactoryRegistry.java:452)
>         >         at
>         >
>         org.geotoolkit.factory.DynamicFactoryRegistry.getOrCreateServiceProvider(DynamicFactoryRegistry.java:167)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:329)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryFinder.getFactory(FactoryFinder.java:236)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryFinder.getStyleFactory(FactoryFinder.java:696)
>         >         at
>         >
>         org.geotoolkit.display2d.GO2Utilities.<clinit>(GO2Utilities.java:135)
>         >         at
>         >
>         org.geotoolkit.display2d.container.ContextContainer2D.<clinit>(ContextContainer2D.java:73)
>         >         at
>         org..geotoolkit.gui.swing.go2.JMap2D.<init>(JMap2D.java:57)
>         >         at
>         org.geotoolkit.gui.swing.go2.JMap2D.<init>(JMap2D.java:49)
>         >         at
>         >
>         geotoolkittest.GeotoolkitTestView.<init>(GeotoolkitTestView.java:54)
>         >         at
>         >
>         geotoolkittest.GeotoolkitTestApp.startup(GeotoolkitTestApp.java:19)
>         >         at org.jdesktop.application.Application
>         > $1.run(Application.java:171)
>         >         at
>         >
>         java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>         >         at
>         java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
>         >         at
>         >
>         java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
>         >         at
>         >
>         java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
>         >         at
>         >
>         java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
>         >         at
>         >
>         java.awt.EventDispatchThread.pumpEvents(EventDispatchThread..java:169)
>         >         at
>         >
>         java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
>         >         at
>         >
>         java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>         > Caused by: org.geotoolkit.factory.FactoryNotFoundException:
>         No factory
>         > of kind "FilterFactory" found.
>         >         at
>         >
>         org.geotoolkit.factory.FactoryRegistry.getOrCreateServiceProvider(FactoryRegistry.java:471)
>         >         at
>         >
>         org.geotoolkit.factory.DynamicFactoryRegistry.getOrCreateServiceProvider(DynamicFactoryRegistry.java:167)
>         >         at
>         >
>         org..geotoolkit.factory.FactoryRegistry.getServiceProvider(FactoryRegistry..java:329)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryFinder.getFactory(FactoryFinder.java:236)
>         >         at
>         >
>         org.geotoolkit.factory.FactoryFinder.getFilterFactory(FactoryFinder.java:666)
>         >         at
>         >
>         org.geotoolkit.style.DefaultStyleFactory.<clinit>(DefaultStyleFactory.java:107)
>         >         ... 29 more
>         > 
>         > 
>         > Thanks in advance 
>         > Sunish Kumar
>         > 
>         > 
>         > 
>         >
>         ______________________________________________________________________
>         > See the Web's breaking stories, chosen by people like you.
>         Check out
>         > Yahoo! Buzz.
>         > _______________________________________________
>         > Geotoolkit mailing list
>         > Geotoolkit at lists.osgeo.org
>         > http://lists.osgeo.org/mailman/listinfo/geotoolkit
>         
>         
> 
> 
> ______________________________________________________________________
> Love Cricket? Check out live scores, photos, video highlights and
> more. Click here.



More information about the Geotoolkit mailing list