Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2006

Tip: Looking for answers? Try searching our database.

Rendering CAD/GIS Data on a Map Canvas

Thread view: 
redefined.horizons@gmail.com - 24 Aug 2006 17:00 GMT
I am working through the design of a disp[lay for a CAD/GIS program
written
in Java. I haven't decided for sure if I will use Swing or SWT for the
GUI yet.

This program I am working on will have to display a large number of 2D
geometric shapes. I'm want to make the rendering process as quick and
efficient as possible. I had a couple of questions about how I can do
this:

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?

I'm trying to avoid a situation where everytime the user pans the
display a
minor amount that the whole screen needs to be rendered. In the above
situation I would have that 20% buffer to allow some limited space for
panning.

Is this method possible? Any ideas or suggestions on how I can learn
the
techniques I need to implement it?

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? Would I do this by
splitting my
display into a grid of different images, or can I just pass the
rectangular
bounds of the new area that needs to be rendered?

Is this method of partial rendering possible? Any ideas or suggestions
on
how I can learn the techniques I need to implement it?

I am interested in learning how this might be done in both Swing and
SWT. The way each widget toolkit handles this area of graphics display
may be the diciding factor in which is chosen for the program.

Thanks for the help.

Scott Huey
Thomas Weidenfeller - 25 Aug 2006 08:27 GMT
> 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
[quoted text clipped - 5 lines]
> 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
Signature

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/

sunburned.surveyor@gmail.com - 25 Aug 2006 16:52 GMT
Thank you so much for your help Thomas.

That is just what I needed to know. I will look at the information you
referenced in your e-mail.

Scott Huey

> > I am working through the design of a disp[lay for a CAD/GIS program
> > written
[quoted text clipped - 66 lines]
> 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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.