private void setDocument(final URL document, boolean load) throws IOException {
    final Cursor cu = switchCursor(waitc);
    try {
      log.info(document);
      final URL old = this.document;
      this.firePropertyChange("document", old, this.document = document);
      setFile(this.document);
      url.setText(this.document == null ? "{null}" : this.document.toString());
      if (!load) return;

      cm.deregister(tactics.getCurves());
      final ComputedTrajectorySet cts;
      if (this.document == null) cts = null;
      else {
        final IONode n = new JCurlSerializer().read(this.document);
        final IOTrajectories it = (IOTrajectories) n;
        final TrajectorySet ts = it.trajectories().get(0);
        cts = (ComputedTrajectorySet) ts;
      }
      change.discardAllEdits();
      if (cts != null) cts.setCurrentTime(currentTime);
      tactics.setCurves(cts);
      broomSwing.setBroom(tactics.getBroom());
      cm.register(cts);
      setModified(false);
    } finally {
      switchCursor(cu);
    }
  }
 public void register(final ComputedTrajectorySet cts) {
   if (cts == null) return;
   cts.getInitialPos().addRockListener(this);
   cts.getInitialVel().addRockListener(this);
   // cts.getCurrentPos().addRockListener(this);
   // cts.getCurrentSpeed().addRockListener(this);
 }
 @SuppressWarnings("unchecked")
 private static CompoundEdit reset(
     final ComputedTrajectorySet cts, final BroomPromptModel broom, final boolean outPosition) {
   final RockSet<Pos> ipos = cts.getInitialPos();
   final RockSet<Vel> ivel = cts.getInitialVel();
   // store the initial state:
   final PosMemento[] pm = new PosMemento[RockSet.ROCKS_PER_SET];
   for (int i16 = RockSet.ROCKS_PER_SET - 1; i16 >= 0; i16--)
     pm[i16] = new PosMemento(ipos, i16, ipos.getRock(i16).p());
   final IndexMemento bi = new IndexMemento(broom, broom.getIdx16());
   final HandleMemento bh = new HandleMemento(broom, broom.getOutTurn());
   final XYMemento bxy = new XYMemento(broom, broom.getBroom());
   final SplitMemento bs = new SplitMemento(broom, broom.getSplitTimeMillis().getValue());
   final boolean preS = cts.getSuspended();
   cts.setSuspended(true);
   try {
     // reset:
     RockSet.allZero(ivel);
     broom.setIdx16(-1);
     if (outPosition) RockSetUtils.allOut(ipos);
     else RockSetUtils.allHome(ipos);
     broom.setIdx16(1);
     broom.setBroom(new Point2D.Double(0, 0));
     broom.getSplitTimeMillis().setValue(3300);
   } finally {
     cts.setSuspended(preS);
   }
   // create a compound edit
   final CompoundEdit ce = new CompoundEdit();
   ce.addEdit(new UndoableMemento(new SuspendMemento(cts, preS), new SuspendMemento(cts, true)));
   for (int i16 = RockSet.ROCKS_PER_SET - 1; i16 >= 0; i16--)
     ce.addEdit(new UndoableMemento(pm[i16], new PosMemento(ipos, i16, ipos.getRock(i16).p())));
   ce.addEdit(new UndoableMemento(bi, new IndexMemento(broom, broom.getIdx16())));
   ce.addEdit(new UndoableMemento(bh, new HandleMemento(broom, broom.getOutTurn())));
   ce.addEdit(new UndoableMemento(bxy, new XYMemento(broom, broom.getBroom())));
   ce.addEdit(
       new UndoableMemento(bs, new SplitMemento(broom, broom.getSplitTimeMillis().getValue())));
   ce.addEdit(new UndoableMemento(new SuspendMemento(cts, true), new SuspendMemento(cts, preS)));
   ce.end();
   return ce;
 }