Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 2D Text Rendering Problems!  RSS feed

 
Andrew Scott
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My first post of many.

I have a little problem let me tell you:

Setting the scene.

I have has this problem occurring with an application that I am developing. It appears to occur on some machines more than others and seems independent of processor speeds, memory e.t.c.

What I have is a JPanel (workspace panel), within this is contained other JPanels (component panels).

These component panels extend Graphic and contain various symbols and text drawn via JavaGraphics2D.

The component tiles are all of equal size and arranged in a gird like formation with the gridbag layout. All component panels and the workspace panel have double buffering turned on.

These tiles can then build up an image i.e. a flow chart. Each tile contains a mouse listener so that its is highlighted when the mouse is over the component and de-highlighted when it is removed.


However, occasionally the program tends to crash. Sometimes this happens when a another component such as a JDialog obscures part of the workspace panel. However less frequently it can happen when the graphics of the workspace panel are updating. For example during highlighting or adding component panels.


The crash comes in a variety of form but seems to relate to the Text rendering of Java2D. It causes the program to freeze. This problem never occurred before I migrated to Java2D from the standard Java Graphics package. The two most recent variants of the exception stack dumps are shown below.


Exception Stack Dumps:

ONE:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.IfGraphic.paint(IfGraphic.java:223)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

TWO

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FileFont.getGlyphImage(Native Method)
at sun.font.FileFontStrike.getSlot0GlyphImagePtrs(FileFontStrike.java:388)
at sun.font.CompositeStrike.getGlyphImagePtrs(CompositeStrike.java:97)
at sun.font.GlyphList.mapChars(GlyphList.java:211)
at sun.font.GlyphList.setFromString(GlyphList.java:186)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:52)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.AssignGraphic.paint(AssignGraphic.java:93)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

I have taken many a look on the forums around the internet but never found one the specifically answers this problem´┐Ż Please help.


Thanks in advance....

Andrew.

[ August 15, 2006: Message edited by: Andrew Scott ]
[ August 15, 2006: Message edited by: Andrew Scott ]
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see some of your code...
Are you overriding the paint(Graphics g) methods in your JPanels?
Are you doing something with threads?
 
Andrew Scott
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IFGraphic Class





Graphic

IfGraphic inherits from this class.







Thanks
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why are you calling super.paint(G) in your paint method?
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really just looking at the paint() method,

it seems a little confusing to call methods on both G and g2d, when you could just use g2d. Your exceptions are related to drawing glyphs...are you sure that the font that you've chosen is appropriate for the characters that you're trying to draw?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!