As soon a I use gradients in my code, the repaint isn\'t done while resizing I get something like that while resizing (black rectangles where it has been resized, see image in t
I put together a test and found that the GradientPaint
has woeful performance. Taking an average render time from 1.2 seconds (at 400x400 pixles) out to 20+ seconds.
I changed the GradientPaint
for a LinearGradientPaint
and found that the render time was around 1.3 seconds instead.
LinearGradientPaint lgp = new LinearGradientPaint(
new Point2D.Float(0, minY),
new Point2D.Float(0, maxY),
new float[] {0f, 0.5f, 1f},
new Color[] {Color.BLUE, Color.RED, Color.BLUE}
);
g2d.setPaint(lgp);
// Render all your samples, don't reapply or change you paint...
Sorry, my sample isn't very exciting...
You may find it better to render to a backing buffer in a background thread instead and paint the whole image to the screen once it's complete. This will stop the screen from becoming "paused"