Page 1 of 1

Error when saving Tchart

Posted: Wed Jan 26, 2011 4:55 pm
by 15355183
When i save a TChart using this piece of code:

Code: Select all

filePatch = "/User/Steema/Public/pic1";
TChart1.getExport().getImage().getPNG().save(filePath);
It works. But when i thread that call, every now and then i get these exceptions:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.steema.teechart.drawing.Graphics3DAWT.penPrepare(Graphics3DAWT.java:128)
at com.steema.teechart.drawing.Graphics3DAWT.verticalLine(Graphics3DAWT.java:521)
at com.steema.teechart.axis.AxisDraw$TicksGridDraw.drawGridLine(AxisDraw.java:141)
at com.steema.teechart.axis.AxisDraw$TicksGridDraw.drawGrids(AxisDraw.java:185)
at com.steema.teechart.axis.AxisDraw$TicksGridDraw.drawTicksGrid(AxisDraw.java:408)
at com.steema.teechart.axis.AxisDraw.draw(AxisDraw.java:1070)
at com.steema.teechart.axis.Axis.draw(Axis.java:2579)
at com.steema.teechart.axis.Axes.draw(Axes.java:464)
at com.steema.teechart.Chart.internalDraw(Chart.java:731)
at com.steema.teechart.Chart.paint(Chart.java:2031)
at com.steema.teechart.TChart.paintComponent(TChart.java:616)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent._paintImmediately(JComponent.java:5098)
at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:811)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Re: Error when saving Tchart

Posted: Thu Jan 27, 2011 3:20 pm
by yeray
Hi Turn,

TeeChart is not thread safe. This means you have to control manually (with semaphores or other thread control techniques) to ensure that you won't add a point to the chart at the same time the chart is beeing repainted (or saved to png). Could be this what's happening here?

Re: Error when saving Tchart

Posted: Thu Jan 27, 2011 3:35 pm
by 15355183
Thank you, I didn't know that it wasn't thread safe. And yes, that's exactly whats happening.