Hi,

I am trying to use the panel map integrated in JOSM (without the menus and the 
toolbars) on another Java Application, where I want to load a couple of osm 
files.

I have found the MapViewer and the MapFrame classes, but when I try to 
integrate them on my JFrame, it crashes. I know that there are some 
preferences loaded on the Main class of JOSM and I am trying to replicate 
whatever the Main loads so I can use the map panel on my project.

So far I have found this:

                Main.platform = new PlatformHookUnixoid();
                Main.platform.preStartupHook();
                Main.pref.init(true);

which I think are necessary to load the map.

After that I try:

                map = new MapView();
                frame.add(map);

and it works, showing me an empty map (black), although it says that the 
projection could not be read from the preferences and prints an exception:

java.lang.ClassNotFoundException: 
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.openstreetmap.josm.Main.preConstructorInit(Main.java:258)
        at my.application.Main$Initializer.run(Main.java:125)
        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)

When I try to load an osm layer from a file:

                Layer layer = new OsmDataLayer(new DataSet(), "prueba", new 
File(""));
                map.addLayer(layer);

It simply crashes, throwing this:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at org.openstreetmap.josm.gui.MapView.setActiveLayer(MapView.java:374)
        at org.openstreetmap.josm.gui.MapView.addLayer(MapView.java:173)
        at .....my classes....
        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)

I am wondering if someone can help me pointing me how can I separate the map 
panel from the rest of the application. If it is possible. I just need a map 
that shows osm files, nothing more.

Thanks for your help :)
-- 
María Arias de Reyna Domínguez
Emergya Consultoría

_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/josm-dev

Reply via email to