public ProcessingAnimationView(
      ProcessingAnimationModel
          animationModel) { // ProcessingAnimationModel animationModel, MachineTestController
                            // testController) {
    this.processingAnimationModel = animationModel;
    //        this.machineTestController = testController;

    imageViewTop = new ImageView();
    imageViewTop.setFitWidth(270);
    imageViewTop.setFitHeight(100);
    imageViewTop.setX(200);
    imgTop = new Image("file:Image\\animation\\presTop.png");
    imageViewTop.setImage(imgTop);

    imageViewBot = new ImageView();
    imageViewBot.setTranslateY(40);
    imageViewBot.setFitWidth(270);
    imageViewBot.setFitHeight(300);
    imgBot = new Image("file:Image\\animation\\presBot.png");
    imageViewBot.setPreserveRatio(true);
    imageViewBot.setX(200);
    imageViewBot.setImage(imgBot);

    Image imgStorage = new Image("file:Image\\animation\\storage.png");
    imageViewLeftStorage = new ImageView();
    imageViewLeftStorage.setFitWidth(200);
    imageViewLeftStorage.setFitHeight(80);
    imageViewLeftStorage.setY(185);
    imageViewLeftStorage.setImage(imgStorage);

    imageViewRightStorage = new ImageView();
    imageViewRightStorage.setFitWidth(200);
    imageViewRightStorage.setFitHeight(80);
    imageViewRightStorage.setY(185);
    imageViewRightStorage.setX(500);
    imageViewRightStorage.setImage(imgStorage);

    rectangle = new Rectangle(340, 185, 15, 5);
    //        rectangle.setVisible(false);
    rectangle.setFill(Color.CORAL);
    circle = new Circle(190, 180, 10);
    circle.setFill(Color.CORAL);

    this.getChildren()
        .addAll(
            imageViewLeftStorage,
            imageViewRightStorage,
            rectangle,
            circle,
            imageViewBot,
            imageViewTop);

    this.setMinSize(300, 300);

    timeline = new Timeline();
    transitionCircle = new TranslateTransition();
    transitionRect = new TranslateTransition();
    products = new Stack<>();
  }
Esempio n. 2
0
 /*
  * Resize the image, preserving the aspect ratio if only the height or width is provided, otherwise scale
  * based on the height and width provided.
  */
 private void resizeImage(ImageView imageView, Integer widthSize, Integer heightSize) {
   if (widthSize == null && heightSize != null) {
     iv1.setPreserveRatio(true);
     imageView.setFitHeight(heightSize);
   } else if (widthSize != null && heightSize == null) {
     iv1.setPreserveRatio(true);
     imageView.setFitWidth(widthSize);
   } else {
     imageView.setFitWidth(widthSize);
     imageView.setFitHeight(heightSize);
   }
 }
 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);
 }
Esempio n. 4
0
  public void addImageTab(Path imagePath) {

    TabPane previewTabPane = controller.getPreviewTabPane();

    ImageTab tab = new ImageTab();
    tab.setPath(imagePath);
    tab.setText(imagePath.getFileName().toString());

    if (previewTabPane.getTabs().contains(tab)) {
      previewTabPane.getSelectionModel().select(tab);
      return;
    }

    Image image = new Image(IOHelper.pathToUrl(imagePath));
    ImageView imageView = new ImageView(image);
    imageView.setPreserveRatio(true);

    imageView.setFitWidth(previewTabPane.getWidth());

    previewTabPane
        .widthProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              imageView.setFitWidth(previewTabPane.getWidth());
            });

    Tooltip tip = new Tooltip(imagePath.toString());
    Tooltip.install(tab.getGraphic(), tip);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setContent(imageView);
    scrollPane.addEventFilter(
        ScrollEvent.SCROLL,
        e -> {
          if (e.isControlDown() && e.getDeltaY() > 0) {
            // zoom in
            imageView.setFitWidth(imageView.getFitWidth() + 16.0);
          } else if (e.isControlDown() && e.getDeltaY() < 0) {
            // zoom out
            imageView.setFitWidth(imageView.getFitWidth() - 16.0);
          }
        });

    tab.setContent(scrollPane);

    TabPane tabPane = previewTabPane;
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }
Esempio n. 5
0
  // wyœwietla wszystkie albumy
  private void drawAlbums() {
    for (int i = 0; i < albumList.size(); i++) {
      VBox vBox = new VBox(5);

      // ok³adka albumu
      Song tempSong = new Song(albumList.get(i).albumSongList.get(0));
      ImageView albumCover = new ImageView(tempSong.getAlbumCover());
      albumCover.setFitWidth(130);
      albumCover.setPreserveRatio(true);
      albumCover.setSmooth(true);
      albumCover.imageProperty().bind(tempSong.albumCoverProperty());

      // tytu³ albumu
      Text albumTitle = new Text(albumList.get(i).getAlbumTitle());
      albumTitle.getStyleClass().add("text");
      vBox.getChildren().addAll(albumCover, albumTitle);
      vBox.setAlignment(Pos.CENTER);

      // dodaje do ka¿dego albumu listener którym otwiera listê z piosenkami
      vBox.setOnMouseClicked(
          e -> {
            Text tempText = (Text) vBox.getChildren().get(1);
            for (int j = 0; j < albumList.size(); j++) {
              if (albumList.get(j).getAlbumTitle().equals(tempText.getText())) {
                showCurrentAlbum(albumList.get(j));
                break;
              }
            }
          });

      flowPane.getChildren().add(vBox);
    }
  }
