Jürgen Jacob wrote:
> Jürgen Jacob schrieb:
>   
>> Jody Garnett wrote:
>>  > Jürgen Jacob wrote:
>>  >> Hi list,
>>  >>
>>  >> up to now I have developed applications based on UDIG but now I have
>>  >> to implement a small Swing application and therefore will use
>>  >> GeoTools directly.
>>  >>
>>  > On trunk there are a couple of Swing display widgets that Eclisa can
>>  > tell you about.
>>  >
>>  > The quick answer is:
>>  > 1. Follow this example to get a quick visual (of *any* datastore) -
>>  > basically set up a MapContext and ask the renderer to draw it
>>  > - http://docs.codehaus.org/display/GEOTDOC/09+ShapeLab
>>  >
>>  > 2. Use a memory data store rather than a shapefile - use memory
>>  > datastore to hold your data for the MapContext to draw
>>  > - http://docs.codehaus.org/display/GEOTDOC/10+Memory+DataStore
>>
>> I tried this but I mess the Envelope handling.
>> At first I generate three layer out of three shapefiles. They are added 
>> to the map. Then I want to create four other layers using . All of 
>> geometry type = point and initially without any content/features.
>>
>> The problem is that my featureSource has no Bounds and
>> featureSource.getBounds() returns null. On opening/rendering the map in 
>> my JPanel this leads to a NullPointerException in DefaultMapLayer #405. 
>> There a new Envelope is created using featureSource.getBounds(). Since 
>> this is null it doesn't work. I guess (but it can be completely wrong) 
>> that the Envelope is calculated as bounding box including all features. 
>> But my layer(s) are empty. Is this the reason? How can I manually set 
>> the Bounds to 0,0,0,0?
>>     
>
> If I add some dummy features to the layer before I open / render the map 
> then it works. Does this mean that I should add one feature and remove 
> it? I hope not :)
>   
MemoryDataStore is mostly for doing test cases :-)

But thinking about it - actually *any* DataStore you start with that 
lacks content will lacks bounds (yes some of them may give up and return 
the "whole world" as the extent - consider that failing differently).

The render really wants to know how big your data is so it can show you 
something when you first open; if you have no data (yet) then you are 
stuck, you will need to look at setting the viewport another way ...

Jody


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to