Package javafx.scene.layout

Examples of javafx.scene.layout.VBox


        final Button btn = new Button();
        final Button open1 = new Button();
        final Button open2 = new Button();
        final Text route1 = new Text();
        final Text route2 = new Text();
        final VBox vBox = new VBox();

        open1.setText("Open first file");
        open1.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                File file = fileChooser.showOpenDialog(primaryStage);
                if (file != null) {
                    try {
                        bufferedImage1 = ImageIO.read(new File(String.valueOf(file)));
                        route1.setText(file.toString());
                    } catch (IOException e) {
                        e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                    }
                }
            }
        });

        open2.setText("Open second file");
        open2.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                File file = fileChooser.showOpenDialog(primaryStage);
                if (file != null) {
                    try {
                        bufferedImage2 = ImageIO.read(new File(String.valueOf(file)));
                        route2.setText(file.toString());
                    } catch (IOException e) {
                        e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                    }
                }
            }
        });

        primaryStage.setTitle("Image Comparison Requirements");

        btn.setText("execute'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {

                if (bufferedImage1 != null && bufferedImage2 != null){

                    int startX = -1;
                    int startY = -1;
                    int endX = bufferedImage1.getWidth();
                    int endY = bufferedImage1.getHeight();
                    long col1;
                    long col2;
                    long percent;

                    final BufferedImage newBufferedImage = new BufferedImage(bufferedImage1.getWidth(),
                            bufferedImage1.getHeight(), BufferedImage.TYPE_INT_RGB);
                    Graphics g = newBufferedImage.createGraphics();
                    g.setColor(red);

                    for (int x = 0; x < bufferedImage1.getWidth() - 1; x++) {
                        for (int y = 0; y < bufferedImage1.getHeight() - 1; y++) {
                            col1 = bufferedImage1.getRGB(x, y);
                            col2 = bufferedImage2.getRGB(x, y);
                            percent = col1 * 100 / col2;
                            if (percent > 110 || percent < 90) {
                                if (x > endX + 10) {
                                    g.drawRect(startX, startY, endX - startX, endY - startY);
                                    startX = -1;
                                    startY = -1;
                                    endX = bufferedImage1.getWidth();
                                    endY = bufferedImage1.getHeight();
                                }
                                if (startX == -1) {
                                    startX = x;
                                }
                                if (x <= startX) {
                                    startX = x;
                                }
                                if (startY == -1) {
                                    startY = y;
                                }
                                if (y <= startY) {
                                    startY = y;
                                }
                                if (endX == bufferedImage1.getWidth()) {
                                    endX = x;
                                }
                                if (x >= endX) {
                                    endX = x;
                                }
                                if (endY == bufferedImage1.getHeight()) {
                                    endY = y;
                                }
                                if (y >= endY) {
                                    endY = y;
                                }

                                newBufferedImage.setRGB(x, y, bufferedImage2.getRGB(x, y));
                            } else {
                                newBufferedImage.setRGB(x, y, bufferedImage2.getRGB(x, y));
                            }
                        }
                    }
                    g.drawRect(startX, startY, endX - startX, endY - startY);
                    System.out.println("Готово!");

                    Image image = SwingFXUtils.toFXImage(newBufferedImage, null);
                    ImageView iv1 = new ImageView();
                    iv1.setImage(image);
                    iv1.setFitHeight(500);
                    iv1.setFitWidth(800);
                    vBox.getChildren().add(iv1);

                    Button save = new Button();
                    save.setText("Save file");
                    save.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent actionEvent) {
                            FileChooser fileChooser = new FileChooser();
                            fileChooser.setTitle("Save Image");
                            File file = fileChooser.showSaveDialog(primaryStage);
                            if (file != null) {
                                try {
                                    ImageIO.write(newBufferedImage, "jpg", file);
                                } catch (IOException ex) {
                                    System.out.println(ex.getMessage());
                                }
                            }
                        }
                    });
                    vBox.getChildren().add(save);
                else {
                    Text error = new Text();
                    error.setText("No file");
                    vBox.getChildren().add(error);
                }
            }
        });

        vBox.getChildren().add(open1);
        vBox.getChildren().add(route1);
        vBox.getChildren().add(open2);
        vBox.getChildren().add(route2);
        vBox.getChildren().add(btn);
        root.getChildren().add(vBox);
        primaryStage.setScene(new Scene(root, 900, 700));
        primaryStage.show();
    }