Esempio n. 6
0
  // wyœwietla wszystkie playlisty
  private void drawPlaylists() {
    for (int i = 0; i < playlistList.size(); i++) {
      VBox vBox = new VBox(5);

      ImageView playlistCover =
          new ImageView(new Image(new File("temp_cover.png").toURI().toString()));
      playlistCover.setFitWidth(130);
      playlistCover.setPreserveRatio(true);
      playlistCover.setSmooth(true);

      int ext = playlistList.get(i).getName().lastIndexOf('.');
      Text playlistTitle = new Text(playlistList.get(i).getName().substring(0, ext));
      playlistTitle.getStyleClass().add("text");
      vBox.getChildren().addAll(playlistCover, playlistTitle);
      vBox.setAlignment(Pos.CENTER);

      vBox.setOnMouseClicked(
          e -> {
            Text tempText = (Text) vBox.getChildren().get(1);
            showCurrentPlaylist(new File("Playlists/" + tempText.getText() + ".fpl"));
          });

      flowPane.getChildren().add(vBox);
    }
  }
Esempio n. 7
0
  public void openImageFile(Resource resource) {
    Tab tab = new Tab();
    tab.setClosable(true);
    if (resource == null) {
      Dialogs.create()
          .owner(tabPane)
          .title("Datei nicht vorhanden")
          .message(
              "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.")
          .showError();
      return;
    }
    tab.setText(resource.getFileName());

    ImageResource imageResource = (ImageResource) resource;
    ImageViewerPane pane = new ImageViewerPane();
    pane.setImageResource(imageResource);

    ImageView imageView = pane.getImageView();
    imageView.setImage(imageResource.asNativeFormat());
    imageView.setFitHeight(-1);
    imageView.setFitWidth(-1);

    Label imagePropertiesLabel = pane.getImagePropertiesLabel();
    imagePropertiesLabel.setText(imageResource.getImageDescription());

    tab.setContent(pane);
    tab.setUserData(resource);
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }
  @SuppressWarnings("JavadocMethod")
  public ProjectSettingsEditor(
      Parent root, ProjectSettings projectSettings, AppSettings appSettings) {
    super();

    VBox content =
        new VBox(
            new CustomPropertySheet(BeanPropertyUtils.getProperties(projectSettings)),
            new Separator(),
            new CustomPropertySheet(BeanPropertyUtils.getProperties(appSettings)));
    content.setSpacing(5.0);

    DialogPane pane = getDialogPane();
    pane.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);
    pane.setContent(content);
    pane.styleProperty().bind(root.styleProperty());
    pane.getStylesheets().addAll(root.getStylesheets());
    pane.setPrefSize(DPIUtility.SETTINGS_DIALOG_SIZE, DPIUtility.SETTINGS_DIALOG_SIZE);

    ImageView graphic =
        new ImageView(new Image(getClass().getResourceAsStream("icons/settings.png")));
    graphic.setFitWidth(DPIUtility.SMALL_ICON_SIZE);
    graphic.setFitHeight(DPIUtility.SMALL_ICON_SIZE);

    setTitle("Settings");
    setHeaderText("Settings");
    setGraphic(graphic);
    setResizable(true);
  }
