Esempio 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();
  }
Esempio n. 2
0
 protected void setImageViewTile(int visibleX, int visibleY, int tileIndex) {
   ImageView view = getImageView(visibleX, visibleY);
   if (tileIndex >= 0) {
     view.setViewport(spritesheet.getViewport(tileIndex));
     view.setVisible(true);
   } else {
     view.setVisible(false);
   }
 }
Esempio n. 3
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
 protected void interpolate(double t) {
   final Rectangle2D viewport =
       new Rectangle2D(
           start.getMinX() + t * (end.getMinX() - start.getMinX()),
           start.getMinY() + t * (end.getMinY() - start.getMinY()),
           start.getWidth() + t * (end.getWidth() - start.getWidth()),
           start.getHeight() + t * (end.getHeight() - start.getHeight()));
   imageView.setViewport(viewport);
 }