View Full Code Here


   */
  public Parent getRootNode()
  {
    Locale.setDefault(Locale.ENGLISH);
   
    vbox = new VBox();

    agenda = new Agenda();
    agenda.setDisplayedCalendar(new GregorianCalendar(2014, 0, 1));
    agenda.setPrefSize(1000, 800);
   
View Full Code Here

    lImageView.setId("TheImage");
       
        // layout scene
        BorderPane lBorderPane = new BorderPane();
        lBorderPane.setCenter(lAgenda);
          VBox lVBox = new VBox();
          lVBox.getChildren().add(lCalendarPicker);       
          lVBox.getChildren().add(lImageView);
        lBorderPane.setLeft(lVBox);
        lBorderPane.getStyleClass().add("screen");
       
        // setup scene
    Scene scene = new Scene(lBorderPane, 1000, 600);
View Full Code Here

   */
  private void refreshLayout()
  {
    getChildren().clear();
    StackPane lStackPane = new StackPane();
    VBox lVBox = new VBox(0);
    lVBox.alignmentProperty().set(Pos.CENTER);
    if ( getLabelDateFormat().format(DATE).contains("2") ) {
      if (getShowTickLabels() == ShowTickLabels.YES) {
        lVBox.getChildren().add(hourLabelsPane);
      }
      lVBox.getChildren().add(hourScrollSlider);
    }
    if ( getLabelDateFormat().format(DATE).contains("3") ) {
      lVBox.getChildren().add(minuteScrollSlider);
      if (getShowTickLabels() == ShowTickLabels.YES) {
        lVBox.getChildren().add(minuteLabelsPane);
      }
    }
    if ( getLabelDateFormat().format(DATE).contains("4") ) {
      lVBox.getChildren().add(secondScrollSlider);
    }
    lStackPane.getChildren().add(lVBox);
    lStackPane.getChildren().add(timeText);
    StackPane.setAlignment(timeText, getShowTickLabels() == ShowTickLabels.YES ? Pos.CENTER : Pos.TOP_CENTER);
    getChildren().add(lStackPane);
View Full Code Here

      });
      lBorderPane.setRight(lImageView);
    }
   
    // initial layout
    VBox lMenuVBox = new VBox(padding);
    lBorderPane.setCenter(lMenuVBox);

    // time
    lMenuVBox.getChildren().add(new Text("Time:"));
    // start
    final CalendarTextField lStartCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lStartCalendarTextField.setLocale(getSkinnable().getLocale());
    lStartCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getStartTime());
    lMenuVBox.getChildren().add(lStartCalendarTextField);
    // end
    final CalendarTextField lEndCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lEndCalendarTextField.setLocale(getSkinnable().getLocale());
    lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
    lMenuVBox.getChildren().add(lEndCalendarTextField);
    lEndCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        abstractAppointmentPane.appointment.setEndTime(newValue);
        // refresh is done upon popup close
      }
    });
    lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
    // wholeday
    if ((abstractAppointmentPane.appointment.isWholeDay() != null && abstractAppointmentPane.appointment.isWholeDay() == true) || abstractAppointmentPane.appointment.getEndTime() != null)
    {
      final CheckBox lWholedayCheckBox = new CheckBox("Wholeday");
      lWholedayCheckBox.setId("wholeday-checkbox");
      lWholedayCheckBox.selectedProperty().set(abstractAppointmentPane.appointment.isWholeDay());
      lMenuVBox.getChildren().add(lWholedayCheckBox);
      lWholedayCheckBox.selectedProperty().addListener(new ChangeListener<Boolean>()
      {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue)
        {
          abstractAppointmentPane.appointment.setWholeDay(newValue);
          if (newValue == true)
          {
            abstractAppointmentPane.appointment.setEndTime(null);
          }
          else
          {
            Calendar lEndTime = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndTime.add(Calendar.MINUTE, 30);
            abstractAppointmentPane.appointment.setEndTime(lEndTime);
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }
          lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
          // refresh is done upon popup close
        }
      });
    }
    // event handling
    lStartCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        // enddate
        if (abstractAppointmentPane.appointment.isWholeDay())
        {
          abstractAppointmentPane.appointment.setStartTime(newValue);
        }
        else
        {
          // remember
          Calendar lOldStart = abstractAppointmentPane.appointment.getStartTime();

          // set
          abstractAppointmentPane.appointment.setStartTime(newValue);

          // end date
          if (abstractAppointmentPane.appointment.getEndTime() != null)
          {
            long lDurationInMS = abstractAppointmentPane.appointment.getEndTime().getTimeInMillis() - lOldStart.getTimeInMillis();
            Calendar lEndCalendar = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndCalendar.add(Calendar.MILLISECOND, (int)lDurationInMS);
            abstractAppointmentPane.appointment.setEndTime(lEndCalendar);

            // update field
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }

          // refresh is done upon popup close
        }
      }
    });

    // summary
    lMenuVBox.getChildren().add(new Text("Summary:"));
    TextField lSummaryTextField = new TextField();
    lSummaryTextField.setText(abstractAppointmentPane.appointment.getSummary());
    lSummaryTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setSummary(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lSummaryTextField);

    // location
    lMenuVBox.getChildren().add(new Text("Location:"));
    TextField lLocationTextField = new TextField();
    lLocationTextField.setText( abstractAppointmentPane.appointment.getLocation() == null ? "" : abstractAppointmentPane.appointment.getLocation());
    lLocationTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setLocation(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lLocationTextField);

    // actions
    lMenuVBox.getChildren().add(new Text("Actions:"))// TODO: internationalize
    HBox lHBox = new HBox();
    lMenuVBox.getChildren().add(lHBox);
    // delete
    {
      // close icon
      ImageViewButton lImageView = new ImageViewButton();
      lImageView.getStyleClass().add("delete-icon");
      lImageView.setPickOnBounds(true);
      lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
      {
        @Override public void handle(MouseEvent evt)
        {
          lPopup.hide();
          getSkinnable().appointments().remove(abstractAppointmentPane.appointment);
          // refresh is done via the collection events
        }
      });
      Tooltip.install(lImageView, new Tooltip("Delete")); // TODO: internationalize
      lHBox.getChildren().add(lImageView);
    }

    // construct a area of appointment groups
    lMenuVBox.getChildren().add(new Text("Group:"));
    GridPane lAppointmentGroupGridPane = new GridPane();
    lMenuVBox.getChildren().add(lAppointmentGroupGridPane);
    lAppointmentGroupGridPane.getStyleClass().add("AppointmentGroups");
    lAppointmentGroupGridPane.setHgap(2);
    lAppointmentGroupGridPane.setVgap(2);
    int lCnt = 0;
    for (Agenda.AppointmentGroup lAppointmentGroup : getSkinnable().appointmentGroups())
