Display CAD data

M

Manavan

I am writing an application which needs to display CAD data, a few
millions of Polygons. I am using Java Graphics2d. I extended
JComponent to create a Canvas widget. In the paint module, I am
drawing each of these shapes.

My questions are:
The application needs to be able to zoom-in, zoom-out, show a
particular area. What is the best way to do this?

In the paint component should I draw all the millions of shapes and
then set clip area and transforms to zoom to the interested area? That
would be lot slower - wouldn't it?

Or should I come up with an algorithm which will find out the shapes
that fall within the interested area and call drawShape() for only
those? This algorithm looks so common I wonder if Java already has a
way to essentially do this? Or any library that I can look into?
 
L

Lew

Manavan said:
I am writing an application which needs to display CAD data, a few
millions of Polygons. I am using Java Graphics2d. I extended
JComponent to create a Canvas widget. In the paint module, I am
drawing each of these shapes.

My questions are:
The application needs to be able to zoom-in, zoom-out, show a
particular area. What is the best way to do this?
...

John B. Matthews answered this question in clj.gui. Please do not multi-post.

(Redirected back to clj.gui)
 
R

Roedy Green

In the paint component should I draw all the millions of shapes and
then set clip area and transforms to zoom to the interested area? That
would be lot slower - wouldn't it?

In your paint method you know the clip region. You can be mindless
and paint everything and trust the clip region to throw most of it
away. Or you can be smart and do some rough filtering so you only
bother to draw stuff that will overlap the clip region. If you have
millions of triangles, obviously you need to be smart.

Millions of triangles suggest you are doing 3D rendering. Perhaps you
want to use a 3D rendering package that handles this stuff at a low
level, e.g. using the processing power of the video processor.
--
Roedy Green Canadian Mind Products
http://mindprod.com

There is a certain cosmic justice in the bankruptcy of General Motors. People at every level of the economic spectrum who for
economic motives helped GM pummel the environment with deliberately inefficient automobiles are being punished both severely and economically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,274
Latest member
JessMcMast

Latest Threads

Top