Exemplo n.º 1
0
  @Override
  public void bindData(Star data) throws NullPointerException {
    titleOut.setText(data.getTitle());
    ratingOut.setText(new DecimalFormat("#.#").format(data.getRating()));

    new Thread(
            () -> {
              Image image =
                  new Image(
                      "file:"
                          + PersistenceManager.getInstance().getRootPath()
                          + EAltaiPersistence.STAR_MAIN_IMG_RELATIVE_PATH.getValue()
                          + data.getMainImage());
              double imgH = image.getHeight();
              double imgW = image.getWidth();

              Rectangle2D viewPort;
              if (imgH > imgW) {
                viewPort = new Rectangle2D(0, (imgH / 2) - (imgW / 2), imgW, imgW);
              } else if (imgH < imgW) {
                viewPort = new Rectangle2D((imgW / 2) - (imgH / 2), 0, imgH, imgH);
              } else {
                viewPort = new Rectangle2D(0, 0, imgH, imgW);
              }

              Platform.runLater(
                  () -> {
                    mainImg.setViewport(viewPort);
                    mainImg.setImage(image);
                  });
            })
        .start();
  }
Exemplo n.º 2
0
  public static void updateDimensions(Boolean updateCanvas) {
    CANVAS_WIDTH = WIDTH - (WALL_WIDTH * 2);
    CANVAS_HEIGHT = HEIGHT;

    if (updateCanvas) {
      Canvas cvs = control.getCanvas(1);
      cvs.setWidth(Asteroids.WIDTH);
      cvs.setHeight(Asteroids.HEIGHT);

      Image wall = Util.getImage("side_wall.png");

      Canvas leftWall = control.getLeftWall();
      Canvas rightWall = control.getRightWall();

      GraphicsContext lw = leftWall.getGraphicsContext2D();
      GraphicsContext rw = rightWall.getGraphicsContext2D();

      leftWall.setHeight(Asteroids.HEIGHT);
      rightWall.setHeight(Asteroids.HEIGHT);

      double wall_height =
          (((Asteroids.WALL_WIDTH * 100) / wall.getWidth()) / 100) * wall.getHeight();

      for (int h = 0; h < Asteroids.HEIGHT; h += wall_height) {
        lw.drawImage(wall, 0, wall_height * h, Asteroids.WALL_WIDTH, wall_height);
        Util.drawRotatedImage(rw, wall, 180, 0, wall_height * h, Asteroids.WALL_WIDTH, wall_height);
      }
    }
  }
Exemplo n.º 3
0
 /** This method load all the image of the block (Sprite). */
 private void loadImages() {
   Image temp = new Image("resources/newBlock.png");
   PixelReader reader = temp.getPixelReader();
   images.add(new WritableImage(reader, 0, 0, 100, 40));
   images.add(new WritableImage(reader, 100, 0, 100, 40));
   images.add(new WritableImage(reader, 200, 0, 100, 40));
 }
 public void drawBarUp() {
   barUpR = new Rectangle(0, 0, 1000, 50);
   barUpR.setFill(new ImagePattern(barUp, 0, 0, barUp.getWidth(), barUp.getHeight(), false));
   i = new ImageView();
   i.setImage(barUpRight);
   i.setX(1000);
   i.setY(0);
 }
Exemplo n.º 5
0
 public void changeSize(int newSize) {
   this.size = newSize;
   width = size * 12 + 45;
   double rightWidth = RIGHT.getWidth() - Config.SHADOW_WIDTH;
   double centerWidth = width - LEFT.getWidth() - rightWidth;
   centerImageView.setViewport(
       new Rectangle2D((CENTER.getWidth() - centerWidth) / 2, 0, centerWidth, CENTER.getHeight()));
   rightImageView.setTranslateX(width - rightWidth);
 }
 @Override
 public void handleProductPreview(MouseEvent event, SLCImage product) {
   scrollPane.setHmax(1);
   scrollPane.setVmax(1);
   imageView.relocate(0, 0);
   File imageFile = product.previewStrategy().backgroundFile;
   Image image = new Image(imageFile.toURI().toString());
   pane.setPrefHeight(image.getHeight());
   pane.setPrefWidth(image.getWidth());
   imageView.setImage(image);
 }
 private void fitToScreen() {
   if (mImage.getWidth() < 1100 || mImage.getHeight() < 1100) {
     mImageView.setFitWidth(1100);
     mImageView.setFitHeight(1100);
   } else {
     mImageView.setFitWidth(mImage.getWidth());
     mImageView.setFitHeight(mImage.getHeight());
   }
   mImageView.setPreserveRatio(true);
   mImageView.setSmooth(true);
   mImageView.setCache(true);
   mImageView.setImage(mImage);
 }
  public static Image transform(Image in, ColorTransformer f) {
    int width = (int) in.getWidth();
    int height = (int) in.getHeight();

    WritableImage out = new WritableImage(width, height);

    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        out.getPixelWriter().setColor(x, y, f.apply(x, y, in.getPixelReader().getColor(x, y)));
      }
    }

    return out;
  }
Exemplo n.º 9
0
 public Bat() {
   height = (int) CENTER.getHeight() - Config.SHADOW_HEIGHT;
   Group group = new Group();
   leftImageView = new ImageView();
   leftImageView.setImage(LEFT);
   centerImageView = new ImageView();
   centerImageView.setImage(CENTER);
   centerImageView.setTranslateX(LEFT.getWidth());
   rightImageView = new ImageView();
   rightImageView.setImage(RIGHT);
   changeSize(DEFAULT_SIZE);
   group.getChildren().addAll(leftImageView, centerImageView, rightImageView);
   getChildren().add(group);
   setMouseTransparent(true);
 }
 /*     */ protected Cursor getCustomCursor(WCImage paramWCImage, int paramInt1, int paramInt2)
       /*     */ {
   /*  25 */ return new ImageCursor(
       Image.impl_fromPlatformImage(Utilities.getUtilities().toPlatformImage(paramWCImage)),
       paramInt1,
       paramInt2);
   /*     */ }
Exemplo n.º 11
0
 private static void setRGBMatrix() {
   int height = (int) image.getHeight();
   int width = (int) image.getWidth();
   imgR = new double[width][height];
   imgG = new double[width][height];
   imgB = new double[width][height];
   PixelReader reader = image.getPixelReader();
   for (int readY = 0; readY < height; readY++) {
     for (int readX = 0; readX < width; readX++) {
       Color color = reader.getColor(readX, readY);
       imgG[readX][readY] = color.getGreen();
       imgB[readX][readY] = color.getBlue();
       imgR[readX][readY] = color.getRed();
     }
   }
 }