Esempio n. 9
0
 private void configureButton(final ImageView imageView) {
   imageView.setFitHeight(32);
   imageView.setFitWidth(32);
   imageView.setPreserveRatio(true);
   imageView.setSmooth(true);
   imageView.getStyleClass().add("launcherIcon");
 }
Esempio n. 10
0
 public ImageView getIcon() {
   Image image = FileFetch.getImageFromFile("pin56_small.svg", 22, 22, true, true);
   ImageView imageView = new ImageView(image);
   imageView.setFitHeight(22);
   imageView.setFitWidth(22);
   return imageView;
 }
Esempio n. 11
0
  private ImageView createDropboxIconView() {
    Image dropboxIcon = new Image(dropboxIconPath);
    ImageView dropboxIconView = new ImageView(dropboxIcon);
    dropboxIconView.setFitWidth(imageWidth);
    dropboxIconView.setFitHeight(imageHeight);

    return dropboxIconView;
  }
  private void instanciateWidgets() {

    eventHandler = new DocumentConfigurationScreenEventHandler(this);

    btnAddFromFS = new Button(properties.getProperty("add_from_hard_drive"));
    btnAddFromFS.setPrefSize(300, 80);
    btnAddFromFS.setOnAction(eventHandler);

    Image i = new Image(getClass().getResourceAsStream(properties.getProperty("ico_library_root")));
    ImageView iv = new ImageView(i);
    iv.setSmooth(true);
    iv.setFitWidth(64);
    iv.setFitHeight(64);
    btnAddFromFS.setGraphic(iv);

    btnAddFromScanner = new Button(properties.getProperty("add_scan"));
    btnAddFromScanner.setPrefSize(300, 80);
    btnAddFromScanner.setOnAction(eventHandler);

    Image i2 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_scan")));
    ImageView iv2 = new ImageView(i2);
    iv2.setSmooth(true);
    iv2.setFitWidth(64);
    iv2.setFitHeight(64);
    btnAddFromScanner.setGraphic(iv2);

    docInfoEditor = new DocumentInfoEditor();
    docInfoEditor.getEventHandler().addDocumentInfoEditorListener(eventHandler);

    btnSubmit = new Button(properties.getProperty("save"));
    btnSubmit.setPrefSize(250, 80);
    btnSubmit.setOnAction(eventHandler);

    Image i3 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_save")));
    ImageView iv3 = new ImageView(i3);
    iv3.setSmooth(true);
    iv3.setFitWidth(64);
    iv3.setFitHeight(64);
    btnSubmit.setGraphic(iv3);

    btnSubmit.setDisable(true);

    documentPreviewer = new DocumentPreviewer(this);
    documentPreviewer.getEventHandler().addDocumentPreviewListener(eventHandler);
    documentPreviewer.setEditionMode(true);
  }
 private void gamePicture() throws FileNotFoundException {
   ImageView coloredBoxImg =
       new ImageView(new Image(new FileInputStream("lib/" + selectedGame + ".png")));
   coloredBoxImg.setFitHeight(gamePicture.getPrefHeight() - 25);
   coloredBoxImg.setFitWidth(gamePicture.getPrefWidth() - 25);
   gamePicture.setGraphic(coloredBoxImg);
   gamePicture.setStyle(buttonStyle);
 }
 /**
  * Method to configure the {@link ButtonBase} size and graphic to use the {@link Image} in a
  * consistent style for toolbox buttons.
  *
  * @param button the {@link ButtonBase} to configure.
  * @param image the {@link Image} to apply.
  */
 public void styleButtonSize(ButtonBase button, Image image) {
   ImageView view = new ImageView(image);
   view.setFitHeight(BUTTON_WIDTH);
   view.setFitWidth(BUTTON_HEIGHT);
   button.setGraphic(view);
   button.setPrefSize(BUTTON_WIDTH, BUTTON_HEIGHT);
   button.setMaxWidth(BUTTON_WIDTH);
   button.setMaxHeight(BUTTON_HEIGHT);
   button.setAlignment(Pos.CENTER);
 } // End Method
Esempio n. 15
0
    private BuddyCell() {
      iconLabel = new ImageView();
      iconLabel.setFitHeight(20);
      iconLabel.setFitWidth(20);
      getChildren().add(iconLabel);

      nameLabel = new Label();
      nameLabel.setMaxWidth(Double.MAX_VALUE);
      HBox.setHgrow(nameLabel, Priority.ALWAYS);
      getChildren().add(nameLabel);

      onlineCheckBox = new CheckBox();
      getChildren().add(onlineCheckBox);
    }
