Moving Java Shape Objects above JMapPane or JMapFrame

3 messages Options
Embed this post
Permalink
James Nicolson

Moving Java Shape Objects above JMapPane or JMapFrame

Reply Threaded More More options
Print post
Permalink
Hello all,

Sorry, if this isn't the right place to post but I'm new to geotools.
I'm trying to create an application that displays moving 2D graphics
superimposed upon a map of some kind. However, I do not want to
repaint the map everytime I do this (i.e. I want to paint the last
buffered image of the map, when it was initialised or the last pan,
zoom, rotate occured, and then draw my moving 2D graphics upon this).
An example of this might be a car moving across the map (without the
map being redrawn), or simply a red line spinning round and round at
high speed upon a map (not redrawn).

Does the geotools api provide a mechanism to do this, or will I have
to extend JMapPane in order to achieve this effect? I am also aware of
JLayeredPane and the functionality that is provides, but I am not sure
if this is the best of achieving this.

Thanks in advance,
j

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Moving Java Shape Objects above JMapPane or JMapFrame

Reply Threaded More More options
Print post
Permalink
Hello James,

Must be morphic resonance at work: you are the second person to ask
about displaying an animation over a JMapPane in the last few days.

There is a simple demo of such a thing here...
http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org/geotools/demo/swing/AnimatedMapPane.java

As you guessed, the demo extends JMapPane and overrides the
paintComponent method.

I think the code in the main method that reads a shapefile using a
new, simplified syntax requires GeoTools 2.6-SNAPSHOT (development
version), but in a day or two, version GeoTools 2.6-RC1 will be
released and the demo will run with that. Of course, you can also
simply take the gist of the code and adapt it to your own classes.

I wrote the demo in a hurry and I'm sure it could be much improved, so
if you've got any comments, or if it just doesn't make any sense, let
me know.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Moving Java Shape Objects above JMapPane or JMapFrame

Reply Threaded More More options
Print post
Permalink
Hi James,

Thanks for your nice comments.

> Much appreciated. If you are one of the dev admins, is there any
> chance I can get an svn account. Just in case I ever want to return
> the favour =D

Contributions are very welcome ! Submitting a patch via Jira is the
easiest way to contribute fixes and extensions. For JMapPane related
things you can also email them to me if you find that easier.

Granting commit access to someone normally requires that they be
involved in the project for a while first. They also have to go
through some legalese to formally transfer copyright.

Back to your app - if you want to animate shapes over the map you will
need to access the map pane's cached image which is presently a
private field with no getter method. I think I prefer the getter
option. I can't add it right now because the trunk code is frozen for
all but bug fixes pending the forthcoming release, but I'll try to get
round to making a patch for JMapPane and the animation demo.

cheers
Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users