Exemplo n.º 12
0
 /**
  * Returns the sum of the red, green, and blue components of all the pixels of an image within a
  * region.
  *
  * <p>If the region extends outside the bounds of the image, each pixel outside the bounds of the
  * image is considered to have a value of zero.
  *
  * @param image the image to sum. This must not be null.
  * @param region The region of the image to sum pixels from. This must not be null.
  * @return The sum of components
  */
 private static long brightnessSum(Image image, Rectangle region) {
   final PixelReader reader = image.getPixelReader();
   long sum = 0;
   for (int y = region.y; y < region.y + region.height + 1; y++) {
     for (int x = region.x; x < region.x + region.width + 1; x++) {
       if (x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight()) {
         int argb = reader.getArgb(x, y);
         // Sum the red, green, and blue components to get a value
         // between 0 and 765
         long brightness = ((argb >> 16) & 0xFF) + ((argb >> 8) & 0xFF) + (argb & 0xFF);
         sum += brightness;
       }
     }
   }
   return sum;
 }
Exemplo n.º 13
0
 public static void filtering(int[][] mask) { // blur
   int height = (int) image.getHeight();
   int width = (int) image.getWidth();
   initializeRGBMATRIX(height, width);
   setRGBMatrix();
   imgR = countSum(mask, imgR);
   imgB = countSum(mask, imgB);
   imgG = countSum(mask, imgG);
   WritableImage wi = new WritableImage(width, height);
   PixelWriter pw = wi.getPixelWriter();
   writePixels(pw, imgR, imgB, imgG, height, width);
   imageView.setRotate(angle);
   imageView.setImage(wi);
   imageView.setFitHeight(height);
   imageView.setFitWidth(width);
 }
Exemplo n.º 14
0
 private void listFilesForFolder(final File folder) {
   for (final File fileEntry : folder.listFiles()) {
     if (fileEntry.isDirectory()) {
       listFilesForFolder(fileEntry);
     } else {
       Image img = new Image(fileEntry.toURI().toString());
       imgMan.images.add(
           new ImageInformation(
               img,
               fileEntry.toURI().toString(),
               new ImageInformation.Type[] {
                 ImageInformation.Type.SAND, ImageInformation.Type.FISH,
                 ImageInformation.Type.ALGA, ImageInformation.Type.CORAL,
                 ImageInformation.Type.SAND
               },
               new Point[] {
                 new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.25)),
                 new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.25)),
                 new Point((int) (img.getWidth() * 0.5), (int) (img.getHeight() * 0.5)),
                 new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.75)),
                 new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.75))
               },
               new double[] {0.86, 0.76, 0.99, 0.65, 0.54}));
     }
   }
 }
Exemplo n.º 15
0
  public Image toImage() {
    int width = (int) in.getWidth();
    int height = (int) in.getHeight();
    WritableImage out = new WritableImage(width, height);
    CashPixelReader cash = new CashPixelReader(in, pendingOperations.size());

    for (int i = 0; i < pendingOperations.size(); i++) {
      cash.setLevel(i);
      for (int x = 0; x < width; x++)
        for (int y = 0; y < height; y++) {
          Color c = in.getPixelReader().getColor(x, y);
          c = pendingOperations.get(i).apply(x, y, cash);
          out.getPixelWriter().setColor(x, y, c);
        }
      cash.setImage(out);
    }
    return out;
  }
  private VBox createImageQuestion(QuestionSubmit submit) {
    imageQuestionText.setText(submit.getQuestion());
    if (pictureForQuestion.containsKey(submit.getQuestionId())) {
      Image i = pictureForQuestion.get(submit.getQuestionId()).getImage();

      imageQuestionView.setImage(i);
      imageQuestionView.setFitWidth(i.getWidth());
      imageQuestionView.setFitHeight(i.getHeight());
    }

    if (answerForQuestion.containsKey(submit)) {
      imageAnswer.setText(answerForQuestion.get(submit).getAnswer());
    } else {
      imageAnswer.setText("");
    }

    return imageQuestionVbox;
  }
Exemplo n.º 17
0
  /**
   * Wrapper for usual method since JFX has no BufferedImage support.
   *
   * @param page
   * @param width
   * @param height
   * @return
   */
  @SuppressWarnings("deprecation")
  private Image getPageAsImage(int page, int width, int height) {

    BufferedImage img;
    try {
      img = pdf.getPageAsImage(page);

      // Use deprecated method since there's no real alternative
      if (Image.impl_isExternalFormatSupported(BufferedImage.class)) {
        return javafx.scene.image.Image.impl_fromExternalImage(img);
      }

    } catch (Exception e) {
      logger.error("Cannot display pdf", e);
      Dialog.showThrowable("Erreur", "Impossible d'afficher le pdf", e);
    }

    return null;
  }
Exemplo n.º 18
0
  @Override
  public void start(Stage stage) {

    stage.setTitle("Cursor");
    Group root = new Group(new Button("Hello"));
    Scene scene = new Scene(root, 300, 100);

    // Create a Cursor from a bitmap
    String urlString =
        getClass().getClassLoader().getResource("scene/Cursor/wow_cursor.gif").toExternalForm();

    /*
    Стаический метод cursor(String identifier) принимает или строку ссылки на изображение курсора,
    или строку стандартного курсора:
        DEFAULT, CROSSHAIR, TEXT, WAIT, OPEN_HAND, CLOSED_HAND,
        SW_RESIZE, SE_RESIZE, NW_RESIZE, NE_RESIZE, N_RESIZE, S_RESIZE, W_RESIZE, E_RESIZE,
    Если передаётся ссылка на изображение, то внутренне метод использует:
        new ImageCursor(new Image(identifier))
    Такой способ курсора требует более тонкой работы с изображением, потому что нельзя указать
    его активную область. В данном примере кнопка становится активной тогда, когда изображение
    касается её, но сам мечик, который далеко от края изображения, не касается кнопки.
    */
    Cursor cursor = Cursor.cursor(urlString);
    // scene.setCursor(cursor);

    // Get the WAIT standard cursor using its name
    Cursor waitCur = Cursor.cursor("WAIT");
    // scene.setCursor(waitCur);

    /*
    Если требуется более тонкая работа с курсором, то надо использовать класс ImageCursor.
    В отличие от Cursor ImageCursor позволяет задать позиционирование активной точки курсора
        ImageCursor(final Image image, double hotspotX, double hotspotY)
    */
    Image image = new Image(urlString);
    ImageCursor imageCursor =
        new ImageCursor(image, image.getWidth() / 2 - 10, image.getHeight() / 2 - 10);
    scene.setCursor(imageCursor);

    stage.setScene(scene);
    stage.show();
  }