Esempio n. 16
0
  /**
   * Update the GUI to show a specified page.
   *
   * @param page
   */
  private void showPage(int page) {

    // Check in range
    if (page > pdf.getPageCount()) {
      return;
    }
    if (page < 1) {
      return;
    }

    // Store
    pageNumber = page;

    // Show/hide buttons as neccessary
    if (page == pdf.getPageCount()) {
      next.setVisible(false);
    } else {
      next.setVisible(true);
    }

    if (page == 1) {
      back.setVisible(false);
    } else {
      back.setVisible(true);
    }

    // Calculate scale
    int pW = pdf.getPdfPageData().getCropBoxWidth(page);
    int pH = pdf.getPdfPageData().getCropBoxHeight(page);

    Dimension s = Toolkit.getDefaultToolkit().getScreenSize();
    s.setSize(maxSize.getWidth(), maxSize.getHeight());

    double xScale = (double) s.width / pW;
    double yScale = (double) s.height / pH;
    double scale = xScale < yScale ? xScale : yScale;

    // Work out target size
    pW *= scale;
    pH *= scale;

    // Get image and set
    Image i = getPageAsImage(page, pW, pH);
    imageView.setImage(i);

    // Set size of components
    imageView.setFitWidth(pW);
    imageView.setFitHeight(pH);
  }
Esempio n. 17
0
  // wyœwietla wszystkie piosenki w postaci listy
  private void drawAllFiles() {
    ObservableList<Song> allSongs = FXCollections.observableArrayList();
    for (File file : fileList) {
      allSongs.add(new Song(file.getAbsolutePath()));
    }
    // obrazek
    ImageView allFilesCover =
        new ImageView(new Image(new File("allfiles_cover.jpg").toURI().toString()));
    allFilesCover.setFitWidth(700);
    allFilesCover.setFitHeight(200);
    allFilesCover.setSmooth(true);
    flowPane.getChildren().add(allFilesCover);

    loadSongs(allSongs);
  }
  private void markNodeAsInvalid(Node node) {
    TreeItem<Node> invalidItem = findItem(node);

    if (invalidItem != null) {
      ImageView exclaimImage = new ImageView("/images/red_exclamation.png");
      exclaimImage.setFitHeight(20);
      exclaimImage.setFitWidth(5);

      Tooltip exclaimTooltip =
          new Tooltip(TextFactory.getText(Labels.LabelKey.PROPERTY_MISSING_LABEL));
      Tooltip.install(exclaimImage, exclaimTooltip);

      invalidItem.setGraphic(exclaimImage);
    }
  }
Esempio n. 19
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);
 }
  @Override
  public boolean update() {
    int speed = 1;
    if (myImageView.getFitWidth() <= 300) {
      myImageView.setVisible(true);
      myImageView.setFitHeight(myImageView.getFitHeight() + speed);
      myImageView.relocate(
          myWidth / 2 - myImageView.getFitWidth() / 2,
          myHeight / 2 - myImageView.getFitHeight() / 2);
      myImageView.setFitWidth(myImageView.getFitWidth() + speed);
      myImageView.setRotate(myImageView.getRotate() + speed);
    } else if (myImageView.getRotate() <= 360) {
      myImageView.setRotate(myImageView.getRotate() + speed);
    }

    return (myImageView.getFitHeight() <= 300 || myImageView.getRotate() <= 300);
  }
Esempio n. 21
0
 private Icon(String s, int xOffset, int numberOfIcons) {
   xmlList = ConfigManager.getStringList(ConfigManager.scope(s, "xmlList"));
   Image img =
       new Image(
           getClass()
               .getClassLoader()
               .getResourceAsStream(ConfigManager.getString(ConfigManager.scope(s, "image"))));
   image = new ImageView(img);
   image.setFitWidth(WIDTH / (numberOfIcons * 3 / 2));
   image.setPreserveRatio(true);
   image.setSmooth(true);
   image.setCache(true);
   setGraphic(image);
   setLayoutY(
       ConfigManager.getInt(ConfigManager.scope(this.getClass().getName(), "yPos"), HEIGHT / 3));
   setLayoutX(xOffset - (image.getBoundsInParent().getWidth() + 18) / 2);
   iconName = s;
 }
  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;
  }