View Full Code Here

    }

  @Override
  public void start(Stage stage) {

    VBox lVBox = new VBox();   
    HBox lHBox = new HBox(0);
    lVBox.getChildren().add(lHBox);

    for (int j = 1; j < 27; j++)
    {
      CircularPane lCircularPane = new CircularPane();
      lCircularPane.setStyle("-fx-border-color:black;");
      lCircularPane.setShowDebug(Color.GREEN);
      for (int i = 0; i < j; i++) {
        javafx.scene.shape.Rectangle c = new javafx.scene.shape.Rectangle(30,30);
        //c.setStroke(Color.RED);
        lCircularPane.add(c);
      }
      lHBox.getChildren().add(lCircularPane);
      if (lHBox.prefWidth(-1) > 1500) {
        lHBox = new HBox(0);
        lVBox.getChildren().add(lHBox);
      }
    }

        // setup scene
    Scene scene = new Scene(lVBox);
View Full Code Here

    }

  @Override
  public void start(Stage stage) {

    VBox lVBox = new VBox();   
    HBox lHBox = new HBox(0);
    lVBox.getChildren().add(lHBox);

    for (int j = 1; j < 27; j++)
    {
      CircularPane lCircularPane = new CircularPane();
      lCircularPane.setStyle("-fx-border-color:black;");
      //lCircularPane.setChildrenAreCircular(true);
      lCircularPane.setShowDebug(Color.GREEN);
      for (int i = 0; i < j; i++) {
        javafx.scene.shape.Rectangle c = new javafx.scene.shape.Rectangle(20,20);
        lCircularPane.add(c);
      }
      lHBox.getChildren().add(lCircularPane);
      if (lHBox.prefWidth(-1) > 1000) {
        lHBox = new HBox(0);
        lVBox.getChildren().add(lHBox);
      }
    }

        // setup scene
    Scene scene = new Scene(lVBox);
View Full Code Here

   */
  public Parent getRootNode()
  {
    Locale.setDefault(Locale.ENGLISH);
   
    VBox box = new VBox();

    localDateTimePicker = new LocalDateTimePicker();
    box.getChildren().add(localDateTimePicker);

    localDateTimePicker.setDisplayedLocalDateTime(LocalDateTime.of(2013, 1, 1, 12, 00, 00));
   
    // make sure the pixels moved by the mouse are constant
    box.setPrefSize(300, 300);
    return box;
  }
View Full Code Here

  public Parent getRootNode()
  {
    Locale.setDefault(Locale.ENGLISH);
   
    VBox box = new VBox();

    toggleGroupValue = new ToggleGroupValue<>();
    int idx = 0;
    for (int i = 0; i < 3; i++) {
      RadioButton lButton = new RadioButton("" + idx);
      lButton.setId("button" + idx);
      toggleGroupValue.add(lButton, "value" + idx);
      toggles.add(lButton);
      box.getChildren().add(lButton);
      idx++;
    }
    for (int i = 0; i < 3; i++) {
      ToggleButton lButton = new ToggleButton("" + idx);
      lButton.setId("button" + idx);
      toggleGroupValue.add(lButton, "value" + idx);
      toggles.add(lButton);
      box.getChildren().add(lButton);
      idx++;
    }
    box.getChildren().add(new Button("focus helper"));
   

    // make sure that the listspinner fits with arrows in both directions
    box.setPrefSize(100, 100);
   
    return box;
  }
View Full Code Here

   */
  public Parent getRootNode()
  {
    Locale.setDefault(Locale.ENGLISH);
   
    VBox box = new VBox();

    calendarPicker = new CalendarPicker();
    box.getChildren().add(calendarPicker);

    // display first of January
    calendarPicker.setDisplayedCalendar(new GregorianCalendar(2013, 0, 1, 12, 00, 00));
   
    // make sure there is enough room for the time sliders
    box.setPrefSize(300, 300);
    return box;
  }
View Full Code Here

TOP

Related Classes of javafx.scene.layout.VBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.