Exemplo n.º 19
0
  public SpriteAnimation(ResourceLocator loc, String id, String url, int frames, int framerate)
      throws CorruptDataException {
    this.frames = frames;
    this.framerate = framerate;
    this.id = id;
    this.url = url;

    try {
      Image buffer = new Image(loc.gfx(url));
      hitTester = buffer.getPixelReader();
      hitW = (int) buffer.getWidth();
      hitH = (int) buffer.getHeight();

      double iw = buffer.getWidth() / ((double) frames);
      double ih = buffer.getHeight() / 4.0d;
      sf = GlobalConstants.TILEW / iw;
      w = (int) GlobalConstants.TILEW;
      h = (int) ((GlobalConstants.TILEW / iw) * ih);

      frameTextures = new Paint[frames * 4];
      for (int d = 0; d < 4; d++) {
        for (int f = 0; f < frames; f++) {
          frameTextures[(f * 4) + d] =
              new ImagePattern(buffer, -f * w, -d * h, frames * w, 4 * h, false);
        }
      }

    } catch (IOException e) {
      throw new CorruptDataException("Cannot locate resource " + url, e);
    }
  }
  public static int[][] convertImageTo2DIntArray(Image image, int width, int height) {

    int[][] returnArray = new int[height][width];

    // Obtain PixelReader
    PixelReader pixelReader = image.getPixelReader();

    int xSegmentLength = divideAByBThenRoundDown(image.getWidth(), width);
    int ySegmentLength = divideAByBThenRoundDown(image.getHeight(), height);

    BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null);

    for (int row = 0; row < height; row++) {

      for (int column = 0; column < width; column++) {

        BufferedImage tempBufferedImage =
            bufferedImage.getSubimage(
                xSegmentLength * column, ySegmentLength * row, xSegmentLength, ySegmentLength);

        Color averageColor =
            AverageColorFinder.findAverageColorFromImage(
                SwingFXUtils.toFXImage(tempBufferedImage, null));

        int argb =
            ((int) (averageColor.getOpacity() * 255) << 24)
                | ((int) (averageColor.getRed() * 255) << 16)
                | ((int) (averageColor.getGreen() * 255) << 8)
                | ((int) (averageColor.getBlue() * 255));

        returnArray[row][column] = argb;
      }
    }

    return returnArray;
  }
Exemplo n.º 21
0
  /**
   * Computes the actual scaling of an Image in an ImageView. If the preserveRatio property on the
   * ImageView is false the scaling has no meaning so NaN is returned.
   *
   * @return The scale factor of the image in relation to display coordinates
   */
  public double computeActualScale() {

    if (!imageView.isPreserveRatio()) {
      actualScale = Double.NaN;
    } else if (doScaleRecompute) {
      Image localImage = imageView.getImage();
      Rectangle2D localViewport = imageView.getViewport();

      double w = 0;
      double h = 0;
      if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) {
        w = localViewport.getWidth();
        h = localViewport.getHeight();
      } else if (localImage != null) {
        w = localImage.getWidth();
        h = localImage.getHeight();
      }

      double localFitWidth = imageView.getFitWidth();
      double localFitHeight = imageView.getFitHeight();

      if (w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
        if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
          w = w * localFitHeight / h;
        } else {
          w = localFitWidth;
        }

        actualScale = w / localImage.getWidth();
      }

      doScaleRecompute = false;
    }

    return actualScale;
  }
Exemplo n.º 22
0
  private static Cursor createCustomCursor(ImageCursorFrame cursorFrame) {
    Toolkit awtToolkit = Toolkit.getDefaultToolkit();

    double imageWidth = cursorFrame.getWidth();
    double imageHeight = cursorFrame.getHeight();
    Dimension nativeSize = awtToolkit.getBestCursorSize((int) imageWidth, (int) imageHeight);

    double scaledHotspotX = cursorFrame.getHotspotX() * nativeSize.getWidth() / imageWidth;
    double scaledHotspotY = cursorFrame.getHotspotY() * nativeSize.getHeight() / imageHeight;
    Point hotspot = new Point((int) scaledHotspotX, (int) scaledHotspotY);

    BufferedImage awtImage =
        SwingFXUtils.fromFXImage(
            Image.impl_fromPlatformImage(cursorFrame.getPlatformImage()), null);
    return awtToolkit.createCustomCursor(awtImage, hotspot, null);
  }
Exemplo n.º 23
0
 @FXML
 private void handleImportItemAction(ActionEvent event) {
   File fileLocation = new FileChooser().showOpenDialog(Main.stage);
   try (BufferedReader br = new BufferedReader(new FileReader(fileLocation))) {
     String line;
     while ((line = br.readLine()) != null) {
       final File folder = new File(line);
       if (folder.isDirectory()) {
         listFilesForFolder(folder);
       } else {
         Image img = new Image(folder.toURI().toString());
         imgMan.images.add(
             new ImageInformation(
                 img,
                 folder.toURI().toString(),
                 new ImageInformation.Type[] {
                   ImageInformation.Type.SAND, ImageInformation.Type.FISH,
                   ImageInformation.Type.ALGA, ImageInformation.Type.CORAL,
                   ImageInformation.Type.SAND
                 },
                 new Point[] {
                   new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.25)),
                   new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.25)),
                   new Point((int) (img.getWidth() * 0.5), (int) (img.getHeight() * 0.5)),
                   new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.75)),
                   new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.75))
                 },
                 new double[] {0.86, 0.76, 0.99, 0.65, 0.54}));
       }
     }
   } catch (FileNotFoundException e1) {
     e1.printStackTrace();
   } catch (IOException e1) {
     e1.printStackTrace();
   }
   imgMan.NextImage();
 }
