Beispiel #1
0
 public Show(int showID, Date date, int[] showStart, Movie movie, Theater theater) {
   this.theater = theater;
   this.showID = showID;
   this.movie = movie;
   this.showStart = showStart;
   this.date = date;
   this.pladser = new boolean[theater.getRows()][theater.getSeatsInRow()];
 }
Beispiel #2
0
 public void makeSeatings() {
   int rows = theater.getRows();
   int seatsInRow = theater.getSeatsInRow();
   MySQL.getReservations();
   for (Reservation reservation : MySQL.sendReservations()) {
     for (int i = 0; i < reservation.getSeats().get(0).length - 1; i++) {
       pladser[reservation.getRows().get(0)][reservation.getSeats().get(0)[i]] = true;
     }
   }
 }
  /** Performs the animations in given array. */
  public void showAnimation(Animation[] animations) {
    int n = animations.length;
    int duration = 0;

    // Set the theatre for the animations
    for (int i = 0; i < n; ++i) {
      Animation anim = animations[i];
      anim.setTheatre(theatre);
      anim.init();
      duration = Math.max(duration, anim.getStartTime() + anim.getDuration());
    }

    // if the theatre is not captured, do capture it.
    boolean capture = !theatre.isCaptured();
    if (capture) {
      theatre.capture();
    } else {
      theatre.updateCapture();
    }

    // The animation loop
    double amount = 0.0;
    long time = System.currentTimeMillis();
    while (amount < duration) {

      // Animate the animations.
      double work = volume / fps;
      amount += work;
      for (int i = 0; i < n; ++i) {
        Animation anim = animations[i];
        if (!anim.isFinished()) {
          double dur = anim.getDuration();
          if (dur > amount) {
            anim.animate(work);
          } else {
            anim.animate(amount - dur);
            anim.doFinish();
          }
        }
      }

      // Spend the excess time waiting.
      long waitTime = (long) (1000 / fps) + time - (time = System.currentTimeMillis());

      if (waitTime > 0 && !runUntil) {
        try {
          Thread.sleep(waitTime);
        } catch (InterruptedException e) {
        }
      }

      // If the engine is controlled, inform the controller.
      if (controller != null) {
        try {
          controller.checkPoint(this, false);
        } catch (Exception e) {
        }
      }
    }

    for (int i = 0; i < n; ++i) {
      Animation anim = animations[i];
      anim.finalFinish();
    }

    // if theatre was captured before animation, release it.
    if (capture) {
      theatre.release();
    }
  }
 /** Called by the thread controller when the animation is resumed. */
 public void resume() {
   theatre.capture();
 }
 /** Called by the thread controller when the animation is paused. */
 public void suspend() {
   theatre.release();
 }