Interactive Map viewer desktop application in Java
java, javafx, user-interface
Solution
If really all you have is an image and you want tooltips over it - here is a 30 second description.
- Subclass JPanel
- override paint() method to draw image
- Define some number of Shape objects (polygons, rects, etc...) as your "buildings" along with a text tooltip string
- override getTooltip in JPanel subclass. On each call iterate over your Shape objects, testing if the point is inside shape (shape has a method for this). return tooltip appropriate for Shape, or null if your mouse isn't over shape
- if you want rollover effects, register MouseMotionListener and use it to find the "hover" shape. Call repaint() and render your "hover" in some special way.
- boom! you're done
HINT: You will need to register your JPanel with TooltipManager most likely.
Problem
I want to build a desktop application - a map viewer , something like this : `http://sunsite.ubc.ca/UBCMap/` in Java . Whenever someone hovers the mouse over a building on the map , there should be a balloon tool-tip saying something about that building on the map like its office phone number etc and that building should glow in the 2-d map. Can someone provide me some directions as to what framework should i use in Java to build something like this(e.g JavaFx) ? Is there any sample code which does something similar ?