Exemplo n.º 24
0
 /**
  * will trigger the view to render the one object
  *
  * @param obj the object to be rendered
  * @param state state data used for scaling, and keyframe animation info
  */
 public void displayModel(GameObject obj, RenderingState state) {
   Image model = graphicModel.getModel(obj.getModelID(), 0);
   double scaling = state.getScaleFactor(model.getWidth(), model.getHeight());
   gameView.drawmodel(model, obj.getX(), obj.getY(), scaling);
 }
Exemplo n.º 25
0
 private void refreshImageView(ImageResource resource) {
   Image image = resource.asNativeFormat();
   imageView.setImage(image);
   imageValuesLabel.setText(
       image.getWidth() + "×" + image.getHeight() + " | " + resource.getSize());
 }
 private void createImageView() {
   imageView = new ImageView();
   imageView.setImage(icon);
   imageView.setLayoutX((SIZE - icon.getWidth()) / PADDING);
   imageView.setLayoutY((SIZE - icon.getHeight()) / PADDING);
 }
Exemplo n.º 27
0
 private void load() {
   if (cash[level] == null) {
     cash[level] = in.getPixelReader();
   }
 }
Exemplo n.º 28
0
  /**
   * Tracks an object based on a known position in one frame and returns its most likely position in
   * the next frame
   *
   * @param position The position of the center of the object in the initial frame, with the origin
   *     in the upper left corner of the image
   * @param initialFrame The frame where the object was centered on initialPosition
   * @param nextFrame The next frame to find the object's position in
   * @return The most likely center position of the object in nextFrame
   * @throws IllegalArgumentException if either of the coordinates in initialPosition is negative,
   *     if the X coordinate of initialPosition is greater than or equal to the width of
   *     initialFrame, if the Y coordinate of initialPosition is greater than or equal to the height
   *     of initialFrame, or if initialFrame and nextFrame do not have the same width and height
   * @throws NullPointerException if any argument is null
   */
  public Point track(Point position, Image initialFrame, Image nextFrame) {
    if (position == null || initialFrame == null || nextFrame == null) {
      throw new NullPointerException("No argument may be null");
    }
    // Check frame dimensions
    if (initialFrame.getWidth() != nextFrame.getWidth()
        || initialFrame.getHeight() != nextFrame.getHeight()) {
      throw new IllegalArgumentException("Frames must have the same dimensions");
    }
    if (position.getX() < 0 || position.getX() >= initialFrame.getWidth()) {
      throw new IllegalArgumentException("Initial X coordinate out of range");
    }
    if (position.getY() < 0 || position.getY() >= initialFrame.getHeight()) {
      throw new IllegalArgumentException("Initial Y coordinate out of range");
    }

    final Rectangle initialRegion =
        new Rectangle(
            position.x - config.regionSize / 2,
            position.y - config.regionSize / 2,
            config.regionSize,
            config.regionSize);

    final long initialSum = brightnessSum(initialFrame, initialRegion);

    // Consider center points up to config.maxMovement pixels from
    // the initial position.
    // Define a search region. All integer points in or on the edge of this
    // rectangle are checked
    final Rectangle searchRegion =
        new Rectangle(
            position.x - config.maxMovement / 2,
            position.y - config.maxMovement / 2,
            config.maxMovement,
            config.maxMovement);

    // The smallest absolute value difference in brightness sum
    long minDeviation = Long.MAX_VALUE;
    // Most likely location
    Point bestPoint = null;

    for (int x = searchRegion.x; x <= searchRegion.x + searchRegion.width; x++) {
      for (int y = searchRegion.y; y <= searchRegion.y + searchRegion.height; y++) {
        final Rectangle nextFrameRegion =
            new Rectangle(
                x - config.maxMovement / 2,
                y - config.maxMovement / 2,
                config.maxMovement,
                config.maxMovement);

        final long sum = brightnessSum(nextFrame, nextFrameRegion);
        final long deviation = Math.abs(sum - initialSum);

        if (deviation < minDeviation) {
          minDeviation = deviation;
          bestPoint = new Point(x, y);
        }
      }
    }

    assert bestPoint != null;

    return bestPoint;
  }
Exemplo n.º 29
0
  public static void updateAge(int age) {
    double rate = xrate;
    if (yrate < xrate) rate = yrate;
    if (age == 1) {
      Image stageI = ResManager.getImage("ph1.png");
      stageLabel = new ImageView();
      stageLabel.setImage(stageI);
      stageLabel.setScaleX(rate);
      stageLabel.setScaleY(rate);
      stageLabel.setTranslateX((stageI.getWidth() * xrate - 134) / 2.0 + 15);
      stageLabel.setTranslateY((stageI.getHeight() * yrate - 128) / 2.0);
      stageLabel.toBack();
      background.toBack();
      mbg.root.getChildren().add(stageLabel);
      stageLabel.setX(0);
      stageLabel.setY(0);
      Timeline tl =
          new Timeline(
              new KeyFrame(
                  Duration.seconds(0),
                  new KeyValue(stageLabel.opacityProperty(), 0),
                  new KeyValue(stageLabel.scaleXProperty(), 0)),
              new KeyFrame(
                  Duration.seconds(1),
                  new KeyValue(stageLabel.opacityProperty(), 1),
                  new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT)));
      tl.play();
    } else if (age == 2) {
      GUIManager.bgMusic.stop();
      GUIManager.bgMusic = ResManager.getAudio("age2.mp3");
      GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE);
      GUIManager.bgMusic.setVolume(GUIManager.volumn);
      GUIManager.bgMusic.play();
      final Image stageII = ResManager.getImage("ph2.png");
      EventHandler<ActionEvent> act =
          new EventHandler<ActionEvent>() {
            public void handle(ActionEvent event) {
              stageLabel.setImage(stageII);
            }
          };
      Timeline tl =
          new Timeline(
              new KeyFrame(
                  Duration.seconds(1),
                  new KeyValue(stageLabel.opacityProperty(), 0),
                  new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)),
              new KeyFrame(Duration.seconds(1), act),
              new KeyFrame(
                  Duration.seconds(2),
                  new KeyValue(stageLabel.opacityProperty(), 1),
                  new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT)));
      tl.play();

    } else if (age == 3) {
      GUIManager.bgMusic.stop();
      GUIManager.bgMusic = ResManager.getAudio("age3.mp3");
      GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE);
      GUIManager.bgMusic.setVolume(GUIManager.volumn);
      GUIManager.bgMusic.play();
      final Image stageIII = ResManager.getImage("ph3.png");
      EventHandler<ActionEvent> act =
          new EventHandler<ActionEvent>() {
            public void handle(ActionEvent event) {
              stageLabel.setImage(stageIII);
            }
          };
      Timeline tl =
          new Timeline(
              new KeyFrame(
                  Duration.seconds(1),
                  new KeyValue(stageLabel.opacityProperty(), 0),
                  new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)),
              new KeyFrame(Duration.seconds(1), act),
              new KeyFrame(
                  Duration.seconds(2),
                  new KeyValue(stageLabel.opacityProperty(), 1),
                  new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT)));
      tl.play();
    }
  }
Exemplo n.º 30
0
  public void load() {

    age = 1;
    turn = 1;
    Manager.getKernel().startAge(1);
    boards = Manager.getKernel().getBoards();
    hands = Manager.getKernel().getHands();
    screenX = GUIManager.width; // get the width of the screen
    screenY = GUIManager.height; // get the height of the screen
    // root = new Group();
    scene = new Scene(root, screenX, screenY, GUIManager.bgColor);
    root.setCursor(new ImageCursor(GUIManager.cursor));
    R = screenX / 2.8; //
    r = screenY / 3.1; //
    Ox = screenX / 2 - 140; //
    Oy = screenY / 2 - 98; //
    numOfPlayers = boards.length; // get the amount of players
    moveable = false;
    isDragging = false;
    resList = new SimpleResList[numOfPlayers];
    isIncard = false;
    orListNum = new int[numOfPlayers];
    coins = new int[numOfPlayers];
    for (int i = 0; i < numOfPlayers; i++) coins[i] = 3;
    judgeStateTimeline = new Timeline[numOfPlayers];
    buyStateCircle = new Circle[numOfPlayers];
    // wonderBorderEffect = false;
    // wonderReflectEffect = false;
    if (!GUIManager.enableReflectionEffect) {
      Ox = screenX / 2 - 140; //
      Oy = screenY / 2 - 68;
      r = screenY / 3.5;
    }
    observeIndex = 0;
    isTwice = new boolean[numOfPlayers];
    // primaryStage.setResizable(false);
    for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
    handlerEnable = true;
    player = new Circle[numOfPlayers];
    wait = new Circle[numOfPlayers];
    // shop = new Circle[numOfPlayers];
    // look = new Circle[numOfPlayers];
    numOfCardGivenup = new Label();
    numOfCardGivenup.setVisible(true);
    CardsGivenup = 0;
    String s = String.valueOf(CardsGivenup);
    numOfCardGivenup.setText(s);
    numOfCardGivenup.setFont(Font.font("Arial", 45));

    if (GUIManager.enableGlowEffect) numOfCardGivenup.setEffect(new Glow());
    numOfCardGivenup.setTextFill(Color.web("#c88d15"));
    b = new Block(screenX, screenY);
    b.setVisible(false);
    root.getChildren().add(b);
    TPABoard.initialize();
    tpa = new TPABoard[numOfPlayers];

    final Paint[] color = new Paint[7];
    color[0] = Color.RED;
    color[1] = Color.ORANGE;
    color[2] = Color.YELLOW;
    color[3] = Color.YELLOWGREEN;
    color[4] = Color.GREEN;
    color[5] = Color.BLUE;
    color[6] = Color.PURPLE;
    for (int i = 0; i < 7; i++) {
      Paint temp = color[i];
      int newIndex = (int) (Math.random() * 7);
      color[i] = color[newIndex];
      color[newIndex] = temp;
    }

    playerBoard = new Group();
    // primaryStage.setFullScreen(true);
    // primaryStage.initStyle(StageStyle.UNDECORATED);
    Image bg = ResManager.getImage("bg.jpg");
    background = new ImageView(bg);
    if (!GUIManager.isFullScreen && !Manager.isApplet) this.setDragBackground(background);
    xrate = screenX / 1220.0;
    yrate = screenY / 784.0;
    background.setScaleX(xrate);
    background.setScaleY(yrate);
    numOfCardGivenup.setLayoutX(1106 * xrate);
    numOfCardGivenup.setLayoutY(94 * yrate);
    background.setTranslateX((scene.getWidth() - 1220.0) / 2.0);
    background.setTranslateY((scene.getHeight() - 784.0) / 2.0);
    // Rectangle clip = new Rectangle(0,0,1220,784);
    // clip.setArcHeight(50);
    // clip.setArcWidth(50);
    // background.setClip(clip);
    theta = Math.PI / 2;
    root.getChildren().add(background);
    root.getChildren().add(numOfCardGivenup);
    updateAge(1);

    Image im1 = ResManager.getImage("dir0.jpg");
    counterClockwise0 = new ImageView(im1);
    counterClockwise0.setScaleX(xrate);
    counterClockwise0.setScaleY(yrate);
    counterClockwise0.setTranslateX((im1.getWidth() * xrate - 107.0) / 2 + 271.23 * xrate);
    counterClockwise0.setTranslateY((im1.getHeight() * yrate - 86.0) / 2 + 560 * yrate);
    counterClockwise0.setVisible(false);

    Image im2 = ResManager.getImage("dir1.jpg");
    counterClockwise1 = new ImageView(im2);
    counterClockwise1.setScaleX(xrate);
    counterClockwise1.setScaleY(yrate);
    counterClockwise1.setTranslateX((im2.getWidth() * xrate - 112.0) / 2 + 826 * xrate);
    counterClockwise1.setTranslateY((im2.getHeight() * yrate - 86.0) / 2 + 560 * yrate);
    counterClockwise1.setVisible(false);

    Image im3 = ResManager.getImage("dir2.jpg");
    counterClockwise2 = new ImageView(im3);
    counterClockwise2.setScaleX(xrate);
    counterClockwise2.setScaleY(yrate);
    counterClockwise2.setTranslateX((im3.getWidth() * xrate - 52.0) / 2 + 846.4 * xrate);
    counterClockwise2.setTranslateY((im3.getHeight() * yrate - 39.0) / 2 + 223 * yrate);
    counterClockwise2.setVisible(false);

    Image im4 = ResManager.getImage("dir3.jpg");
    counterClockwise3 = new ImageView(im4);
    counterClockwise3.setScaleX(xrate);
    counterClockwise3.setScaleY(yrate);
    counterClockwise3.setTranslateX((im4.getWidth() * xrate - 52.0) / 2 + 302.6 * xrate);
    counterClockwise3.setTranslateY((im4.getHeight() * yrate - 39.0) / 2 + 222.8 * yrate);
    counterClockwise3.setVisible(false);
    root.getChildren().add(counterClockwise0);
    root.getChildren().add(counterClockwise1);
    root.getChildren().add(counterClockwise2);
    root.getChildren().add(counterClockwise3);

    Image[] image = new Image[numOfPlayers];
    wonder = new Wonders[numOfPlayers];
    Rectangle[] rec = new Rectangle[numOfPlayers];

    TreeMap<String, Integer> boardNameMap = new TreeMap<String, Integer>();
    boardNameMap.put("Rhodes", 0);
    boardNameMap.put("Alexandria", 1);
    boardNameMap.put("Ephesus", 2);
    boardNameMap.put("Babylon", 3);
    boardNameMap.put("Olympia", 4);
    boardNameMap.put("Halicarnassus", 5);
    boardNameMap.put("Giza", 6);

    TreeMap<String, Integer> resNameMap = new TreeMap<String, Integer>();
    // resNameMap.put("", value)

    for (int i = 0; i < numOfPlayers; i++) {
      // Manager.debug(boards[i].getResourceList());
      int ii = boardNameMap.get(boards[i].getName());
      if (boards[i].isBSide()) ii += 7;
      // Manager.debug("" + ii + boards[i].isBSide());
      image[i] = ResManager.getImage("board" + ii + ".jpg");
      // }
      rec[i] = new Rectangle(image[i].getWidth(), image[i].getHeight(), Color.TRANSPARENT);
      rec[i].setX(0);
      rec[i].setY(0);
      rec[i].setArcWidth(20);
      rec[i].setArcHeight(20);
      // if (i > 0) {
      rec[i].setStroke(color[i]);
      rec[i].setStrokeWidth(8);
      // } else {
      // MovingStroke.set(rec[i], (Color) color[i], 8.0, 20.0, 15.0, 0);
      // rec[i].setStroke(color[i]);
      // rec[i].setStrokeWidth(14);
      // }
      // tpa[i] = new TPABoard();
      if (GUIManager.enableLightingEffect) rec[i].setEffect(new Lighting());
      tpa[i] = new TPABoard();
      wonder[i] =
          new Wonders(
              image[i], screenX, screenY, GUIManager.enableReflectionEffect, ii, tpa[i], root);

      SimpleResList list = boards[i].getResourceList();
      for (int index = 1; index <= 7; index++) {
        for (int am = 0; am < list.numAt(index); am++) wonder[i].addResource(index);
        // Manager.debug(i + "Adding Res..." +
        // SimpleResList.resourceAt(index).toString());
      }
      wonder[i].addGoldSign(3);
      double percent = (workoutY1(Ox, Oy + r, i, numOfPlayers) - Oy + r) / (2 * r);
      wonder[i].setLayoutX(workoutX1(Ox, Oy + r, i, numOfPlayers) - (0.6 * percent + 0.4) * 160);
      wonder[i].setLayoutY(workoutY1(Ox, Oy + r, i, numOfPlayers) - (0.6 * percent + 0.4) * 90);
      wonder[i].setScaleX(0.6 * percent + 0.4);
      wonder[i].setScaleY(0.6 * percent + 0.4);
      wonder[i].getChildren().add(rec[i]);
      final int index = i;
      wonder[i].addEventHandler(
          MouseEvent.MOUSE_ENTERED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
              moveable = true;
              targetWonderIndex = index;
              for (int i = 0; i < numOfPlayers; i++) {
                Timeline tl =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0.3), new KeyValue(wonder[i].opacityProperty(), 1)));
                tl.play();
              }
            }
          });
      wonder[i].addEventHandler(
          MouseEvent.MOUSE_EXITED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
              if (!isDragging) moveable = false;
            }
          });

      wonder[i].getChildren().add(tpa[i]);
      tpa[i].setLayoutY(-80);
      tpa[i].setLayoutX(65);
      tpa[i].setScaleX(1 / (0.6 * percent + 0.4));
      tpa[i].setScaleY(1 / (0.6 * percent + 0.4));
    }

    dicClockwise();
    bigCircle = new Group();
    bigCircle
        .getChildren()
        .add(
            MovingStroke.set(
                new Circle(29, Color.web("white", 0)),
                Color.web("white", 0.7),
                6,
                5,
                10,
                0.3 * (age != 2 ? -1 : 1)));

    // bigCircle.setStroke(Color.web("white", 0.3));
    if (GUIManager.enableLightingEffect) bigCircle.setEffect(new Lighting());
    // bigCircle.setStrokeWidth(4);
    playerBoard.getChildren().add(bigCircle);

    for (int i = 0; i < numOfPlayers; i++) {
      wait[i] = new Circle(8);
      wait[i].setFill(color[i]);
      // look[i] = new Circle(4);
      // look[i].setFill(color[i]);
      // shop[i] = new Circle(5, Color.web("white", 0));
      // shop[i].setStroke(color[i]);
      // shop[i].setStrokeWidth(4);
      player[i] = wait[i];
      player[i].setVisible(true);
      if (GUIManager.enableLightingEffect) player[i].setEffect(new Lighting());
      player[i].setLayoutX(xForPlayer(i));
      player[i].setLayoutY(yForPlayer(i));
      player[i].addEventHandler(
          MouseEvent.MOUSE_ENTERED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent e) {
              // show the information of the players
            }
          });
      final int i1 = i;
      player[i].addEventHandler(
          MouseEvent.MOUSE_CLICKED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent e) {
              if (!isTwice[i1]) {
                if (remable) {
                  remable = false;
                }
                isTwice[i1] = true;
                for (int i = 0; i < numOfPlayers; i++) if (i != i1) isTwice[i] = false;
                handlerEnable = true;
                EventHandler<ActionEvent> act1 =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        wonder[signrec].hideInfo();
                      }
                    };
                EventHandler<ActionEvent> act2 =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        b.setVisible(false);
                        // cardBoard.toFront();
                        player[i1].setDisable(false);
                      }
                    };
                Timeline pre_tl =
                    new Timeline(
                        new KeyFrame(Duration.ZERO, act1),
                        new KeyFrame(
                            Duration.seconds(0.3),
                            new KeyValue(b.opacityProperty(), 0.7),
                            new KeyValue(cardBoard.layoutYProperty(), screenY - 105)),
                        new KeyFrame(Duration.seconds(0.6), new KeyValue(b.opacityProperty(), 0)),
                        new KeyFrame(Duration.seconds(0.6), act2));
                if (b.isVisible()) {
                  player[i1].setDisable(true);
                  pre_tl.play();
                }
                double[] forsort = new double[numOfPlayers];
                int[] sign = new int[numOfPlayers];
                for (int j = 0; j < numOfPlayers; j++) {
                  double percent = (workoutY1(Ox, Oy + r, j - i1, numOfPlayers) - Oy + r) / (2 * r);
                  Timeline tl =
                      new Timeline(
                          new KeyFrame(
                              Duration.seconds(0.3),
                              new KeyValue(
                                  wonder[j].layoutXProperty(),
                                  workoutX1(Ox, Oy + r, j - i1, numOfPlayers)
                                      - (0.6 * percent + 0.4) * 160),
                              new KeyValue(
                                  wonder[j].layoutYProperty(),
                                  workoutY1(Ox, Oy + r, j - i1, numOfPlayers)
                                      - (0.6 * percent + 0.4) * 90),
                              new KeyValue(tpa[j].scaleXProperty(), 1 / (0.6 * percent + 0.4)),
                              new KeyValue(tpa[j].scaleYProperty(), 1 / (0.6 * percent + 0.4)),
                              new KeyValue(wonder[j].scaleXProperty(), (0.6 * percent + 0.4)),
                              new KeyValue(wonder[j].scaleYProperty(), (0.6 * percent + 0.4))));
                  // wonder[j].setLayoutX();
                  // wonder[j].setLayoutY();
                  // tpa[j].setScaleX();
                  // tpa[j].setScaleY();
                  // wonder[j].setScaleX();
                  // wonder[j].setScaleY();
                  // Path path = new Path();
                  // Manager.debug(wonder[j].getLayoutX() +
                  // ":" +
                  // wonder[j].getLayoutY() + " " +
                  // wonder[j].getTranslateX() + ":" +
                  // wonder[j].getTranslateY());
                  // double x = wonder[j].getLayoutX();
                  // double y = wonder[j].getLayoutY();
                  // path.getElements().addAll(new
                  // MoveTo(screenX/2,screenY/2),
                  // new ArcTo(R/2,r/2,0,workoutX1(Ox, Oy + r,
                  // j - i1,
                  // numOfPlayers) - x, workoutY1(Ox, Oy + r,
                  // j - i1,
                  // numOfPlayers) - y,true,true)
                  // );
                  // path.setStroke(color[j]);
                  // path.setStrokeWidth(10);
                  // root.getChildren().add(path);
                  // PathTransition pt = new
                  // PathTransition(Duration.seconds(8),path,wonder[j]);
                  //
                  // pt.setCycleCount(PathTransition.INDEFINITE);
                  // pt.setAutoReverse(true);
                  // pt.play();

                  tl.play();
                  forsort[j] = wonder[j].getLayoutY();
                  sign[j] = j;
                }
                // wonder[i1].toFront();
                for (int i = 0; i < numOfPlayers - 1; i++) {
                  for (int j = 0; j < numOfPlayers - i - 1; j++) {
                    if (forsort[j] > forsort[j + 1]) {
                      double temp = forsort[j + 1];
                      forsort[j + 1] = forsort[j];
                      forsort[j] = temp;
                      int temp1 = sign[j + 1];
                      sign[j + 1] = sign[j];
                      sign[j] = temp1;
                    }
                  }
                }
                for (int i = 0; i < numOfPlayers; i++) {
                  if (sign[i] == i1) {

                    b.toFront();
                  }
                  wonder[sign[i]].toFront();
                }
                // if(!b.isVisible())
                cardBoard.toFront();
                playerBoard.toFront();
                // turn the wonderBoard
                if (Manager.getKernel().isReplayMode()) {
                  int index = 0;
                  if (age == 2) index = (2 * numOfPlayers - turn + i1 + 1) % numOfPlayers;
                  else index = (turn + i1 - 1) % numOfPlayers;
                  handCard.changeRole(boards[i1], hands[index]);
                  observeIndex = i1;
                }
              } else {
                EventHandler<ActionEvent> act =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        wonder[i1].showInfo();
                        remable = true;
                        signrec = i1;
                        playerBoard.toFront();
                        // show the game information of player
                      }
                    };
                for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
                b.setOpacity(0);
                b.toFront();
                playerBoard.toFront();
                wonder[i1].toFront();
                b.setVisible(true);

                handlerEnable = false;
                Timeline tl =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0.3),
                            new KeyValue(b.opacityProperty(), 0.7),
                            new KeyValue(cardBoard.layoutYProperty(), screenY)),
                        new KeyFrame(Duration.seconds(0.3), act));
                tl.play();
              }
              theta = Math.PI / 2 - 2 * Math.PI / numOfPlayers * i1;
            }
          });
      playerBoard.getChildren().add(player[i]);
      judgeStateTimeline[i] =
          new Timeline(
              new KeyFrame(Duration.seconds(0.3), new KeyValue(player[i].opacityProperty(), 0)));
      judgeStateTimeline[i].setCycleCount(Timeline.INDEFINITE);
      judgeStateTimeline[i].setAutoReverse(true);
      buyStateCircle[i] =
          (Circle)
              MovingStroke.set(
                  new Circle(xForPlayer(i), yForPlayer(i), 11, Color.TRANSPARENT),
                  Color.GOLDENROD,
                  3,
                  3,
                  4,
                  0.3);
      playerBoard.getChildren().add(buyStateCircle[i]);
      buyStateCircle[i].setVisible(false);
    }
    buy = new BuyBoard();
    buy.setScaleX(0.7);
    buy.setScaleY(0.7);
    buy.setLayoutY(0);
    buy.setVisible(false);
    root.getChildren().add(buy);
    CardGroup.initializeData(screenX, buy, boards[0]);
    handCard = new CardGroup();
    handCard.setplayer(wonder[0]);
    for (int i = 0; i < numOfPlayers; i++) {
      resList[i] = new SimpleResList(boards[i].getResourceList());
    }
    /*
     * primaryStage.addEventHandler(WindowEvent.RESIZE, new
     * EventHandler<MouseEvent>(){
     *
     * @Override public void handle(MouseEvent event) {
     * System.out.println("OK");
     *
     * }
     *
     * }); primaryStage.
     */

    scene.addEventHandler(
        MouseEvent.MOUSE_PRESSED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (handlerEnable && moveable) {
              double x = e.getX(), y = e.getY();
              double tana = (y - Oy) / (x - Ox) * R / r;
              beta = Math.atan(tana);
              if (x <= Ox) beta = beta + Math.PI;
            }
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_RELEASED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            isDragging = false;
            if (handlerEnable && moveable) theta = alpha - beta + theta;
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_DRAGGED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            isDragging = true;
            if (handlerEnable && moveable) {
              for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
              double x = e.getX() - 70, y = e.getY();
              double[] forsort = new double[numOfPlayers];
              int[] sign = new int[numOfPlayers];
              for (int i = 0; i < numOfPlayers; i++) {
                // int index = (i +
                // numOfPlayers+targetWonderIndex+1) %
                // numOfPlayers;
                int index = i;
                double percent = (workoutY(x, y, i, numOfPlayers) - Oy + r) / (2 * r);
                tpa[index].setScaleX(1 / (0.6 * percent + 0.4));
                tpa[index].setScaleY(1 / (0.6 * percent + 0.4));
                wonder[index].setScaleX((0.6 * percent + 0.4));
                wonder[index].setScaleY((0.6 * percent + 0.4));
                wonder[index].setLayoutX(
                    workoutX(x, y, i, numOfPlayers) - (0.6 * percent + 0.4) * 160);
                wonder[index].setLayoutY(
                    workoutY(x, y, i, numOfPlayers) - (0.6 * percent + 0.4) * 90);
                forsort[i] = wonder[i].getLayoutY();
                sign[i] = i;
              }
              for (int i = 0; i < numOfPlayers - 1; i++) {
                for (int j = 0; j < numOfPlayers - i - 1; j++) {
                  if (forsort[j] > forsort[j + 1]) {
                    double temp = forsort[j + 1];
                    forsort[j + 1] = forsort[j];
                    forsort[j] = temp;
                    int temp1 = sign[j + 1];
                    sign[j + 1] = sign[j];
                    sign[j] = temp1;
                  }
                }
              }
              for (int i = 0; i < numOfPlayers; i++) wonder[sign[i]].toFront();
              playerBoard.toFront();
              cardBoard.toFront();
            }
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_ENTERED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (handlerEnable) {
              double y = e.getX();
              // if( y > screenY - 牌宽)
              // 牌.show();
            }
          }
        });
    switch (numOfPlayers) {
      case 3:
        root.getChildren().add(wonder[2]);
        break;
      case 4:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        break;
      case 5:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        break;
      case 6:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        root.getChildren().add(wonder[5]);
        break;
      case 7:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        root.getChildren().add(wonder[5]);
        root.getChildren().add(wonder[6]);
    }

    root.getChildren().add(wonder[1]);
    root.getChildren().add(wonder[0]);

    playerBoard.setLayoutX(scene.getWidth() - 60);
    playerBoard.setLayoutY(50);
    root.getChildren().add(playerBoard);
    handCard.nextHand(hands[0], true);
    cardBoard = new Group();
    cardBoard.getChildren().add(handCard);
    root.getChildren().add(cardBoard);
    cardBoard.setLayoutX(0);
    cardBoard.setLayoutY(screenY - 105);
    cardBoard.addEventHandler(
        MouseEvent.MOUSE_ENTERED,
        new EventHandler<MouseEvent>() {

          public void handle(MouseEvent e) {
            if (wonderFadeTimeline != null)
              for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.stop();
            wonderFadeTimeline = new Timeline[numOfPlayers];
            wonderFadeTimeline[observeIndex] =
                new Timeline(
                    new KeyFrame(
                        Duration.seconds(0.1),
                        new KeyValue(cardBoard.layoutYProperty(), screenY - 270)));
            for (int i = 0; i < numOfPlayers; i++) {
              if (i == observeIndex) continue;
              if (wonder[i].getOpacity() > 0.99)
                wonderFadeTimeline[i] =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0), new KeyValue(wonder[i].opacityProperty(), 1)),
                        new KeyFrame(
                            Duration.seconds(1.5), new KeyValue(wonder[i].opacityProperty(), 1)),
                        new KeyFrame(
                            Duration.seconds(2),
                            new KeyValue(
                                wonder[i].opacityProperty(),
                                i == (1 + observeIndex) % numOfPlayers
                                        || i == (numOfPlayers - 1 + observeIndex) % numOfPlayers
                                    ? 0.65
                                    : 0.35,
                                Interpolator.EASE_IN)));
            }
            for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.play();

            cardBoard.toFront();
            isIncard = true;
          }
        });
    cardBoard.addEventHandler(
        MouseEvent.MOUSE_EXITED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (wonderFadeTimeline != null)
              for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.stop();
            wonderFadeTimeline = new Timeline[numOfPlayers];
            wonderFadeTimeline[0] =
                new Timeline(
                    new KeyFrame(
                        Duration.seconds(0.15),
                        new KeyValue(cardBoard.layoutYProperty(), screenY - 105)));
            for (int i = 1; i < numOfPlayers; i++) {
              if (wonder[i].getOpacity() < 0.99)
                wonderFadeTimeline[i] =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0), new KeyValue(wonder[i].opacityProperty(), 0.5)),
                        new KeyFrame(
                            Duration.seconds(0.3), new KeyValue(wonder[i].opacityProperty(), 1)));
            }
            for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.play();
            isIncard = true;
          }
        });
    this.exitDialog = Index.loadExitGameDialog(root);
    root.getChildren().add(new GameMenu());

    // For Test
    for (int i = 0; i < numOfPlayers; i++) {
      updatePlayerState(i, 1);
    }
    // ScoreBoard sb = new ScoreBoard(boards);
    // root.getChildren().add(sb);
    // JOptionPane.showMessageDialog(null,
    // boards[0].getLeftNeighbor().getName() + ""
    // +boards[0].getRightNeighbor().getName());
    if (Manager.getKernel().isReplayMode()) {
      // Button nextBtn = new Button("Next!");
      // nextBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
      // @Override
      // public void handle(MouseEvent event) {
      // nextTurn();
      // }
      // });
      // root.getChildren().add(nextBtn);
      root.getChildren().add(replayControl = new ReplayControl());
    }
  }