当前位置: 首页>>代码示例>>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;未经允许,请勿转载。