Re: Rendering CAD/GIS Data on a Map Canvas
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 09:27:12 +0200
redefined.horizons@xxxxxxxxx wrote:
I am working through the design of a disp[lay for a CAD/GIS program
written
in Java.
You probably want to have a look at existing drawing frameworks for Java like JHotDraw (based on Swing), instead of doing everything from scratch.
Let's say for the sake of this discussion that the area I will use to
display my map, or the canvas, will be 600 by 300 pixels. Would it be
possible to render the shapes that would fall within an area 20% larger
than
this to allow for quicker panning and zooming?
You are mixing things up. Painting more than what is visible will hot help for zooming, only for panning.
Regarding panning: Yes, with a trick. You could render to an off-screen image, like a VolatileImage, which you made larger then the visible portion of the drawing panel. A VolatileImage can be hardware accelerated (depends on platform and VM), so later drawing portions of the VolatileImage to the panel should be fast.
Is this method possible? Any ideas or suggestions on how I can learn
the
techniques I need to implement it?
Sun's Java 2D tutorial. And a good book on computer graphics in general will be a good idea. Plus, the GoF book is full of related patterns, which is not surprising, since the authors were involved in the historic InterViews GUI framework which also included a drawing framework called Idraw (all written in C++).
Oh, and you might want to sort out your Java terminology. A canvas in Java is associated with an AWT component (Canvas), which you don't want to use if you use Swing for painting. There one uses a JPanel, or even a JComponent.
Also, my program will allow the user to select shapes on the display
using
various interactions with the mouse, and will subsequently allow them
to
move or modify those geometries. Is it possible to only render the
portion
of the canvas that needs to be repainted, instead of repainting the
entire
canvas everytime a single shape is modified?
Yes, in Swing you would issue a repaint, specifying a bounding rectangle which indicates the area of the screen which has changed. In the paintComponent() method your code would have to observe that information and only redraw the changed parts.
Is this method of partial rendering possible? Any ideas or suggestions
on
how I can learn the techniques I need to implement it?
The API documentation, the Java 2D tutorial.
I am interested in learning how this might be done in both Swing and
SWT.
Keep in mind that SWT is reported to be slow like a dog on anything but Windows. Which is ironic, because one justification for its existence was that Swing is soooooo slow (which it never was).
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
.
- Follow-Ups:
- Re: Rendering CAD/GIS Data on a Map Canvas
- From: sunburned . surveyor
- Re: Rendering CAD/GIS Data on a Map Canvas
- References:
- Rendering CAD/GIS Data on a Map Canvas
- From: redefined . horizons
- Rendering CAD/GIS Data on a Map Canvas
- Prev by Date: Re: Help with a JPanel
- Next by Date: Set keyboard focus to Applet when it is loaded
- Previous by thread: Rendering CAD/GIS Data on a Map Canvas
- Next by thread: Re: Rendering CAD/GIS Data on a Map Canvas
- Index(es):
Relevant Pages
|