Esempio n. 23
0
  public void refreshImageViewer(Resource resourceToUpdate) {
    List<Tab> tabs = tabPane.getTabs();
    for (Tab tab : tabs) {
      Resource resource = (Resource) tab.getUserData();
      if (resourceToUpdate.equals(resource)) {
        ImageResource imageResource = (ImageResource) resourceToUpdate;
        logger.info("refreshing image resource");
        ImageViewerPane imageViewerPane = (ImageViewerPane) tab.getContent();
        ImageView imageView = imageViewerPane.getImageView();
        imageView.setImage(imageResource.asNativeFormat());
        imageView.setFitHeight(-1);
        imageView.setFitWidth(-1);

        Label imagePropertiesLabel = imageViewerPane.getImagePropertiesLabel();
        imagePropertiesLabel.setText(imageResource.getImageDescription());
      }
    }
  }
Esempio n. 24
0
  // pokazuje wybran¹ playliste
  private void showCurrentPlaylist(File playlistFile) {
    flowPane.getChildren().clear();

    // ok³adka playlisty
    ImageView playlistCover =
        new ImageView(new Image(new File("temp_cover.png").toURI().toString()));
    playlistCover.setFitWidth(200);
    playlistCover.setPreserveRatio(true);
    playlistCover.setSmooth(true);
    // nazwa playlisty
    int ext = playlistFile.getName().lastIndexOf('.');
    Text playlistTitle = new Text(playlistFile.getName().substring(0, ext));
    playlistTitle.setFont(new Font("Segoe UI Light", 20));
    playlistTitle.setFill(Paint.valueOf("WHITE"));
    VBox playlistData = new VBox(playlistCover, playlistTitle);

    flowPane.getChildren().add(playlistData);
    loadSongs(Playlist.loadPlaylist(playlistFile));
  }
