示例#1
0
  private final void defineStretching() {
    //////////// give resizing hints
    ObservableList<RowConstraints> rows = getRowConstraints();
    logger.info("original row constraints size" + rows.size());

    RowConstraints rc;

    rc = new RowConstraints();
    // rc.setPercentHeight( 0 );
    rc.setVgrow(Priority.NEVER);
    rc.setMinHeight(StaticConst.GU);
    rows.add(rc);
    rc = new RowConstraints();
    // rc.setPercentHeight( 100 );
    rc.setVgrow(Priority.ALWAYS);
    rows.add(rc);
    rc = new RowConstraints();
    // rc.setPercentHeight( 0 );
    rc.setVgrow(Priority.NEVER);
    rows.add(rc);

    ObservableList<ColumnConstraints> ccs = getColumnConstraints();
    logger.info("original column constraints size" + ccs.size());
    ColumnConstraints cc;

    cc = new ColumnConstraints();
    cc.setHgrow(Priority.ALWAYS);
    ccs.add(cc);
  }
示例#2
0
  private GridPane getNewGrid() {
    GridPane grid = new GridPane();
    grid.setVgap(10);
    grid.setHgap(5);
    // grid.setGridLinesVisible(true);
    grid.paddingProperty().set(new Insets(5));

    // GridPane.setVgrow(grid, Priority.ALWAYS);
    // grid.setMinWidth(500);

    ColumnConstraints col = new ColumnConstraints();

    col.setMinWidth(10);
    col.setHgrow(Priority.SOMETIMES);
    col.setFillWidth(true);

    // col.setPercentWidth(1);
    col.setPrefWidth(100);

    grid.getColumnConstraints().addAll(col, col);

    // ------

    RowConstraints row1 = new RowConstraints();
    RowConstraints row2 = new RowConstraints();

    row1.setMinHeight(10);
    row1.setVgrow(Priority.SOMETIMES);
    row1.setFillHeight(true);
    row1.setPrefHeight(30);

    row2.setMinHeight(10);
    row2.setVgrow(Priority.SOMETIMES);
    row2.setFillHeight(true);
    row2.setValignment(VPos.CENTER);

    grid.getRowConstraints().addAll(row1, row2);

    // ColumnConstraints c = new ColumnConstraints();
    // c.setHgrow(Priority.SOMETIMES);
    // c.setMaxWidth(173.0);
    // c.setMinWidth(10.0);
    // c.setPrefWidth(124.0);
    // grid.getColumnConstraints().add(c);

    // c = new ColumnConstraints();
    // c.setHalignment(HPos.RIGHT);
    // c.setHgrow(Priority.NEVER);
    // grid.getColumnConstraints().add(c);

    // RowConstraints r = new RowConstraints();
    // r.setVgrow(Priority.NEVER);
    // grid.getRowConstraints().add(r);

    return grid;
  }
示例#3
0
文件: View.java 项目: jimmor/whale
 public <T extends Field> T addField(String fieldName, T field) {
   Validate.notNull(field);
   field.setName(fieldName);
   final String caption = AnnotationUtils.getFieldCaption(MODEL_CLASS, fieldName);
   final RowConstraints row = new RowConstraints();
   row.setFillHeight(Boolean.TRUE);
   row.setValignment(VPos.TOP);
   getGridPane().getRowConstraints().addAll(row);
   getGridPane()
       .addRow(
           getController().getFields().size(),
           new Label(caption),
           getController().registerField(field, fieldName).getUI());
   return field;
 }
  public final void initCanvas(int cols, int rows) {
    this.currentPad = 0;
    this.canvasPads.clear();
    this.getChildren().clear();

    double widthFactor = 1.0 / cols;
    double heightFactor = 1.0 / rows;

    GridPane grid = new GridPane();

    for (int c = 0; c < cols; c++) {
      for (int r = 0; r < rows; r++) {
        TEmbeddedPad pad = new TEmbeddedPad();
        this.canvasPads.add(pad);
        pad.widthProperty().bind(this.widthProperty().multiply(widthFactor));
        pad.heightProperty().bind(this.heightProperty().multiply(heightFactor));
        grid.add(pad, c, r);
      }
    }

    ColumnConstraints cc = new ColumnConstraints();
    // cc1.setPercentWidth(50);
    cc.setHgrow(Priority.ALWAYS);
    cc.setFillWidth(true);
    for (int c = 0; c < cols; c++) {
      grid.getColumnConstraints().add(cc);
    }

    RowConstraints rc = new RowConstraints();
    rc.setFillHeight(true);
    rc.setVgrow(Priority.ALWAYS);
    for (int r = 0; r < rows; r++) {
      grid.getRowConstraints().add(rc);
    }

    this.getChildren().add(grid);
    // grid.prefWidthProperty().bind(this.widthProperty());
    // grid.prefHeightProperty().bind(this.heightProperty());
    // GridPane grid = new GridPane();
    // pad.widthProperty().bind(this.widthProperty());
    // pad.heightProperty().bind(this.heightProperty());

  }
