>From watching the sourcecode of JMapPane.java I know now, that mapArea is
null and mouseClicked doesn't check if it's a null-pointer, that's why I get
the NullPointerException. (maybe a check for null should be added here,
other methods do check I saw)

But shouldn't be my map rendered although I don't click in the MapPane?

Salke



Salke wrote:
> 
> Hi Martin,
> 
> thanks for your help. You were absolutly right, the gc.show()-method
> created the frame. But that actually means, that my JMapPane isn't working
> at all. The code now looks like that:
> 
> MapContext mc = new DefaultMapContext();
> StyleBuilder sb = new StyleBuilder(); 
> org.geotools.styling.Style style =
> sb.createStyle(sb.createRasterSymbolizer());
> 
> StreamingRenderer renderer = new StreamingRenderer();
>                       
> HashMap hints = new HashMap(); 
> hints.put("memoryPreloadingEnabled", Boolean.TRUE); 
> renderer.setRendererHints(hints);
> 
> mc.addLayer(gc, style);
> JMapPane mp = new JMapPane(new BorderLayout(), true, renderer, mc);
> mp.setBounds(230, 10, 600, 600);
> mp.setReset(true);
> mp.repaint();
>                       
> this.getContentPane().add(mp);
> 
> Nothing appears on my frame, BUT, if I click on the area where the
> JMapPane SHOULD be, I get a NullPointerException, so obviously I'm still
> missing something. I think it's a problem with the MapContext or the
> Renderer, maybe some additional options need to be set?! 
> 
> Greetings and thanks for your help again, Salke
> 
> 
> Martin Schmitz-5 wrote:
>> 
>> Hello Salke,
>> 
>> I think your "strange" behavior comes from:
>> 
>> gc.show();
>> 
>> This (test method) opens a frame and shows the grid.
>> Comment this line out to avoid this.
>> To show your grid in "your own" JMapPane/MapContext it is additionally
>> necessary to invoke
>> 
>> JMapPane.setReset(true);
>> JMapPane.repaint();
>> 
>> after adding a new layer to the MapContext.
>> 
>> @Geotools-Developers:
>> Maybe it is time to provide the JavaDoc for JMapPane, where also the
>> setReset(.) issue is mentioned. There often are the same questions on
>> this list...
>> 
>> Kind regards
>> 
>> Martin Schmitz
>> 
>> 
>> Salke schrieb:
>>> Hi,
>>> 
>>> I started using geotools today, so I am pretty new to this impressive
>>> library. I am using a JMapPane to display raster data I got from a WMS
>>> (geoserver). The layer is displayed properly, BUT: As soon as I create
>>> the
>>> JMapPane-object, it's opening its own frame displaying the loaded layer
>>> inside. 0o Looking at the documentation I found out that JMapPane is a
>>> subclass of a "normal" JPanel, how can it open it's own frame? :X
>>> 
>>> I want the JMapPane to be displayed inside my mainframe, which is a
>>> normal
>>> JFrame. 
>>> 
>>> Another question: How can I use the controls for Zooming and Panning I
>>> read
>>> about in some posts and parts of the documentation) At the moment, it
>>> looks
>>> like a static image beeing simply displayed. Some source is following,
>>> maybe
>>> it helps to find a way out of the magic frame-creation :)
>>> 
>>>                                     URL myURL = new
>>> URL("http://localhost:8080/geoserver/wms";);
>>>                     WebMapServer wms = new WebMapServer(myURL);
>>>                     GetMapRequest mapRequest = wms.createGetMapRequest();
>>>                     mapRequest.addLayer(currentLayer);
>>>                     mapRequest.setFormat("image/png");
>>>                     mapRequest.setDimensions(600, 600);
>>>                     mapRequest.setBBox(currentLayer.getLatLonBoundingBox());
>>>                     
>>>                     BufferedImage image =
>>> ImageIO.read(wms.issueRequest(mapRequest).getInputStream());
>>>                     GeneralEnvelope envelope = new
>>> GeneralEnvelope(currentLayer.getLatLonBoundingBox());
>>> 
>>>                     GridCoverageFactory factory = new 
>>> GridCoverageFactory(); 
>>>                     GridCoverage2D gc = factory.create("GridCoverage", 
>>> image, envelope);
>>>                     gc.show();
>>>                 
>>>                     MapContext mc = new DefaultMapContext();
>>>                     StyleBuilder sb = new StyleBuilder(); 
>>>                     org.geotools.styling.Style style =
>>> sb.createStyle(sb.createRasterSymbolizer());
>>> 
>>>                     StreamingRenderer renderer = new StreamingRenderer();
>>>                     
>>>                     HashMap hints = new HashMap(); 
>>>                     hints.put("memoryPreloadingEnabled", Boolean.TRUE); 
>>>                     renderer.setRendererHints(hints);
>>> 
>>>                     mc.addLayer(gc, style);
>>>                     JMapPane mp = new JMapPane(null, true, renderer, mc);
>>>                     
>>>                     // this points to this class that is a subclass of 
>>> JFrame
>>>                     // the JMapPane is even "displayed" (own frame) without 
>>> this line 0o
>>>                     this.getContentPane().add(mp);
>> 
>> 
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Strange-JMapPane-behaviour-tf3736310.html#a10602855
Sent from the geotools-gt2-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to