Hi,
I develop a high performance application that has to draw loooots of
objects to the screen (usually some thousands up to 1 mio.).
Most of the data are just lines and rectangles, some minor ones are
polygons. So I used the Shape object to store my data in a common way.
Shape shape = new Rectangle2D.Double(...);
I used the following to draw the elements (I use a special check if the
object is shown on screen, before I draw it of course, which I supress
in this example code to keep it short):
Graphics2D g2 = (Graphics2D)g;
// do some transformations/scaling...
Iterator rectIter = rectangleList.iterator();
while (iter.hasNext()) {
Rectangle2D rect = (Rectangle2D)iter.next();
g2.draw(rect);
}
That works quite fine, except the drawing speed is not what I expected.
I investigated some time and found out that replacing the drawing line
from:
g2.draw(rect);
to
g2.drawrect((int)rect.x,(int)rect.y,(int)rect.width,(int)rect.height);
The drawing speed on my linux box is around 3 times faster. Does anybody
know why it works that way?
I really like the draw(shape) in the Graphics context, but it is n-times
slower then the direct drawing functions. So my recommendation for fast
redrawing of many objects is to use the functions from the pure graphics
object - and btw. scaling/rotating/translating works even fine while
using these functions!
On the other hand I found that drawing a looooong line into a Graphics
context that uses clipping (and 99.9 % of the line is outside of the
clipping area) will cause most jvms to freeze (at least linux,sun) - I
guess it is a not directly a bug, but the cpu performance goes up to
100% and stays there for minutes.... - and never comes back.
I am not sure, if I should file this as a bug into the bugtracking
system.
Karsten
--
Karsten Trott
Technical Lead, Intuitive Design Interface , Get2Chip.com, Inc.
Phone: +49-89-5908-2333
Fax: +49-89-5908-1328
===========================================================================
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".