예제 #1
0
 /** Sets the events for each label in the grid. */
 private void setEvents() {
   for (Label label : labels) {
     label.setOnMouseClicked(
         event -> {
           int index = gridPane.getRowIndex(label);
           chosenPlugin[0] = plugins.get(index).get(0);
           curIndex = index;
           chosenPlugin[1] = plugins.get(index).get(1);
           chosenPreview = preview.get(index).get(0);
           description = appData.get(index).get(1);
           goToNextScreen("/fxml/PluginInfo.fxml");
         });
   }
   for (ImageView image : iconsView) {
     image.setOnMouseClicked(
         event -> {
           int index = gridPane.getRowIndex(image);
           chosenPlugin[0] = plugins.get(index).get(0);
           curIndex = index;
           chosenPlugin[1] = plugins.get(index).get(1);
           chosenPreview = preview.get(index).get(0);
           description = appData.get(index).get(1);
           goToNextScreen("/fxml/PluginInfo.fxml");
         });
   }
 }
예제 #2
0
 public static void removeRowsFromGridPane(GridPane gridPane, int fromGridRow, int toGridRow) {
   Set<Node> nodes = new CopyOnWriteArraySet<>(gridPane.getChildren());
   nodes
       .stream()
       .filter(e -> GridPane.getRowIndex(e) >= fromGridRow && GridPane.getRowIndex(e) <= toGridRow)
       .forEach(e -> gridPane.getChildren().remove(e));
 }
예제 #3
0
 private static Node ruutLaual(
     GridPane kasutjaRuudustik, int rida, int veerg) { // gridpaneist vastava ruudu tuvastamine
   for (Node node : kasutjaRuudustik.getChildren()) {
     if (GridPane.getColumnIndex(node) == veerg && GridPane.getRowIndex(node) == rida) {
       return node;
     }
   }
   return null;
 }
 /**
  * Gets the Node at a given location in the GridPane
  *
  * @param row the row (y-coordinate) where to get the Node
  * @param column the column (x-coordinate) where to get the Node
  * @param gridPane the GridPane to get a Node from
  * @return the Node at that given location from the GridPane
  */
 private Node getNodeFromIndex(int row, int column, GridPane gridPane) {
   Node result = null;
   ObservableList<Node> childrens = gridPane.getChildren();
   for (Node node : childrens) {
     if (gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) {
       result = node;
       break;
     }
   }
   return result;
 }
예제 #5
0
 private int getRowCount(GridPane pane) {
   int numRows = pane.getRowConstraints().size();
   for (int i = 0; i < pane.getChildren().size(); i++) {
     Node child = pane.getChildren().get(i);
     if (child.isManaged()) {
       Integer rowIndex = GridPane.getRowIndex(child);
       if (rowIndex != null) {
         numRows = Math.max(numRows, rowIndex + 1);
       }
     }
   }
   return numRows;
 }
예제 #6
0
  public void reactOnMouseClick(
      GridPane grid,
      String[] listOfImageAsk,
      Image imgYes,
      Image imgNo,
      ImageView imageViewSourceRef) {
    System.out.println("Level Factor is " + levelFactor);
    String id = imageViewSourceRef.getId();
    System.out.println(id);
    int columnIndex = grid.getColumnIndex(imageViewSourceRef);
    int rowIndex = grid.getRowIndex(imageViewSourceRef);

    if (ifTheRightPictureClicked(id, listOfImageAsk)) {
      grid.add(new ImageView(imgYes), columnIndex, rowIndex);
      correctImageCounter = correctImageCounter + 1;
      System.out.println("Correct image counter is " + correctImageCounter);
      if (correctImageCounter == levelFactor) {
        levelSuccess();
      }
    } else wrongImageClicked(grid, imgNo, columnIndex, rowIndex);
  }
  public void redrawMacroGridPane() {

    // Remove all nodes except first row
    ObservableList<Node> children = macroGridPane.getChildren();
    for (ListIterator<Node> iter = children.listIterator(); iter.hasNext(); ) {
      Node node = iter.next();
      if (GridPane.getRowIndex(node) != 0) {
        iter.remove();
      }
    }

    // Repopulate GridPane with macro rows
    for (Macro macro : terminal.txRx.macroManager.macros) {

      MacroRow macroRow = new MacroRow(model, terminal, macro, glyphFont);
      macroGridPane.addRow(
          GridPaneHelper.getNumRows(macroGridPane),
          macroRow.nameTextField,
          macroRow.sequenceTextField,
          macroRow.runButton);
    }
  }
예제 #8
0
  public void showPersonOverview() {
    try {
      // Load person overview.
      FXMLLoader loader1 = new FXMLLoader();
      loader1.setLocation(ChessFx.class.getResource("view/javafx/ChessBoard.fxml"));
      GridPane chessBoard = loader1.load();
      chessBoard.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

      for (Node node : chessBoard.getChildren()) {
        Integer x = GridPane.getRowIndex(node);
        Integer y = GridPane.getColumnIndex(node);
        int row = x == null ? 0 : x;
        int col = y == null ? 0 : y;
        if (node instanceof Pane) {
          node.setId("pane" + row + "_" + col);
        }
        row = 8 - row - 1;

        if ((row + col) % 2 == 1) {
          node.setStyle("-fx-background-color: rgb(255,255,255);");
        } else {
          node.setStyle("-fx-background-color: rgb(128,128,128);");
        }

        if (row == 1) {
          ImageView img =
              new ImageView(new Image(ChessFx.class.getResourceAsStream("view/images/bpawn.png")));
          if (node instanceof Pane) {
            ((Pane) node).getChildren().add(img);
          }
        } else if (row == 6) {
          ImageView img =
              new ImageView(new Image(ChessFx.class.getResourceAsStream("view/images/wpawn.png")));
          if (node instanceof Pane) {
            ((Pane) node).getChildren().add(img);
          }
        } else if (row == 0) {
          if (col == 0 || col == 7) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/brook.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 1 || col == 6) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/bknight.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 2 || col == 5) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/bbishop.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 4) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/bking.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 3) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/bqueen.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          }

        } else if (row == 7) {
          if (col == 0 || col == 7) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/wrook.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 1 || col == 6) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/wknight.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 2 || col == 5) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/wbishop.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 4) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/wking.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          } else if (col == 3) {
            ImageView img =
                new ImageView(
                    new Image(ChessFx.class.getResourceAsStream("view/images/wqueen.png")));
            if (node instanceof Pane) {
              ((Pane) node).getChildren().add(img);
            }
          }
        } else {
          ImageView img = new ImageView();
          if (node instanceof Pane) {
            ((Pane) node).getChildren().add(img);
          }
        }
      }

      rootLayout.setCenter(chessBoard);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }