| From | Sent On | Attachments |
|---|---|---|
| scen...@javadesktop.org | Jul 28, 2008 1:19 pm |
| Subject: | minor SGText bug | |
|---|---|---|
| From: | scen...@javadesktop.org (scen...@javadesktop.org) | |
| Date: | Jul 28, 2008 1:19:32 pm | |
| List: | net.java.dev.scenegraph.dev | |
Hello,
I believe that I found a bug with text SGText nodes. When a zero length string
is set as the text and font attributes are used there is an illegal argument
exception thrown when painting:
-----------------------------------
Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: Zero
length string passed to TextLayout constructor.
at java.awt.font.TextLayout.<init>(Unknown Source)
at sun.java2d.SunGraphics2D.drawString(Unknown Source)
at com.sun.scenario.scenegraph.SGText.paint(SGText.java:170)
at com.sun.scenario.scenegraph.SGNode.render(SGNode.java:732)
at com.sun.scenario.scenegraph.SGNode.render(SGNode.java:859)
at com.sun.scenario.scenegraph.SGNode.render(SGNode.java:859)
at com.sun.scenario.scenegraph.SGNode.render(SGNode.java:859)
at com.sun.scenario.scenegraph.JSGPanel.paintComponent(JSGPanel.java:524)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at
com.sun.scenario.scenegraph.SGEventQueue.dispatchEvent(SGEventQueue.java:374)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
-------------------------------------
Code to reproduct:
-------------------------------------
import java.awt.Font; import java.awt.Point; import java.awt.font.TextAttribute; import java.util.HashMap; import java.util.Map;
import javax.swing.JFrame;
import com.sun.scenario.scenegraph.JSGPanel; import com.sun.scenario.scenegraph.SGGroup; import com.sun.scenario.scenegraph.SGText;
public class Test { /** * @param args */ public static void main(String[] args) { new Test(); }
public Test( ) {
JFrame f = new JFrame("Text test"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
SGGroup scene = new SGGroup(); JSGPanel panel = new JSGPanel(); panel.setScene(scene);
SGText textNode = new SGText(); textNode.setText(""); textNode.setLocation(new Point(22, 142));
Map<TextAttribute, Object> fontAttributes = new HashMap<TextAttribute,
Object>( );
fontAttributes.put( TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON );
textNode.setFont(new Font(fontAttributes));
scene.add(textNode);
f.getContentPane( ).add( panel ); f.pack(); f.setSize( 700, 400 ); f.setVisible(true); } }
// End code to reproduce ------------------------------- [Message sent by forum member 'billg' (billg)]





