Error when saving Tchart

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Error when saving Tchart

Post by Turc » Wed Jan 26, 2011 4:55 pm

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)

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Error when saving Tchart

Post by Yeray » Thu Jan 27, 2011 3:20 pm

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Re: Error when saving Tchart

Post by Turc » Thu Jan 27, 2011 3:35 pm

Thank you, I didn't know that it wasn't thread safe. And yes, that's exactly whats happening.

Post Reply