Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Swing Frame Rate / Custom RepaintManager  (Read 3143 times)
0 Members and 1 Guest are viewing this topic.
Offline pcabot

Junior Newbie


« Posted 2003-07-23 12:02:02 »


I am writing a visual 2d equipment simulator using jdk1.3.1 under windows 2000.

I use Swing and AWT as renderer because I take advantage of the Design Time builder (bean box) to allow a fast and easy construction of simulations.

The simulations are mainly composed of reusable objects. The base class for all objects is a custom panel (JPanel) on which Images can be drawn.

Here are my questions :

1) When there are a lot of animation on screen (lets say many led objects that flashes), the memory usage of the simulation grows very fast.
I have pin pointed the problem with a Profiler (OptimizeIT) and I have discovered that the paintChildren() method of JComponent creates a lot of RECTANGLE objects to calculate the cliping area.
Is there a way to control that ?

2)  I have tried to create my own RepaintManager by subclassing the RepaintManager class. I have managed to catch all repaint() calls in the application, and force a repaint on the main application frame every 50ms using a timer, to simulate a fix frame rate. This seems to have free some of the CPU because the EventDispatcher is not longer flooded with repaint() request from all the objects. Is there anything else we can do with a Custom RepaintManager ?

3) One of the main item I have also discovered is that I am drawing all my components in a panel where cousins (siblings) components can lie on different layer on the same panel (i.e. components are added using the .add(c, 3) where 3 is a layer in JPanel).
This has a huge effect on performance since the JPanel Swing OptimizedDrawing feature (isOptimizedDrawing flag) must be set to false for the siblings components to be painted correctly. The result is that each time Swing wants to repaint a component, it must calculate the clipping area from the bottom of the hierarchy (frame) to the top (leaf component).
Is there a way to optimize the drawing without forcing swing to redraw the entire object tree ?

Any comments would be appreciated,


Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (864 views)
2018-03-24 14:47:39

ivj94 (125 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!