Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CAD/GIS Display - Question #1  RSS feed

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working through the design of a disp[lay for a CAD/GIS program written in Java. (I haven't decided firmly if I will use SWT or Swing.)

This program will have to display a large number of Java 2D 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. I will ask the first in this thread:

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?

Landon

(P.S. - I already have the O'Reilly book on Java 2D Graphics...)
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could render into a BufferedImage instead of directly on the screen, and then render the visible part of the Image on the screen.

Another option is to reuse the previously rendered image by just panning it by the necessary amount and then only redraw those areas that weren't visible beforehand.

But you should probably get your basic rendering working before you worry about these things - those optimizations shouldn't be too hard to introduce later, and you might learn that there are other things that are more important to optimize. "Premature optimization is the root of all evil."
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!