Esempio n. 25
0
  // pokazuje piosenki wybranego albumu
  private void showCurrentAlbum(Album album) {
    flowPane.getChildren().clear();

    Song tempSong = album.getSongs().get(0);
    // ok³adka albumu
    ImageView albumCover = new ImageView(tempSong.getAlbumCover());
    albumCover.imageProperty().bind(tempSong.albumCoverProperty());
    albumCover.setFitWidth(200);
    albumCover.setPreserveRatio(true);
    // tytu³ albumu
    Text albumTitle = new Text(tempSong.getAlbum());
    albumTitle.textProperty().bind(tempSong.albumProperty());
    albumTitle.setFont(new Font("Segoe UI Light", 20));
    albumTitle.setFill(Paint.valueOf("WHITE"));
    // VBox zawieraj¹cy ok³adkê i tytu³
    VBox albumData = new VBox(albumCover, albumTitle);
    flowPane.getChildren().addAll(albumData);

    loadSongs(album.getSongs());
  }
  @Override
  public void resizeNode(double width, double height) {
    MN90.getLogger().debug(this, "Changement de taille : " + width + " - " + height);
    double widthForFit = width > height ? width : height;
    for (int i = 0; i < this.getColumnConstraints().size(); i++) {
      double value = 5;
      if (i == 1) {
        value = 10;
      }
      this.getColumnConstraints().get(i).setPercentWidth(value);
    }

    for (int i = 0; i < this.getRowConstraints().size(); i++) {
      double value = 5;
      if (i == 0) {
        value = 5;
      }
      this.getRowConstraints().get(i).setPercentHeight(value);
    }
    if (mImgView.getFitWidth() != widthForFit) mImgView.setFitWidth(widthForFit);
  }
  /**
   * Instantiates the tileSet images using an image selected by the user. Given the number of rows
   * that the user input at the program startup, this automatically calculates the positions of the
   * individual tile images, and sets the tileSize for all tiles.
   *
   * <p>Note: tiles must be designed to be squares.
   *
   * @param file The image file containing what will be the map tiles
   */
  public void openTileSet(File file) {
    try {
      origTileImage = ImageIO.read(file);
      tileSize = (int) origTileImage.getHeight() / numTileRows;
      // Minus 1 because tileSet matrix starts at index 0
      numTileColumns = (int) origTileImage.getWidth() / tileSize;
      tileSet = new BufferedImage[numTileRows][numTileColumns];
      for (int row = 0; row < numTileRows; row++) {
        for (int col = 0; col < numTileColumns; col++) {
          tileSet[row][col] =
              origTileImage.getSubimage(col * tileSize, row * tileSize, tileSize, tileSize);
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    // add tileSet to tileMap so that it is shown on screen
    for (int i = 0; i < numTileRows; i++) {
      for (int j = 0; j < numTileColumns; j++) {
        Image image = SwingFXUtils.toFXImage(tileSet[i][j], null);
        ImageView imageView = new ImageView(image);
        imageView.setX(j * tileSize);
        imageView.setY(i * tileSize);
        imageView.setFitWidth(tileSize);
        imageView.setFitHeight(tileSize);
        tileMap.getChildren().add(imageView);
      }
    }
    // Make the first tile selected
    currentTile = 0;
    double tx = ((ImageView) tileMap.getChildren().get(0)).getX();
    double ty = ((ImageView) tileMap.getChildren().get(0)).getY();
    double tw = ((ImageView) tileMap.getChildren().get(0)).getFitWidth();
    double th = ((ImageView) tileMap.getChildren().get(0)).getFitHeight();
    tileOutline = new Rectangle(tx, ty, tw, th);
    tileOutline.setStroke(Color.RED);
    tileOutline.setFill(null);
    tileMap.getChildren().add(tileOutline);
  }
  /**
   * Loads a map from file: converts the values from the passed int matrix into images given by the
   * tileSet. The value in the map is the tile number. The matrix is passed to this method by {@code
   * loadMap()} in the KeyPressedListener class.
   *
   * @param oldMap int matrix holding tile numbers that correspond to a specific tile.
   */
  public void loadOldMap(int[][] oldMap) {
    constructedMap.getChildren().clear();
    mapX = tileSize;
    mapY = tileSize;
    mapW = oldMap[0].length;
    mapH = oldMap.length;
    mapOutline.setX(mapX);
    mapOutline.setY(mapY);
    mapOutline.setWidth(mapW * tileSize);
    mapOutline.setHeight(mapH * tileSize);
    map = new int[mapH][mapW];

    for (int row = 0; row < mapH; row++) {
      for (int col = 0; col < mapW; col++) {
        currentTile = map[row][col] = oldMap[row][col];

        // Get the right tile from tileSet
        int tileRow = (int) currentTile / numTileColumns;
        int tileCol = currentTile % numTileColumns;

        // Get the right image
        Image image = SwingFXUtils.toFXImage(tileSet[tileRow][tileCol], null);
        ImageView imageView = new ImageView(image);

        // Add the selected tile to the screen
        double imageX = mapOutline.getX() + col * tileSize;
        double imageY = mapOutline.getY() + row * tileSize;
        imageView.setX(imageX);
        imageView.setY(imageY);
        imageView.setFitWidth(tileSize);
        imageView.setFitHeight(tileSize);
        updateConstructedMap(imageView);
      }
    }

    currentTile = 0;
    updateCurrentTile();
  }
Esempio n. 29
0
  @Override
  public void start(Stage primaryStage) {

    keyPressedLed on = new keyPressedLed();
    double height = 300.0;
    double width = 300.0;

    primaryStage.setTitle("Logitech");
    primaryStage.setResizable(false);

    Image g = new Image("g.png");
    ImageView gt = new ImageView();
    gt.setImage(g);
    gt.setFitWidth(300);
    gt.setPreserveRatio(true);
    gt.setSmooth(true);
    gt.setCache(true);

    Text txtr = new Text();
    txtr.setId("txtr");
    txtr.setText("Red Percentage");

    Text txtg = new Text();
    txtg.setId("txtg");
    txtg.setText("Green Percentage");

    Text txtb = new Text();
    txtb.setId("txtb");
    txtb.setText("Blue Percentage");

    ScrollBar sct = new ScrollBar(); // 2
    int val_o = (int) sct.getValue();
    sct.setMin(0);
    sct.setMax(100);

    ScrollBar scth = new ScrollBar(); // 3
    int val_t = (int) scth.getValue();
    scth.setMin(0);
    scth.setMax(100);

    ScrollBar sc = new ScrollBar(); // 1
    int val_th = (int) sc.getValue();
    sc.setMin(0);
    sc.setMax(100);

    Button btn = new Button();
    Button btnt = new Button();
    btn.setText("Stop Effects");
    btn.setText("Launch Keyboard lights");
    btnt.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {}
        });
    btn.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            on.start();
          }
        });

    sc.valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                setRed((int) sc.getValue());
                // red = (int) sc.getValue();

                System.out.println(getRed());
              }
            });

    sct.valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                int val = (int) sct.getValue();
                System.out.println(val);
              }
            });

    scth.valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                int val = (int) scth.getValue();
                System.out.println(val);
              }
            });

    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            on.interrupt();
          }
        });

    AnchorPane root = new AnchorPane();

    root.getChildren().add(btn);
    root.getChildren().add(sc);
    root.getChildren().add(sct);
    root.getChildren().add(scth);
    root.getChildren().addAll(txtr, txtg, txtb, gt);

    root.setLeftAnchor(btn, 75.0); // Button1
    root.setBottomAnchor(btn, 10.0);

    root.setTopAnchor(sc, 10.0); // Scroll1
    root.setLeftAnchor(sc, 110.0);

    root.setTopAnchor(sct, 25.0); // Scroll 2
    root.setLeftAnchor(sct, 110.0);

    root.setTopAnchor(scth, 40.0); // Scroll 3
    root.setLeftAnchor(scth, 110.0);

    root.setTopAnchor(txtr, 10.0);
    root.setLeftAnchor(txtr, 5.0); // Text red

    root.setTopAnchor(txtg, 25.0);
    root.setLeftAnchor(txtg, 4.0); // text Green

    root.setTopAnchor(txtb, 40.0); // Text Blue
    root.setLeftAnchor(txtb, 5.0);

    root.setTopAnchor(gt, 80.0);

    Scene set = new Scene(root, width, height);
    set.getStylesheets().add("style.css");
    primaryStage.setScene(set);

    primaryStage.show();
  }
