Inserting a map in Java Desktop Application
I am doing a Java Desktop application and I wish to implement a map that can be zoom in and zoom out, and also get coordinate of a location. What I need is just a very small area map.
I tried to google and found this link.
http://today.java.net/pub/a/today/20...mapviewer.html
However, my program give me an error state that the image tile is failed to load from the server.
I tried to find other way to implement a map but most of it implement using javascript.
Can anyone tell me how to insert a map in Java desktop application. the application will be used offline after this.Thanks!
Re: Inserting a map in Java Desktop Application
This is my take in this. forgive me if its wrong.
1. Declare Image Icon objects, initialize them to take a image path parameter
2.Declare and initialize Image objects to get the image of the preloaded ImageIcon objects .getImage() ;
3. Add an anonymous key lister or a key lister class and override the methods of the KeyAdapter.
4. with in overrode key methods set the preloaded ImageIcons to be a new ImageIcon and pass in a different image path as the parmameter.
note: Each of the preloaded imageIcons should be a path to an image that is cropped or larger to create the illusion of zooming on key press.
You must call repaint() during each key press to repaint the graphics of the application.
Alterantivley: You could create a method that takes an Image as a parameter and handle the changing image path based on the parameter passed in.
Re: Inserting a map in Java Desktop Application
A problem you may have is that a map is more than just an image, especially if you want to zoom in and out without degrading the quality of what the user sees. In my opinion, this may be better accomplished with use of vector graphics rather than the typical Java raster graphics since the former would scale well. I will add the caveat that I myself have never done this and so cannot say that I've tested any of this. Also if you could search some more and find and use a well crafted ready-made solution, you'll of course be a step ahead of the game.
Also regarding Steven Bishop's advice, he has some useful recommendations, but I would strongly recommend that you avoid using KeyListeners or KeyAdapters with Swing applications. Much better would be to use AbstractActions tied to key bindings as well as button, menu, and even mouse events.
Re: Inserting a map in Java Desktop Application
Quote:
Originally Posted by
curmudgeon
A problem you may have is that a map is more than just an image, especially if you want to zoom in and out without degrading the quality of what the user sees. In my opinion, this may be better accomplished with use of vector graphics rather than the typical Java raster graphics since the former would scale well. I will add the caveat that I myself have never done this and so cannot say that I've tested any of this. Also if you could search some more and find and use a well crafted ready-made solution, you'll of course be a step ahead of the game.
Also regarding Steven Bishop's advice, he has some useful recommendations, but I would strongly recommend that you avoid using KeyListeners or KeyAdapters with Swing applications. Much better would be to use AbstractActions tied to key bindings as well as button, menu, and even mouse events.
yes, You got my point, it is not just an image.I am trying to search a well crafted ready-made solution. I believe there must be some way in doing this. Currently I am trying Geotools. Anyone has experiences in using this? I am still a beginner.
thanks for your reply:)