當前位置: 首頁>>代碼示例>>Java>>正文


Java VPos.TOP屬性代碼示例

本文整理匯總了Java中javafx.geometry.VPos.TOP屬性的典型用法代碼示例。如果您正苦於以下問題:Java VPos.TOP屬性的具體用法?Java VPos.TOP怎麽用?Java VPos.TOP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javafx.geometry.VPos的用法示例。


在下文中一共展示了VPos.TOP屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createLabels

/**
 * Creates or updates the actual layout of the time axis.
 * The layout can either be horizontal or vertical.
 * The GridView is populated with columns/rows and labels are added accordingly.
 * The labels show the time between this.timeStartProperty and this.timeEndProperty with
 * this.timeStepsProperty in between.
 * The time is formatted according to this.formatter.
 */
private void createLabels() {
    this.getChildren().clear();
    this.getRowConstraints().clear();
    this.getColumnConstraints().clear();

    for(LocalTime currentTime = getTimeStartProperty().get();
        currentTime.isBefore(getTimeEndProperty().get()); ) {

        // create a new label with the time
        Label lblTime = new Label();
        lblTime.setText(currentTime.format(getFormatter()));
        lblTime.getStyleClass().add("time-axis-label");

        // create a new row/column and add the label to it
        if(horizontal) {
            // center the label
            lblTime.widthProperty().addListener(o -> lblTime.setTranslateX( -lblTime.widthProperty().getValue() / 2));

            ColumnConstraints column = new ColumnConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true);
            this.getColumnConstraints().add(column);
            this.add(lblTime, this.getColumnConstraints().size() - 1, 0);
        } else {
            // center the label
            lblTime.heightProperty().addListener(o -> lblTime.setTranslateY( -lblTime.heightProperty().getValue() / 2));
            RowConstraints row = new RowConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, VPos.TOP, true);
            this.getRowConstraints().add(row);
            this.add(lblTime, 0, this.getRowConstraints().size() - 1);
        }

        // prevent overflows at midnight
        LocalTime newTime = currentTime.plusMinutes(getTimeStepsProperty().get().toMinutes());
        if(newTime.isAfter(currentTime)) {
            currentTime = newTime;
        } else {
            break;
        }
    }
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:46,代碼來源:TimeAxis.java

示例2: setLayout

private void setLayout() {
    // set layout for this pane
    final RowConstraints headerRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // HEADER FOR FULL WEEK
    final RowConstraints allDayRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // SINGLE DAY HEADER AND ALL DAY APPOINTMENTS
    final RowConstraints calendarRow = new RowConstraints(
            150, 500, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // CALENDAR
    final ColumnConstraints columnConstraints = new ColumnConstraints(
            400, 600, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true); // FULL WIDTH
    this.getRowConstraints().addAll(headerRow, allDayRow, calendarRow);
    this.getColumnConstraints().add(columnConstraints);
    this.getStyleClass().add("weekview");


    // create a container for the week header
    Pane weekHeaderContainer = new StackPane();
    weekHeaderContainer.getStyleClass().add("weekview-header-container");
    this.weekHeaderContainer = weekHeaderContainer;

    // ScrollPane that contains the DayPane and the TimeAxis
    final ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("weekview-scrollpane");
    scrollPane.setStyle("-fx-background-color:transparent;"); // remove gray border
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);

    // the ScrollPane holds a GridPane with two columns: one for the TimeAxis and one for the calendar
    final GridPane scrollPaneContent = new GridPane();
    scrollPaneContent.getStyleClass().add("weekview-scrollpane-content");
    final ColumnConstraints timeColumn = new ColumnConstraints(
            USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE, Priority.ALWAYS, HPos.LEFT, false); // TIME COLUMN
    final ColumnConstraints calendarColumn = new ColumnConstraints(
            USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT, true); // CALENDAR COLUMN
    final RowConstraints rowConstraint = new RowConstraints(
            USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // FULL HEIGHT
    scrollPaneContent.getColumnConstraints().addAll(timeColumn, calendarColumn);
    scrollPaneContent.getRowConstraints().addAll(rowConstraint);
    scrollPane.setContent(scrollPaneContent);

    // create a container for the TimeAxis
    Pane timeAxisContainer = new StackPane();
    timeAxisContainer.getStyleClass().add("weekview-timeaxis-container");
    scrollPaneContent.add(timeAxisContainer, 0, 0);
    this.timeAxisContainer = timeAxisContainer;

    // set up a GridPane that holds all the DayPanes and a GridPane for the headers and full day appointments
    final GridPane dayPaneContainer = new GridPane();
    dayPaneContainer.getStyleClass().add("weekview-daypane-container");
    final GridPane dayHeaderContainer = new GridPane();
    dayHeaderContainer.getStyleClass().add("weekview-day-header-container");
    for (int i = 0; i < numberOfDays; i++) {
        final ColumnConstraints appointmentsColumn = new ColumnConstraints(
                USE_PREF_SIZE, dayPaneMinWidth, Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.CENTER, true);
        dayPaneContainer.getColumnConstraints().add(appointmentsColumn);
        dayHeaderContainer.getColumnConstraints().add(appointmentsColumn);
    }
    final RowConstraints singleDayHeaderRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // PANE FOR A DAILY HEADER
    final RowConstraints singleDayAppointmentsRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // PANE FOR ALL DAY APPOINTMENTS
    dayHeaderContainer.getRowConstraints().addAll(singleDayHeaderRow, singleDayAppointmentsRow);
    timeAxisContainer.widthProperty().addListener(observable -> {
        dayHeaderContainer.setPadding(new Insets(0, 17 /*scrollbar*/, 0, timeAxisContainer.getWidth() + 1));
    });
    final RowConstraints dayPanesRow = new RowConstraints(
            USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // FULL HEIGHT
    dayPaneContainer.getRowConstraints().add(dayPanesRow);
    this.dayPanesContainer = dayPaneContainer;
    this.dayHeadersContainer = dayHeaderContainer;
    scrollPaneContent.add(dayPaneContainer, 1, 0);

    // ordering is important:
    this.add(scrollPane, 0, 2);
    this.add(dayHeaderContainer, 0, 1);
    this.add(weekHeaderContainer, 0, 0);
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:74,代碼來源:WeekView.java


注:本文中的javafx.geometry.VPos.TOP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。