Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

CAD/GIS Display - Question #1

Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


(P.S. - I already have the O'Reilly book on Java 2D Graphics...)
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic