 package save;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import main.ChronoPanel;
 import main.ChronoWindow;
 import signals.AdaptSignals;
 import signals.Signals;
 import tools.Arrow;
 
 public class Slot
 {
   public static void save(File saveDir)
   {
     try
     {
       ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(saveDir)));
       
       oos.writeObject(Integer.valueOf(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).signals.size()));
       for (int i = 0; i < ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).signals.size(); i++) {
         oos.writeObject(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).signals.get(i));
       }
       oos.writeObject(Integer.valueOf(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).nbrTimeLapse));
       oos.writeObject(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).timeLapse);
       oos.writeObject(Boolean.valueOf(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).displayBackLines));
       oos.writeObject(main.Main.version);
       
       oos.writeObject(Boolean.valueOf(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).antialiasing));
       oos.writeObject(Integer.valueOf(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).arrows.size()));
       for (int i = 0; i < ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).arrows.size(); i++) {
         oos.writeObject(((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).arrows.get(i));
       }
       oos.close();
     }
     catch (FileNotFoundException e)
     {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   
   public static void load(File openDir)
   {
     int size = 0;
     try {
       ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(openDir)));
       try
       {
         size = ((Integer)ois.readObject()).intValue();
         for (int i = 0; i < size; i++)
         {
           ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).signals.add(new AdaptSignals((Signals)ois.readObject()));
         }
         ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).nbrTimeLapse = ((Integer)ois.readObject()).intValue();
         ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).timeLapse = ((int[][])ois.readObject());
         ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).displayBackLines = ((Boolean)ois.readObject()).booleanValue();
         String version = (String)ois.readObject();
         
         ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).antialiasing = ((Boolean)ois.readObject()).booleanValue();
         int arrowSize = ((Integer)ois.readObject()).intValue();
         for (int i = 0; i < arrowSize; i++) {
           ((ChronoPanel)ChronoWindow.chrono.get(ChronoWindow.active)).arrows.add((Arrow)ois.readObject());
         }
       }
       catch (ClassNotFoundException e) {
         e.printStackTrace();
       }
       ois.close();
     } catch (FileNotFoundException e) {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }





