コード例 #1
0
ファイル: World.java プロジェクト: TesterViera/JavaLibWorld
  /**
   * Initialize the canvas, the event handlers, and the timer for the given <code>
   * {@link World World}</code> to the current settings.
   *
   * @param bw the new <code>{@link World World}</code> created by the user
   * @return the same <code>{@link World World}</code> with the canvas, the event handlers, and the
   *     timer initialized to the current settings.
   */
  private synchronized World resetWorld(World bw) {
    if (this.worldExists) {
      bw.theCanvas = this.theCanvas;
      bw.worldExists = true;

      // with all the listeners
      bw.ka = this.ka;
      bw.ma = this.ma;
      bw.windowClosing = this.windowClosing;
      bw.ka.currentWorld = bw;
      bw.ma.currentWorld = bw;

      // and the timer
      bw.mytime = this.mytime;
      bw.mytime.setSpeed();
      bw.mytime.currentWorld = bw;

      // draw the new world
      bw.drawWorld("");
      return bw;
    } else {
      this.theCanvas.clear();
      this.drawWorld("");
      return this;
    }
  }