/**
  * Method used for unserialization
  *
  * @param in
  * @throws IOException
  * @throws ClassNotFoundException
  */
 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   int savedVersion = in.readInt();
   trackNumber = in.readInt();
   // recreate panels
   trackPanel = new JPanel();
   handlePanel = new HandlePanel(trackNumber);
   graphicsPanel = new GraphicsPanel();
   // set the background and foreground layers
   backgroundLayer = (BackgroundLayer) in.readObject();
   backgroundLayer.setTrack(this);
   foregroundLayer = (ForegroundLayer) in.readObject();
   foregroundLayer.setTrack(this);
   // initialize the track
   // add the tracks
   int layerCount = in.readInt();
   if (layerCount > 0) {
     layers = (TrackModel) in.readObject();
     // since the track field of layers is transient we have to set it
     for (Layer<?> currentLayer : layers) {
       currentLayer.setTrack(this);
     }
     setActiveLayer((Layer<?>) in.readObject());
   } else {
     layers = new TrackModel();
     layers.addListDataListener(this);
   }
   score = (TrackScore) in.readObject();
   // initialize the track
   initTrack();
   // restore the height of the track
   setPreferredHeight(in.readInt());
   if (savedVersion >= 1) {
     trackName = (String) in.readObject();
   }
 }
  /**
   * Creates an instance of {@link Track}
   *
   * @param trackNumber number of the track
   */
  public Track(int trackNumber) {
    super();

    // create the panels
    trackPanel = new JPanel();
    handlePanel = new HandlePanel(trackNumber);
    graphicsPanel = new GraphicsPanel();

    // initializes the foreground and background drawer
    backgroundLayer = new BackgroundLayer(this);
    foregroundLayer = new ForegroundLayer(this);

    // set the track number
    this.trackNumber = trackNumber;

    // set the track score
    score = new TrackScore(this);

    // initializes the layer list
    layers = new TrackModel();
    layers.addListDataListener(this);

    initTrack();
  }