Lasse Riis wrote:

I'm about to write a GUI app that displays maps of a building, and draws a point, or circle that indicates a position. (The coordinates for this or these positions will be fetched from a network socket btw.)

Can you provide any details on the building maps. Like approx size (10's of K, 100'2 of K, Megabytes)?.

INTRO, (can be skipped)___________
To allow proper zooming of the map, the choice fell on SVG, and as the only proper toolkit-implementation of SVG (that I know of*) is Batik. So the choice fell on Java and Batik. However, being quite the newcomer to Java, and so also to Awt/Swing and Batik, this toolkit is very complex and hard to really grasp with the very scarce tutorial-material on the Batik-page.

Well, for simple things, things tend to be simple, for complex things it's almost impossible to cover all the bases. The good thing is that unlike most commercial packages you have the source, which is the source of all answers. Also I think you will find this list quite useful.

   Also even just identifying a topic for a tutorial would be helpful.
It's too hard as a developer to see the forest for the trees. ;)

FEATURES________________________
The app will have multiple maps; of multiple buildings, and of the multiple levels in these. Switching between maps should be rather fast, so maybe some sort of layering is required? (i.e. keeping pre-rendered images in memory and just swapping between displays of them as to avoid a time-comsuming render for each map-change)

This is possible, the easiest thing is to have multiple JSVGCanvas Objects one for each 'view'. However I suspect that you will encounter two problems with this. First it will take a lot of memory, second it will take a long time to generate every conceivable view. You might be able to do something like load the overview map, and a map of the 1st level of each building (assuming a smallish number of buildings). Then when the user 'commits' to a building start loading the floors for that building in the background.

   You can preload the SVG which will save a potentially significant
amount of the 'first view' time, and will save the potentially large
offscreen image.

Given a set of coordinates (that I will somehow have to match with that of the SVG-map) a dot or some form of indicator should appear on this map and thus visualize the position you're at. As the coordinates are updated the indicator should appear at (or be moved to) a new position. It's of no importance that this indicator is actually part of the SVG(-map). This is strictly a matter of visualization, so as long as it's on top of the map at the proper coordinates it's fine. So maybe some sort of layering is required here as well (with maybe a non-svg layer)?

The JSVGComponent has the notion of 'overlays' which are objects drawn on top of the SVG image. The SVG image is updated from an offscreen buffer when the overlay moves. This is a very good match for your 'dot' (although unless the maps are very complex the update engine should optimize the moving pretty well). There are methods on the canvas to help with your alignment issue.

(to avoid re-rendering upon each indicator update) Also I might want to display several indicators on the same map, so some sort of text hovering next to the indicator would maybe be a requirement.

You can draw what ever you want in an overlay.

Also I'd like zooming to be an option, specifically using a JSlider, and thus allowing "real-time" zooms (zoom as you slide), and not slide-to-point-then-render.

You might try the shift-rightMouse-drag zoom support in Batik this simply scales the offscreen image as you drag an hence is very interactive even for very complex SVG. If the SVG is simple enough (and it is possible that simple floor plans would be) then you might be able to update in real time. If that is the case then you could skip all the nonsense with multiple canvas's.

When zoomed I'd like the map to be movable, but I guess that's just a matter of moving the already rendered image.

It's a little more complex than that since we don't render the entire 'canvas' when zoomed in (it could be 100's of times larger than the screen). But Batik already handles this, you just update the rendering transform and it will update the display.

Currently all I have is a small app that creates a JSVGCanvas and then calls setURI() on it to display an image, also there's a JSlider, that serves no purpose yet, because i can't figure out how to zoom the image.

Take a look at the zoom and pan interactors for an idea of how to make your slider 'live' (see batik.swing.gvt.AbstractImageZoomInteractor).

Reading through the javadoc I gather that the JSVGCanvas is not really all that easy to manipulate and I should do all this in some other way.

Well the JSVGCanvas is a complex beast because it tries to do most of it's work asynchronously so your whole interface doesn't lock up while it's loading data, or rendering the screen.

But as I said, I'm very confused from all the classes and different approaches to this. So what I'm looking for is some tips as to how this could be done. Not actual code, just a general outline**, from someone who's familiar with Batik. This will give me a chance to read up on the right things in possibly the right order.

From what you have described I would look at the various interactors, and the Overlays (most of the interactors are paired with an overlay). These classes are actually fairly simple and they manipulate the canvas in the ways you are interested in.

   You might also want to read my ApacheCON presentation from a
while ago:

   http://www.apache.org/~deweese/ac2003/ApacheCON2003.pdf

   Also the FAQ does have some useful notes on what to do
and what not to do.

Hope this sort of request is allowed on this list.

This is exactly what the list is for.

(I could very well be wrong, maybe Batik is not the proper tool for this job?)

No I think Batik is a good fit for this.

**Something like: "create a JSVGComponent, then use an updatemanager and then do", and so on....

Well, I haven't really done this, but I hope it starts you in the right direction. Feel free to ask back if you run into problems.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to