Dear Mr. Morgan,
The performance of Java-2D is better than most people
have been led to believe. Let me illustrate. The
attached file "MorganClass.java" contains my
impression of a working application containing your
code. I apologize in advance if I made any mistakes
in translating your code sample into a full
application.
The attached file "MorganGreenClass.java" shows some
things that can be done to improve performance. Note
the use of GeneralPath objects. GeneralPath does
everything that the Vector objects do in your original
example. This code is both faster AND renders cleaner
at high magnifications (use the slider to verify
this).
Hope this helps.
Sincerely,
Thorn Green
--- "Mr H. Morgan" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am drawing scientific graphs consisting of a large
> number (over 1000) of
> unconnected lines. The user can zoom in using a
> JSlider. It takes around 50
> milliseconds to perform a zoom, and this flickers
> when the slider is dragged. I
> tried double buffering and this increased the time
> it took to draw ten fold.
>
> Should I be able to get better performance with java
> 2D. Does anyone have any
> suggestions about how to improve my code. Any help
> would be greatly
> appreciated.
>
> I am running it on a Sun Ultra 10 under solaris.
>
> I include my code for doing the drawing.
>
> void drawGraph(Graphics g)
> {
> g2d = (Graphics2D)g;
> int i;
> at = new AffineTransform();
> g2d.translate(xPos, yPos);
> at.setToScale(factor, factor);
> g2d.transform(at);
> g2d.translate(-xPos, -yPos);
>
> // Draw Grid
> g2d.setColor(Color.red);
> for(i=0; i<20; ++i)
> {
> j = i*size;
> g2d.drawLine(i*size,0,i*size,(19 * size));
> }
>
> for(i=0; i<20; ++i)
> {
> j = i*size;
> g2d.drawLine(0,i*siz,(19 * size),i*size);
> }
>
> g2d.setColor(Color.blue);
>
> // Draw Line
> drawLineToPoints(g2d, xValues1, yValues1,
> xValues2, yValues2);
> }
>
> // Function to draw the line
> void drawLineToPoints(Graphics2D g2d, Vector
> xValues1, Vector yValues1, Vector
> xValues2, Vector yValues2)
> {
> for(int a=0; a<xValues1.size(); ++a)
> {
> g2d.drawLine(getInt(xValues1,
> (a)),((19 * size + 1) -
> getInt(yValues1, (a))),getInt(xValues2, (a)),((19 *
> size + 1) - getInt(yValues2,
> (a))));
> }
> }
>
>
===========================================================================
> 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".
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
MorganClass.java
MorganGreenClass.java