"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!
I'm having the same issues as you are I think. Check out my post here: stackoverflow.com/questions/196890/java2... It shows the reason for the performance degradation and how to fix it. It's not guaranteed to work well on all platforms though.
You'll see why in the post.
A synthesis of the answers to this post, the answers to Consty's, and my own research: What works: Use GraphicsConfiguration. CreateCompatibleImage to create images compatible with what you're drawing on. This is absolutely essential!
Use double-buffered drawing via Canvas. CreateBufferStrategy. Use -Dsun.
Java2d. Opengl=True where available to speed up drawing. Avoid using transforms for scaling.
Instead, cache scaled versions of the images you are going to use. In my tests, using these methods, I got a speed increase of 10x - 15x, making proper Java 2D graphics a possibility.
Here are some tips off the top of my head. If you were more specific and what you were trying to do I may be able to help more. Sounds like a game, but I don't want to assume.
Only draw what you need to! Don't blindly call repaint() all of the time, try some of the siblings like repaint(Rect) or repaint(x,y,w,h). Be very careful with alpha blending as it can be an expensive operation to blending images / primitives.
Try to prerender / cache as much as possible. If you find yourself drawing a circle the same way, over and over, consider drawing in into a BufferedImage and then just draw the BufferedImage. You're sacrificing memory for speed (typical of games / high perf graphics) Consider using OpenGL, use JOGL of LWJGL.
JOGL is more Java-like whereas LWJGL provides more gaming functionality on top of OpenGL access. OpenGL can draw orders of magnitude (with proper hardware and drivers) than Swing can.
I've done some basic drawing applications using Java. I haven't worked on anything too graphic-intensive, but I would recommend that you have a good handle on all the 'repaint' invocations. An extra repaint call on a parent container could double the amount of rendering your doing.
I've been watching this question, hoping someone would offer you a better answer than mine. In the meantime, I found the following Sun white paper which was written after a beta release of jdk 1.4. There are some interesting recommendations here on fine-tuning, including the runtime flags (at the bottom of the article): "Runtime Flag For Solaris and Linux Starting with the Beta 3 release of the SDK, version 1.4, Java 2D stores images in pixmaps by default when DGA is not available, whether you are working in a local or remote display environment. You can override this behavior with the pmoffscreen flag: -Dsun.
Java2d. Pmoffscreen=true/false If you set this flag to true, offscreen pixmap support is enabled even if DGA is available. If you set this flag to false, offscreen pixmap support is disabled.
Disabling offscreen pixmap support can solve some rendering problems.
Make sure you use double buffering, draw first to one big buffer in memory that you then flush to screen when all drawing is done.
Currently, I use myCanvas. CreateBufferStrategy(2). But I don't know if manually creating a Volatile buffer wouldn't be faster.
– Zarkonnen Sep 29 '08 at 12:38.
There are couple of things you will need to keep in mind 1) is refreshing this link shows how to use swingtimers which might be a good option for calling repaint. Getting repaint figured out (as the previous posters have said is important so you're not doing too much work). 2) Make sure you're only doing drawing in one thread.
Updating UI from mulitple threads can lead to nasty things. 3) Double Buffering. This makes the rendering smoother.
This site has some more good info for you.
An alternative if you don't want to go pure Java 2D is to use a game library such as GTGE or JGame (search for them on Google), then offer easy access to graphics and also offer double buffering and much simpler drawing commands.
There's an important one which hasn't been mentioned yet, I think: cache images of everything you can. If you have an object that is moving across the screen, and it's appearance doesn't change much, draw it to an image and then render the image to the screen in a new position each frame. Do that even if the object is a very simple one - you might be surprised at how much time you save.
Rendering a bitmap is much faster than rendering primitives. You might also want to look at setting rendering hints explicitly, and turning off things like antialiasing if quality considerations permit.
If you find yourself drawing a circle the same way, over and over, consider drawing in into a BufferedImage and then just draw the BufferedImage. Consider using OpenGL, use JOGL of LWJGL. JOGL is more Java-like whereas LWJGL provides more gaming functionality on top of OpenGL access.
OpenGL can draw orders of magnitude (with proper hardware and drivers) than Swing can.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.