/**
  * 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();
   }
 }
 /**
  * Sets the current track with the parameters and the layers of the specified track
  *
  * @param otherTrack
  */
 public void setContentAs(Track otherTrack) {
   foregroundLayer = otherTrack.foregroundLayer.clone();
   foregroundLayer.setTrack(this);
   backgroundLayer = otherTrack.backgroundLayer.clone();
   backgroundLayer.setTrack(this);
   for (Layer<?> currentLayer : otherTrack.layers) {
     Layer<?> layerToAdd = currentLayer.clone();
     layerToAdd.setTrack(this);
     getLayers().add(layerToAdd);
   }
   if ((otherTrack.trackName != null)
       && !otherTrack.trackName.equals(otherTrack.getDefaultName())) {
     trackName = otherTrack.trackName;
   }
   score.setMinimumScore(otherTrack.score.getMinimumScore());
   score.setMaximumScore(otherTrack.score.getMaximumScore());
   score.setScoreAxisAutorescaled(otherTrack.score.isScoreAxisAutorescaled());
 }