示例#5
0
  /** Sets the FX constraints. */
  private void setConstraints() {

    // Column 1 has empty constraints.
    this.getColumnConstraints().add(new ColumnConstraints());

    // Column 2 should grow to fill space.
    ColumnConstraints column2 = new ColumnConstraints();
    column2.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(column2);

    // Rows 1-4 have empty constraints.
    this.getRowConstraints().add(new RowConstraints());
    this.getRowConstraints().add(new RowConstraints());
    this.getRowConstraints().add(new RowConstraints());
    this.getRowConstraints().add(new RowConstraints());

    // Row 5 should
    RowConstraints row5 = new RowConstraints();
    row5.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row5);
  }
  public GridPaneSample() {

    VBox vbox = new VBox();

    // grid1 places the child by specifying the rows and columns in
    // GridPane.setContraints()
    Label grid1Caption =
        new Label(
            "The example below shows GridPane content placement by specifying rows and columns:");
    grid1Caption.setWrapText(true);
    GridPane grid1 = new GridPane();
    grid1.setHgap(4);
    grid1.setVgap(6);
    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    Label label = new Label("Name:");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("John Q. Public");
    GridPane.setConstraints(label, 1, 0, 2, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    label = new Label("Address:");
    GridPane.setConstraints(label, 0, 1);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("12345 Main Street, Some City, CA");
    GridPane.setConstraints(label, 1, 1, 5, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    vbox.getChildren().addAll(grid1Caption, grid1, new Separator());

    // grid2 places the child by influencing the rows and columns themselves
    // via GridRowInfo and GridColumnInfo. This grid uses the preferred
    // width/height and max/min width/height.
    Label grid2Caption =
        new Label(
            "The example below shows GridPane content placement by influencing the rows and columns themselves.");
    grid2Caption.setWrapText(true);
    grid2Caption.setWrapText(true);
    GridPane grid2 = new GridPane();
    grid2.setPadding(new Insets(18, 18, 18, 18));
    RowConstraints rowinfo = new RowConstraints(40, 40, 40);
    ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90);

    for (int i = 0; i <= 2; i++) {
      grid2.getRowConstraints().add(rowinfo);
    }

    for (int j = 0; j <= 2; j++) {
      grid2.getColumnConstraints().add(colinfo);
    }

    Label category = new Label("Category:");
    GridPane.setHalignment(category, HPos.RIGHT);
    Label categoryValue = new Label("Wines");
    Label company = new Label("Company:");
    GridPane.setHalignment(company, HPos.RIGHT);
    Label companyValue = new Label("Acme Winery");
    Label rating = new Label("Rating:");
    GridPane.setHalignment(rating, HPos.RIGHT);
    Label ratingValue = new Label("Excellent");

    ImageView imageView = new ImageView(ICON_48);
    GridPane.setHalignment(imageView, HPos.CENTER);

    // Place content
    GridPane.setConstraints(category, 0, 0);
    GridPane.setConstraints(categoryValue, 1, 0);
    GridPane.setConstraints(company, 0, 1);
    GridPane.setConstraints(companyValue, 1, 1);
    GridPane.setConstraints(imageView, 2, 1);
    GridPane.setConstraints(rating, 0, 2);
    GridPane.setConstraints(ratingValue, 1, 2);
    grid2
        .getChildren()
        .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue);

    vbox.getChildren().addAll(grid2Caption, grid2, new Separator());

    // grid3 places the child by influencing the rows and columns
    // via GridRowInfo and GridColumnInfo. This grid uses the percentages
    Label grid3Caption =
        new Label(
            "The example below shows GridPane content placement by influencing row and column percentages.  Also, grid lines are made visible in this example.  The lines can be helpful in debugging.");
    grid3Caption.setWrapText(true);
    GridPane grid3 = new GridPane();
    grid3.setPadding(new Insets(18, 18, 18, 18));
    grid3.setGridLinesVisible(true);
    RowConstraints rowinfo3 = new RowConstraints();
    rowinfo3.setPercentHeight(50);

    ColumnConstraints colInfo2 = new ColumnConstraints();
    colInfo2.setPercentWidth(25);

    ColumnConstraints colInfo3 = new ColumnConstraints();
    colInfo3.setPercentWidth(50);

    grid3.getRowConstraints().add(rowinfo3); // 2*50 percent
    grid3.getRowConstraints().add(rowinfo3);

    grid3.getColumnConstraints().add(colInfo2); // 25 percent
    grid3.getColumnConstraints().add(colInfo3); // 50 percent
    grid3.getColumnConstraints().add(colInfo2); // 25 percent

    Label condLabel = new Label(" Member Name:");
    GridPane.setHalignment(condLabel, HPos.RIGHT);
    GridPane.setConstraints(condLabel, 0, 0);
    Label condValue = new Label("MyName");
    GridPane.setMargin(condValue, new Insets(0, 0, 0, 10));
    GridPane.setConstraints(condValue, 1, 0);

    Label acctLabel = new Label("Member Number:");
    GridPane.setHalignment(acctLabel, HPos.RIGHT);
    GridPane.setConstraints(acctLabel, 0, 1);
    TextField textBox = new TextField("Your number");
    GridPane.setMargin(textBox, new Insets(10, 10, 10, 10));
    GridPane.setConstraints(textBox, 1, 1);

    Button button = new Button("Help");
    GridPane.setConstraints(button, 2, 1);
    GridPane.setMargin(button, new Insets(10, 10, 10, 10));
    GridPane.setHalignment(button, HPos.CENTER);

    GridPane.setConstraints(condValue, 1, 0);
    grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox);

    vbox.getChildren().addAll(grid3Caption, grid3);

    getChildren().add(vbox);
  }
    public JavaFXJeopardyBoardViz(Object pane) {

      mainBoardPane = (StackPane) pane;
      mainBoardPane.getChildren().clear();

      // Create and add children of mainBoardPane
      gridPane = new GridPane();
      gridPane.setHgap(10);
      gridPane.setVgap(10);
      questionText = new Button("");
      mainBoardPane.getChildren().addAll(gridPane, questionText);

      gridPane.toString();

      questionText.setMaxWidth(Double.MAX_VALUE);
      questionText.setMaxHeight(Double.MAX_VALUE);
      questionText.setWrapText(true);
      questionText.setTextAlignment(TextAlignment.CENTER);
      questionText.setStyle(
          "-fx-text-fill: white; -fx-font-size: 36px; -fx-font-weight: bold; -fx-background-color: #0000FF;");
      questionText.setVisible(false);

      // Set the columns to be equal sizes in the grid
      for (int col = 1; col <= 6; col++) {
        ColumnConstraints colConstraint = new ColumnConstraints();
        colConstraint.setPercentWidth(100 / 6);
        gridPane.getColumnConstraints().add(colConstraint);
      }

      // Set the rows to be equal sizes in the grid
      RowConstraints rowConstraint = new RowConstraints();
      rowConstraint.setPercentHeight(12);
      gridPane.getRowConstraints().add(rowConstraint);
      for (int row = 1; row <= 5; row++) {
        rowConstraint = new RowConstraints();
        rowConstraint.setPercentHeight(88 / 5);
        gridPane.getRowConstraints().add(rowConstraint);
      }

      categoryButtons = new Button[6];

      itemButtons = new Button[5][6];

      // Add buttons for category titles
      for (int categoryIndex = 0; categoryIndex <= 5; categoryIndex++) {
        categoryButtons[categoryIndex] = new Button(categories.get(categoryIndex).getName());
        categoryButtons[categoryIndex].setMaxWidth(Double.MAX_VALUE);
        categoryButtons[categoryIndex].setMaxHeight(Double.MAX_VALUE);
        categoryButtons[categoryIndex].setWrapText(true);
        categoryButtons[categoryIndex].setTextAlignment(TextAlignment.CENTER);
        categoryButtons[categoryIndex].setStyle(
            "-fx-text-fill: white; -fx-font-size: 14px; -fx-font-weight: bold; -fx-background-color: #0000FF;");
        // categoryButtons[categoryIndex].setFont(new Font("Arial Narrow", 14px));
        gridPane.add(categoryButtons[categoryIndex], categoryIndex, 0);

        // Add buttons for BoardItems
        for (int itemIndex = 0; itemIndex <= 4; itemIndex++) {
          itemButtons[itemIndex][categoryIndex] =
              new JeopardyItemButton(categories.get(categoryIndex).getBoardItem(itemIndex));
          itemButtons[itemIndex][categoryIndex].setMaxWidth(Double.MAX_VALUE);
          itemButtons[itemIndex][categoryIndex].setMaxHeight(Double.MAX_VALUE);
          itemButtons[itemIndex][categoryIndex].setStyle(
              "-fx-text-fill: gold; -fx-font-size: 24px; -fx-font-weight: bold; -fx-background-color: #0000FF;");
          gridPane.add(itemButtons[itemIndex][categoryIndex], categoryIndex, itemIndex + 1);
          categories
              .get(categoryIndex)
              .getBoardItem(itemIndex)
              .setViz(itemButtons[itemIndex][categoryIndex]);
        }
      }
    }
  public PlongeeSimpleView() {
    MN90.getLogger().debug(this, "Construction de la vue PlongeeSimple");
    // this.setGridLinesVisible(MN90.AFFICHAGE_GRILLE);
    this.setGridLinesVisible(true);

    ColumnConstraints col = new ColumnConstraints();
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(90);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);
    // col.setPercentWidth(5);
    col.setHgrow(Priority.ALWAYS);
    this.getColumnConstraints().add(col);

    RowConstraints row = new RowConstraints();
    // row.setPercentHeight(90);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    // row.setPercentHeight(90);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);
    row.setVgrow(Priority.ALWAYS);
    this.getRowConstraints().add(row);

    mImgView.setImage(mImgPlongeeFond);
    mImgView.setFitWidth(100);
    mImgView.setManaged(true);
    mImgView.setPreserveRatio(true);
    mImgView.setSmooth(true);
    mImgView.setCache(true);
    this.add(mImgView, 0, 1, 13, 8);

    this.add(mHeureDepartLabel, 0, 0);

    mHeureDepartValue.setPrefWidth(100);
    mHeureDepartValue.setMaxWidth(100);
    mHeureDepartValue.setMinWidth(100);
    this.add(mHeureDepartValue, 1, 0, 2, 1);

    this.add(mProfMaxLabel, 2, 8);

    mProfMaxValue.setPrefWidth(45);
    mProfMaxValue.setMaxWidth(45);
    mProfMaxValue.setMinWidth(45);
    this.add(mProfMaxValue, 3, 8);

    this.add(mHeureSortieLabel, 10, 0);

    mHeureSortieValue.setPrefWidth(100);
    mHeureSortieValue.setMaxWidth(100);
    mHeureSortieValue.setMinWidth(100);
    this.add(mHeureSortieValue, 11, 0, 2, 1);

    this.add(mDureePlongeeLabel, 2, 7);

    mDureePlongeeValue.setPrefWidth(45);
    mDureePlongeeValue.setMaxWidth(45);
    mDureePlongeeValue.setMinWidth(45);
    this.add(mDureePlongeeValue, 3, 7);

    this.add(mPalier3mLabel, 11, 2);

    mDureePalier3mValue.setPrefWidth(50);
    mDureePalier3mValue.setMaxWidth(50);
    mDureePalier3mValue.setMinWidth(50);
    this.add(mDureePalier3mValue, 11, 3);

    this.add(mDTRLabel, 10, 8);

    mDTRValue.setPrefWidth(50);
    mDTRValue.setMaxWidth(50);
    mDTRValue.setMinWidth(50);
    this.add(mDTRValue, 11, 8);

    this.add(mGPSLabel, 10, 7);

    mGPSValue.setPrefWidth(50);
    mGPSValue.setMaxWidth(50);
    mGPSValue.setMinWidth(50);
    this.add(mGPSValue, 11, 7);
  }