Title: RE: [JAVA2D] Slow response

How many vehicles are you painting?

I've written many apps that have situations like this. I used to write them the way you're describing, where I'd use an individual Compoenent/JComponent for each object I was drawing. It made hit detection really easy as well as drag&drop. Unfortunately, if you want to get any real performance this strategy will not work.  It's also very error prone.  There's too much reliance on the underlying windowing system to do a lot of heavy lifting for you.

The technique I highly recommend and now use all the time is doing your own lightweight implementation. Do everything in AWT, and only use Swing for really complex widgets like JTree/JTable/JTabbedPane, etc. There's a lot of tricky rules about AWT/Swing mixing, but they're very well known. You also have to deal with delegating mouse events out to the visual objects, which isn't that hard. You also need to deal with the painting of the children, not that hard in AWT.  These systems are much more complicated to build, but are highly robuts and perform very well. On a current project I can get fluid motion(>30 fps) of about 50 objects that interact with a DB for every frame. A prior implementation in Swing like you described below of this yielded ~0.5 fps.  It also was subject to the random whims of Swing global repaint calls and drawing artifacts.

That's my 0.02

Jeff Kardatzke

-----Original Message-----
From: Wong, Fook Hoi [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 22, 2001 9:37 PM
To: [EMAIL PROTECTED]
Subject: [JAVA2D] Slow response


hi,

I am using java to create a program which simulates moving vehicles.  The
platform is a dual CPU PC (800Mhz  & 512MB ram) with Windows2000 OS.

Basically, the APPLICATION consists of 2 panels, one (a JLayeredPane) is
used for the painting of the icons representing the vehicles which are
updated every second via calls to JComponent.setLocation() for each of the
icons.  The other panel  ('control panel')  consist of JTextFields and
JButtons with which i interact with the application - such as zooming, etc.

The PROBLEM i am facing is that as more vehicles are added to the
JLayeredPane, the 'control panel' reaction time slows down.  Above a
certain load, the response for a click on a button can slow to 3 or 4
seconds.  As an example, when i click on a JComboBox, the list will be
displayed only after 4 secs.  The interesting thing is that at all times,
the CPU load (via windows Task Manager) only indicates about 50% load on
both processors, memory usage is also way below 512MB .  Also the icons
still seem to be repainted regularly at 1 second intervals.   I dont
understand what is causing the delay in the updates on the 'control panel'.

Any clues / help in this is greatly appreciated.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to