Re: Rendering CAD/GIS Data on a Map Canvas



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/
.



Relevant Pages

  • Re: Rendering CAD/GIS Data on a Map Canvas
    ... You probably want to have a look at existing drawing frameworks for Java ... like JHotDraw (based on Swing), instead of doing everything from scratch. ... display my map, or the canvas, will be 600 by 300 pixels. ...
    (comp.lang.java.gui)
  • comp.lang.java.gui FAQ
    ... Q1.3 There are so many Java FAQs. ... Q1.4 Does Sun support or endorse this FAQ? ... Q3.2 How do I update the GUI from another thread? ... Q4.2 What is the Swing single-threading issue? ...
    (comp.lang.java.gui)
  • comp.lang.java.gui FAQ
    ... Q1.3 There are so many Java FAQs. ... Q1.4 Does Sun support or endorse this FAQ? ... Q3.2 How do I update the GUI from another thread? ... Q4.2 What is the Swing single-threading issue? ...
    (comp.lang.java.programmer)
  • comp.lang.java.gui FAQ
    ... Q2.1 My GUI freezes or doesn't update. ... Q2.5 How to create a transparent or non-rectangular window? ... Q5.1 What is the equivalent of AWT's Canvas in Swing? ... Q5.3 How do I generate some charts / plots in Java? ...
    (comp.lang.java.gui)
  • Re: comp.lang.java.gui FAQ
    ... Q2.1 My GUI freezes or doesn't update. ... Q2.5 How to create a transparent or non-rectangular window? ... Q5.1 What is the equivalent of AWT's Canvas in Swing? ... Q5.3 How do I generate some charts / plots in Java? ...
    (comp.lang.java.gui)