Serialization problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
bonododo
Posts: 9
Joined: Wed Mar 17, 2004 5:27 pm

Serialization problem

Post by bonododo » Wed May 19, 2004 10:22 am

I would like to serialize a chartpanel containing timeseries. The serialization seems to works good, as it creates me a file, but unfortunatly the unserialization doesn t seems to work. Does someone know where it comes from? has someone already done this before?


code :

Serializing
File file = jFileChooser1.getSelectedFile();
FileOutputStream f = new FileOutputStream(file);
ObjectOutputStream o = new ObjectOutputStream(f);
o.writeObject(myChartPanel);
o.close();

deserializing
File file = jFileChooser1.getSelectedFile();
FileInputStream f = new FileInputStream(file);
ObjectInputStream o new ObjectInputStream(f);
ChartPanel tata = (ChartPanel) o.readObject();
o.close();



and here is the error i get:
java.lang.NullPointerException at cc.ods.util.SerializeOpen.main



plz help me and send me any ideas you got :D

thanks in advance

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed May 19, 2004 11:57 am

The ChartPanel class is not yet serializable. You might have more luck just serializing the chart (and put in into a new ChartPanel after deserialization), although even then you might run into a bug or two (not many people use the serialization, as far as I can tell, so this part of JFreeChart hasn't been extensively tested).

I'll make some changes to the ChartPanel class to get basic serialization working...then hopefully the bugs will surface and get squashed one by one.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

bonododo
Posts: 9
Joined: Wed Mar 17, 2004 5:27 pm

Post by bonododo » Wed May 19, 2004 12:45 pm

ok thanks for your reply, also it's not what i was awaiting :shock:


and thanks for your work, it s really great


bonododo

Locked