*
* Demonstrate Java hang when rendering a Shape with max. coordinates
* much greater than 32K.
*
* Item 16
* 10/3/2000
*
*
* Displaying a Shape in Graphics2D with coordinates much greater than 32K
* using the default transform and clip causes Java to hang.
*
* The problem occurs under WinNT 4.0, Win95, Win98, and Solaris 8 iwth
* the 1.2.2 and 1.3 JVMs.
*
* The program below draws a Shape which is a triangle, and the sole
* command line argument is a number used as the maximum x and y
* coordinates of the triangle.
*
* In other words it draws a filled triangle with coordinates: (0,0),
* (0,n), (n,n)
*
* 33052 may be a magic number for this problem on Solaris.vi
*
*
*
* To reproduce:
* javac gifclient/ClipBugViewer.java
*
* java gifclient.ClipBugViewer 64000
*/
package gifclient;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
/** demonstrate clipping bug
*/
public class ClipBugViewer extends JPanel {
private Shape m_shape;
public ClipBugViewer()
{
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
if (m_shape != null)
{
System.out.println("paintComponent()");
g2d.setColor(Color.blue);
System.out.println("paintComponent() about to draw");
g2d.draw(m_shape);
System.out.println("paintComponent() about to fill");
g2d.fill(m_shape);
System.out.println("paintComponent() returning");
}
}
public void setShape(Shape shape)
{
m_shape = shape;
}
public static final void main(String [] args) throws Exception
{
int bound = 32000;
if (args.length > 0)
try {
bound = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.err.println("Usage: ClipBugViewer <#>" +
" Supply an upper bound, default is 32000");
};
ClipBugViewer viewer = new ClipBugViewer();
viewer.setSize(new Dimension(600, 600));
JFrame frame = new JFrame();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
path.lineTo(0, bound);
path.lineTo(0 + bound, bound);
path.closePath();
viewer.setShape(path);
frame.setSize(new Dimension(600, 600));
frame.setVisible(true);
frame.getContentPane().add(viewer);
frame.repaint();
}
}
- duplicates
-
JDK-4250125 Graphics.drawline() hangs for some values
-
- Closed
-
-
JDK-4190783 rendering very large paths takes a long time when not antialiasing
-
- Closed
-
-
JDK-4204453 Large polygons with negative values hang VM/rasterizer
-
- Closed
-
-
JDK-4297004 Infinite loop on drawing a polygon into an offscreen image graphics
-
- Closed
-
-
JDK-4323072 Graphics2D vector rendering causes 100% cpu for high magnification
-
- Closed
-
- relates to
-
JDK-4265778 Java2D incorrectly renders objects with large coordinates
-
- Open
-
-
JDK-4252578 Program hang in JPanel with large Graphics.drawLine
-
- Resolved
-