Hi,

  I'm writing a Java-Application for editing musical
notations, running on an PentiumII/400Mhz WindowsNT with
128Mb. The program has to display many (>400) lines on a
Panel. For an increase in the performance I tried out
different variants:

// variant 1
g.setStroke(new BasicStroke(lineWidth));
g.drawLine(x, y, x + width, y);

// variant 2
g.setStroke(new BasicStroke(lineWidth));
g.draw(new Line2D.Double(x, y, width, 0));

// variant 3
g.fillRect(x, y, x + width, y + lineWidth);

// variant 4
g.fill(new Rectangle2D.Double(x, y, width, lineWidth));

Taking a look at the implementation of BasicStroke I was not
suprised of the performance results:
Variant 3 and 4 are 40% faster than variant 1 and 2.

Then I tried to improve the perfomance by reusing the
Rectangle2D in variant 4, but that resulted in only a
marginal speed up.

So I even wrote an own shape named SimpleLine, which reuses
its own PathIterator for each call to getPathIterator() -
although that's not conform to the Shape interface (it should
return a fresh one each time). I was able to fill it on the
graphics but it didn't got much faster.

What I would like to know:
Have I to live with this poor performance of Java2D?
I thought that I removed all OO-overhead with my own shape
class and by reusing all objects - but it keeps to be slow.
Have I missed something? Is there any faster solution?
Where does Java2D spend all the time just to fill a simple
rectangular shape?

Regards

Sven

===========================================================================
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