-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta3
-
x86
-
windows_95
Name: rlT66838 Date: 07/08/99
I discovered my Java application to hang while zooming in on
a graphics repaint while drawing lines.
I experimented and determined it happens with
drawLine(x1,y1,x2,y2) when (x2-x1)*(y2-y1)>2^30 or so.
This happens for lines as small as drawLine(0,0,32900,32900).
That's significantly larger than the screen resolution,
but when I'm zooming in on a small part of my image, this
happens quite easily.
Included is an example program. It draws:
drawLine(0,0,rad,rad), with rad=32000 and each time a
"repaint" button is pressed, rad is increased by 100.
Pressing "repaint" 9 times will cause it to fail at rad=32900.
I used this program to test the limits. The error will occur
on any little program with a drawLine which exceeds this limit.
In the very least, the bug should be fixed so the program
doesn't hang - it could just draw nothing.
Thanks!
********************************
//redraw4.java
//7/7/99
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class redraw4 extends JFrame
implements ActionListener
{
static redraw4 frame = new redraw4("Drawing test");
static Dimension d=new Dimension(200,200);
test t=new test();
int rad=32000;
redraw4(String x)
{
super(x);
Container c=getContentPane();
c.setLayout(new BorderLayout());
c.add(t,BorderLayout.CENTER);
Button b=new Button("repaint");
b.addActionListener(this);
c.add(b,BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent e)
{
String arg = e.getActionCommand();
if (arg.equals("repaint")) t.repaint();
}
public static void main(String[] args)
{
frame.addWindowListener
( //allow application to close with x button.
new WindowAdapter()
{
public void windowClosing(WindowEvent e) {System.exit(0);}
}
);
frame.pack();
frame.setVisible(true);
}
class test extends JPanel
{
public test()
{
super();
}
public Dimension getPreferredSize() { return d; }
public void draw(Graphics g)
{
g.setXORMode(getBackground());
g.setColor(Color.white);
g.setPaintMode();
g.drawString("drawLine(0,0,"+rad+","+rad+")",10,100);
g.drawLine(0,0,rad,rad);
rad=(int)(rad+100);
}
public void paint(Graphics g)
{
super.paint(g);
draw(g);
}
}
}
(Review ID: 85334)
======================================================================
- relates to
-
JDK-4376103 Java hangs rendering a shape with max. coordinates much greater than 32K
- Resolved