PDA

View Full Version : Java Graphics Unnecessary Repainting



SNYP40A1
July 11th, 2010, 08:02 PM
I am using JFreeChart to draw graphics in Java. I find that the draw function is called several times back to back while I expect that it should only be called once. I want to figure out what's triggering the repaint() or update() calls. I put in a Thread.dumpStack() at the place of redraw, but it only tells me that the repaint call originated from the Swing EventDispatch thread. How do I determine what actually notified the Swing Dispatcher to repaint the plot? Is there a Swing trace debug method for this?



java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at org.jfree.chart.renderer.xy.XYBarRenderer.drawItem s(XYBarRenderer.java:1343)
at org.jfree.chart.plot.XYPlot.render(XYPlot.java:373 8)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3311)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:12 34)
at org.jfree.chart.ChartPanel.paintComponent(ChartPan el.java:1663)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintToOffscreen(JComponent .java:5124)
at javax.swing.RepaintManager$PaintManager.paintDoubl eBuffered(RepaintManager.java:1479)
at javax.swing.RepaintManager$PaintManager.paint(Repa intManager.java:1410)
at javax.swing.BufferStrategyPaintManager.paint(Buffe rStrategyPaintManager.java:294)
at javax.swing.RepaintManager.paint(RepaintManager.ja va:1224)
at javax.swing.JComponent._paintImmediately(JComponen t.java:5072)
at javax.swing.JComponent.paintImmediately(JComponent .java:4882)
at javax.swing.RepaintManager.paintDirtyRegions(Repai ntManager.java:785)
at javax.swing.RepaintManager.paintDirtyRegions(Repai ntManager.java:713)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Re paintManager.java:693)
at javax.swing.SystemEventQueueUtilities$ComponentWor kRequest.run(SystemEventQueueUtilities.java:125)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 597)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)