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".