Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6513150
Votes 0
Synopsis Zero scale AffineTransforms gives NPE in SunGraphics2D.getClipBounds()
Category java:classes_2d
Reported Against
Release Fixed
State 3-Accepted, bug
Priority: 4-Low
Related Bugs 4264298
Submit Date 15-JAN-2007
Description
FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
 customer  Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
If scaling an graphics  customer  to scale (0,0) for a JPanel (or probably any component) it does, as expected, not paint. The NPE that is thrown from sun.java2d.SunGraphics2D.getClipBounds(SunGraphics2D.java:1605) is not expected however.

One solution would be that a graphics  customer  would not accept an AffineTransform with zero scale, throwing an IllegalArgumentException with relevant explanation (much better than the current seemingly unrelated NPE).

Another solution would be to paint at scale 0, i.e. not paint at all.

The latter suggestion would be on par with how other "inivisible" items are painted (i.e. by setting the scale to (epsilon, epsilon) for instance), i.e. not painted at all but without a NPE.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run provided example code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A JFrame showing nothing (in this particular case).
ACTUAL -
A stacktrace.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.java2d.SunGraphics2D.getClipBounds(SunGraphics2D.java:1605)
	at javax.swing.JComponent.paint(JComponent.java:961)
	at test.TestFrame$1.paint(TestFrame.java:15)
	at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
	at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
	at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
	at java.awt.Container.paint(Container.java:1709)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
	at sun.awt.RepaintArea.paint(RepaintArea.java:224)
	at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
	at java.awt.Component.dispatchEventImpl(Component.java:4031)
	at java.awt.Container.dispatchEventImpl(Container.java:2024)
	at java.awt.Window.dispatchEventImpl(Window.java:1778)
	at java.awt.Component.dispatchEvent(Component.java:3803)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class TestFrame  {

    public static void main(String arg[]) {
        JPanel panel = new JPanel() {
            public void paint(Graphics g) {
                ((Graphics2D) g).scale(0,0);
                super.paint(g);
            }
        };

        Frame f = new Frame();
        f.setLayout(new BorderLayout());
        f.add(panel, BorderLayout.CENTER);
        f.setSize(400,300);
        f.setVisible(true);
    }

}

---------- END SOURCE ----------
Posted Date : 2007-01-15 11:26:28.0
Work Around
N/A
Evaluation
The stack trace shows the NPE in 2D, I'm reassigning for evaluation there.
Posted Date : 2007-01-16 20:23:07.0
Comments
  
  Include a link with my name & email   

Submitted On 02-OCT-2009
I'm running into this as well.  No fix in 2 1/2 years??



PLEASE NOTE: JDK6 is formerly known as Project Mustang