Esempio n. 30
0
 @FXML
 public void loadGame(ActionEvent event) {
   Stage newStage = new Stage();
   if (event.getSource() == loadButton) {
     loadData = LoadSaveGame.load();
     if (loadData != null) {
       Controller.loaded = true;
       GameController.numPasses = (int) Controller.loadData.get(4);
       // GameController.landButton.setDisable(true);
       try {
         gameRoot = FXMLLoader.load(getClass().getResource("UIFiles/MainMap.fxml"));
         gameScene = new Scene(gameRoot);
         Parent startWindow = FXMLLoader.load(getClass().getResource("UIFiles/playerStart.fxml"));
         startScene = new Scene(startWindow);
       } catch (IOException e) {
         e.printStackTrace();
       }
       newStage.setScene(gameScene);
       newStage.setTitle("Game Screen");
       newStage.show();
       GridPane grid = (GridPane) gameRoot;
       landPlots = (Land[][]) loadData.get(0);
       level = (String) loadData.get(1);
       players = (Player[]) loadData.get(3);
       for (Player player : players) {
         for (Land land : player.getLandOwned()) {
           landPlots[land.getCol()][land.getRow()].setOwner(player);
         }
       }
       if (grid != null) {
         for (Land[] landArray : landPlots) {
           for (Land land : landArray) {
             if (land.isOwned()) {
               Player owner = land.getOwner();
               Rectangle color = new Rectangle();
               color.setFill(Color.valueOf(owner.getColor()));
               color.setHeight(25);
               color.setWidth(25);
               color.setOpacity(1);
               GridPane.setHalignment(color, HPos.LEFT);
               GridPane.setValignment(color, VPos.TOP);
               grid.add(color, land.getCol(), land.getRow());
               if (land.hasMule()) {
                 Image mulePic = new Image("gameConfig/UIFiles/Media/aMule.png");
                 ImageView muleView = new ImageView();
                 muleView.setImage(mulePic);
                 muleView.setFitWidth(50);
                 muleView.setPreserveRatio(true);
                 GridPane.setHalignment(muleView, HPos.LEFT);
                 GridPane.setValignment(muleView, VPos.CENTER);
                 muleView.setId(String.valueOf(land.getCol()) + String.valueOf(land.getRow()));
                 grid.add(muleView, land.getCol(), land.getRow());
               }
             }
           }
         }
       }
       numPlayer = players.length;
       Turns turns = new Turns(players);
       turns.setRounds((int) loadData.get(5));
       GameController.beginTurn();
     } else {
       Controller.loaded = false;
     }
   }
 }