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


Java Bindings.bindBidirectional方法代碼示例

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


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

示例1: updateView

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
private void updateView() {
    vbox.getChildren().clear();
    for (CalendarSource source : getSkinnable().getCalendarSources()) {
        source.getCalendars().removeListener(updater);
        source.getCalendars().addListener(updater);

        VBox box = new VBox(8);
        box.getStyleClass().add("single-calendar-group");

        for (Calendar calendar : source.getCalendars()) {
            CheckBox checkBox = new CheckBox();
            checkBox.textProperty().bind(calendar.nameProperty());
            checkBox.getStyleClass().addAll("default-style-visibility-checkbox",//$NON-NLS-1$
                    calendar.getStyle() + "-visibility-checkbox"); //$NON-NLS-1$
            Bindings.bindBidirectional(checkBox.selectedProperty(), getSkinnable().getCalendarVisibilityProperty(calendar));
            box.getChildren().add(checkBox);
        }

        if (getSkinnable().getCalendarSources().size() == 1) {
            vbox.getChildren().add(box);
        } else {
            TitledPane titledPane = new TitledPane();
            titledPane.textProperty().bind(source.nameProperty());
            titledPane.setContent(box);
            vbox.getChildren().add(titledPane);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:29,代碼來源:SourceViewSkin.java

示例2: bind

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * Invokes {@link DateControl#bind(DateControl, boolean)} and adds some more
 * bindings between this control and the given control.
 *
 * @param otherControl the control that will be bound to this control
 * @param bindDate     if true will also bind the date property
 */
public final void bind(DayViewBase otherControl, boolean bindDate) {
    super.bind(otherControl, bindDate);

    Bindings.bindBidirectional(
            otherControl.earlyLateHoursStrategyProperty(),
            earlyLateHoursStrategy);
    Bindings.bindBidirectional(otherControl.hoursLayoutStrategyProperty(),
            hoursLayoutStrategyProperty());
    Bindings.bindBidirectional(otherControl.hourHeightProperty(),
            hourHeightProperty());
    Bindings.bindBidirectional(otherControl.hourHeightCompressedProperty(),
            hourHeightCompressedProperty());
    Bindings.bindBidirectional(otherControl.visibleHoursProperty(),
            visibleHoursProperty());
    Bindings.bindBidirectional(otherControl.enableCurrentTimeMarkerProperty(),
            enableCurrentTimeMarkerProperty());
    Bindings.bindBidirectional(otherControl.trimTimeBoundsProperty(),
            trimTimeBoundsProperty());
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:27,代碼來源:DayViewBase.java

示例3: CalendarView

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * Constructs a new calendar view.
 */
public CalendarView() {
    getStyleClass().add(DEFAULT_STYLE_CLASS);

    this.dayPage = new DayPage();
    this.weekPage = new WeekPage();
    this.monthPage = new MonthPage();
    this.yearPage = new YearPage();

    this.searchField = (CustomTextField) TextFields.createClearableTextField();
    this.sourceView = new SourceView();
    this.searchResultView = new SearchResultView();
    this.yearMonthView = new YearMonthView();

    if (Boolean.getBoolean("calendarfx.developer")) { //$NON-NLS-1$
        this.developerConsole = new DeveloperConsole();
        this.developerConsole.setDateControl(this);
    }

    selectedPage.set(dayPage);

    Bindings.bindBidirectional(searchField.visibleProperty(), showSearchFieldProperty());

    /*
     * We do have a user agent stylesheet, but it doesn't seem to work
     * properly when run as a standalone jar file.
     */
    getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm()); //$NON-NLS-1$

    /*
     * We are "abusing" the properties map to pass new values of read-only
     * properties from the skin to the control.
     */
    getProperties().addListener((Change<?, ?> change) -> {
        if (change.getKey().equals(SELECTED_PAGE)) {
            if (change.getValueAdded() != null) {
                PageBase page = (PageBase) change.getValueAdded();
                selectedPage.set(page);
                getProperties().remove(SELECTED_PAGE);
            }
        }
    });

    InvalidationListener fixSelectedPageListener = it -> fixSelectedPage();

    dayPage.hiddenProperty().addListener(fixSelectedPageListener);
    weekPage.hiddenProperty().addListener(fixSelectedPageListener);
    monthPage.hiddenProperty().addListener(fixSelectedPageListener);
    yearPage.hiddenProperty().addListener(fixSelectedPageListener);

    fixSelectedPage();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:55,代碼來源:CalendarView.java

示例4: bindPage

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public final void bindPage(PrintablePage otherPage) {
    super.bind(otherPage, true);

    Bindings.bindBidirectional(otherPage.viewTypeProperty(), viewTypeProperty());
    Bindings.bindBidirectional(otherPage.paperProperty(), paperProperty());
    Bindings.bindBidirectional(otherPage.showAllDayEntriesProperty(), showAllDayEntriesProperty());
    Bindings.bindBidirectional(otherPage.showCalendarKeysProperty(), showCalendarKeysProperty());
    Bindings.bindBidirectional(otherPage.showMiniCalendarsProperty(), showMiniCalendarsProperty());
    Bindings.bindBidirectional(otherPage.showTimedEntriesProperty(), showTimedEntriesProperty());
    Bindings.bindBidirectional(otherPage.printStartDateProperty(), printStartDateProperty());
    Bindings.bindBidirectional(otherPage.printEndDateProperty(), printEndDateProperty());
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:13,代碼來源:PrintablePage.java

示例5: DetailedWeekView

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * Constructs a new view with the given number of days.
 *
 * @param numberOfDays the number of days to show in the view
 */
public DetailedWeekView(int numberOfDays) {
    setNumberOfDays(numberOfDays);

    getStyleClass().add(DEFAULT_STYLE_CLASS);

    calendarHeaderView = new CalendarHeaderView();
    calendarHeaderView.numberOfDaysProperty().bind(numberOfDaysProperty());
    calendarHeaderView.bind(this);

    weekDayHeaderView = new WeekDayHeaderView();
    bind(weekDayHeaderView, true);
    Bindings.bindBidirectional(weekDayHeaderView.numberOfDaysProperty(), numberOfDaysProperty());
    Bindings.bindBidirectional(weekDayHeaderView.adjustToFirstDayOfWeekProperty(), adjustToFirstDayOfWeekProperty());

    allDayView = new AllDayView(getNumberOfDays());
    bind(allDayView, true);
    Bindings.bindBidirectional(allDayView.numberOfDaysProperty(), numberOfDaysProperty());
    Bindings.bindBidirectional(allDayView.adjustToFirstDayOfWeekProperty(), adjustToFirstDayOfWeekProperty());

    weekView = new WeekView();
    bind(weekView, true);
    Bindings.bindBidirectional(weekView.numberOfDaysProperty(), numberOfDaysProperty());
    Bindings.bindBidirectional(weekView.adjustToFirstDayOfWeekProperty(), adjustToFirstDayOfWeekProperty());

    timeScaleView = new WeekTimeScaleView();
    bind(timeScaleView, true);

    startDate.bind(weekView.startDateProperty());
    endDate.bind(weekView.endDateProperty());

}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:37,代碼來源:DetailedWeekView.java

示例6: YearPage

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * Constructs a new year page.
 */
public YearPage() {
    getStyleClass().add("year-page"); //$NON-NLS-1$

    this.yearView = new YearView();

    this.monthSheetView = new MonthSheetView();
    this.monthSheetView.setCellFactory(param -> new MonthSheetView.DetailedDateCell(param.getView(), param.getDate()));
    this.monthSheetView.setClickBehaviour(ClickBehaviour.SHOW_DETAILS);

    bind(yearView, true);
    bind(monthSheetView, true);

    Bindings.bindBidirectional(monthSheetView.showTodayProperty(), showTodayProperty());

    setDateTimeFormatter(DateTimeFormatter.ofPattern(Messages.getString("YearPage.DATE_FORMAT"))); //$NON-NLS-1$

    displayModeProperty().addListener(it -> updateDisplayModeIcon());

    displayModeButton = new ToggleButton();
    displayModeButton.setId("display-mode-button");
    displayModeButton.setTooltip(new Tooltip(Messages.getString("YearPage.TOOLTIP_DISPLAY_MODE")));
    displayModeButton.setSelected(getDisplayMode().equals(DisplayMode.COLUMNS));
    displayModeButton.selectedProperty().addListener(it -> {
        if (displayModeButton.isSelected()) {
            setDisplayMode(DisplayMode.COLUMNS);
        } else {
            setDisplayMode(DisplayMode.GRID);
        }
    });

    displayModeProperty().addListener(it -> displayModeButton.setSelected(getDisplayMode().equals(DisplayMode.COLUMNS)));

    updateDisplayModeIcon();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:38,代碼來源:YearPage.java

示例7: TrayPane

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public TrayPane() {
    // source view
    sourceView = getSkinnable().getSourceView();
    sourceView.bind(getSkinnable());

    // year month view
    yearMonthView = getSkinnable().getYearMonthView();
    yearMonthView.setShowToday(false);
    yearMonthView.setShowTodayButton(false);
    yearMonthView.setId("date-picker"); //$NON-NLS-1$
    yearMonthView.setSelectionMode(SINGLE);
    yearMonthView.setClickBehaviour(PERFORM_SELECTION);
    yearMonthView.getSelectedDates().add(getSkinnable().getDate());
    yearMonthView.getSelectedDates().addListener((Observable evt) -> {
        if (yearMonthView.getSelectedDates().size() > 0) {
            yearMonthView.setDate(
                    yearMonthView.getSelectedDates().iterator().next());
        }
    });

    getSkinnable().dateProperty().addListener(it -> {
        yearMonthView.getSelectedDates().clear();
        yearMonthView.getSelectedDates().add(getSkinnable().getDate());
    });

    Bindings.bindBidirectional(yearMonthView.todayProperty(),
            getSkinnable().todayProperty());
    Bindings.bindBidirectional(yearMonthView.dateProperty(),
            getSkinnable().dateProperty());
    yearMonthView.weekFieldsProperty().bind(getSkinnable().weekFieldsProperty());

    ScrollPane scrollPane = new ScrollPane(sourceView);

    scrollPane.getStyleClass().add("source-view-scroll-pane"); //$NON-NLS-1$
    setCenter(scrollPane);
    setBottom(yearMonthView);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:38,代碼來源:CalendarViewSkin.java

示例8: createContent

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
@Override
protected Node createContent() {
    WeekPage weekPage = getSkinnable();
    DetailedWeekView detailedWeekView = weekPage.getDetailedWeekView();

    weekPage.bind(detailedWeekView, true);

    Bindings.bindBidirectional(detailedWeekView.startTimeProperty(), weekPage.startTimeProperty());
    Bindings.bindBidirectional(detailedWeekView.endTimeProperty(), weekPage.endTimeProperty());

    return detailedWeekView;
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:13,代碼來源:WeekPageSkin.java

示例9: TrayPane

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public TrayPane() {
    // source view
    sourceView = getSkinnable().getSourceView();
    sourceView.bind(getSkinnable());

    // year month view
    yearMonthView = getSkinnable().getYearMonthView();
    yearMonthView.setShowToday(false);
    yearMonthView.setShowTodayButton(false);
    yearMonthView.setId("date-picker"); //$NON-NLS-1$
    yearMonthView.setSelectionMode(SINGLE);
    yearMonthView.setClickBehaviour(PERFORM_SELECTION);
    yearMonthView.getSelectedDates().add(getSkinnable().getDate());
    yearMonthView.getSelectedDates().addListener((Observable evt) -> {
        if (yearMonthView.getSelectedDates().size() > 0) {
            yearMonthView.setDate(yearMonthView.getSelectedDates().iterator().next());
        }
    });

    getSkinnable().dateProperty().addListener(it -> {
        yearMonthView.getSelectedDates().clear();
        yearMonthView.getSelectedDates().add(getSkinnable().getDate());
    });

    Bindings.bindBidirectional(yearMonthView.todayProperty(), getSkinnable().todayProperty());
    Bindings.bindBidirectional(yearMonthView.dateProperty(), getSkinnable().dateProperty());
    yearMonthView.weekFieldsProperty().bind(getSkinnable().weekFieldsProperty());

    ScrollPane scrollPane = new ScrollPane(sourceView);

    scrollPane.getStyleClass().add("source-view-scroll-pane"); //$NON-NLS-1$
    setCenter(scrollPane);
    setBottom(yearMonthView);
}
 
開發者ID:dlemmermann,項目名稱:JProCalendarFX,代碼行數:35,代碼來源:CalendarViewSkin.java

示例10: bind

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * Binds several properties of the given date control to the same properties
 * of this control. This kind of binding is needed to create UIs with nested
 * date controls. The {@link CalendarView} for example consists of several
 * pages. Each page is a date control that consists of several other date
 * controls. The {@link DayPage} consists of the {@link AgendaView}, a
 * single {@link DayView}, and a {@link YearMonthView} . All of these
 * controls are bound to each other so that the application can simply
 * change properties on the {@link CalendarView} without worrying about the
 * nested controls.
 *
 * @param otherControl the control that will be bound to this control
 * @param bindDate     determines if the date property will also be bound
 */
public final void bind(DateControl otherControl, boolean bindDate) {
    requireNonNull(otherControl);

    boundDateControls.add(otherControl);

    // bind maps
    Bindings.bindContentBidirectional(otherControl.getCalendarVisibilityMap(), getCalendarVisibilityMap());

    // bind lists
    Bindings.bindContentBidirectional(otherControl.getCalendarSources(), getCalendarSources());
    Bindings.bindContentBidirectional(otherControl.getSelections(), getSelections());
    Bindings.bindContentBidirectional(otherControl.getWeekendDays(), getWeekendDays());

    // bind properties
    Bindings.bindBidirectional(otherControl.suspendUpdatesProperty(), suspendUpdatesProperty());
    Bindings.bindBidirectional(otherControl.entryFactoryProperty(), entryFactoryProperty());
    Bindings.bindBidirectional(otherControl.defaultCalendarProviderProperty(), defaultCalendarProviderProperty());
    Bindings.bindBidirectional(otherControl.virtualGridProperty(), virtualGridProperty());
    Bindings.bindBidirectional(otherControl.draggedEntryProperty(), draggedEntryProperty());
    Bindings.bindBidirectional(otherControl.requestedTimeProperty(), requestedTimeProperty());

    Bindings.bindBidirectional(otherControl.selectionModeProperty(), selectionModeProperty());
    Bindings.bindBidirectional(otherControl.selectionModeProperty(), selectionModeProperty());
    Bindings.bindBidirectional(otherControl.weekFieldsProperty(), weekFieldsProperty());
    Bindings.bindBidirectional(otherControl.layoutProperty(), layoutProperty());

    Bindings.bindBidirectional(otherControl.startTimeProperty(), startTimeProperty());
    Bindings.bindBidirectional(otherControl.endTimeProperty(), endTimeProperty());
    Bindings.bindBidirectional(otherControl.timeProperty(), timeProperty());
    Bindings.bindBidirectional(otherControl.usagePolicyProperty(), usagePolicyProperty());

    if (bindDate) {
        Bindings.bindBidirectional(otherControl.dateProperty(), dateProperty());
    }

    Bindings.bindBidirectional(otherControl.todayProperty(), todayProperty());
    Bindings.bindBidirectional(otherControl.zoneIdProperty(), zoneIdProperty());

    // edit callbacks
    Bindings.bindBidirectional(otherControl.entryDetailsCallbackProperty(), entryDetailsCallbackProperty());
    Bindings.bindBidirectional(otherControl.dateDetailsCallbackProperty(), dateDetailsCallbackProperty());
    Bindings.bindBidirectional(otherControl.contextMenuCallbackProperty(), contextMenuCallbackProperty());
    Bindings.bindBidirectional(otherControl.entryContextMenuCallbackProperty(), entryContextMenuCallbackProperty());
    Bindings.bindBidirectional(otherControl.calendarSourceFactoryProperty(), calendarSourceFactoryProperty());
    Bindings.bindBidirectional(otherControl.entryDetailsPopOverContentCallbackProperty(), entryDetailsPopOverContentCallbackProperty());
    Bindings.bindBidirectional(otherControl.entryEditPolicyProperty(), entryEditPolicyProperty());
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:62,代碼來源:DateControl.java

示例11: EntryHeaderView

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public EntryHeaderView(Entry<?> entry, List<Calendar> calendars) {
    this.entry = requireNonNull(entry);
    requireNonNull(calendars);

    getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm());

    TextField titleField = new TextField(entry.getTitle());
    Bindings.bindBidirectional(titleField.textProperty(), entry.titleProperty());

    titleField.disableProperty().bind(entry.getCalendar().readOnlyProperty());

    TextField locationField = new TextField(entry.getLocation());
    Bindings.bindBidirectional(locationField.textProperty(), entry.locationProperty());
    locationField.getStyleClass().add("location"); //$NON-NLS-1$
    locationField.setEditable(true);
    locationField.setPromptText(Messages.getString("EntryHeaderView.PROMPT_LOCATION")); //$NON-NLS-1$
    locationField.setMaxWidth(500);
    locationField.disableProperty().bind(entry.getCalendar().readOnlyProperty());

    calendarSelector = new CalendarSelector();
    calendarSelector.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    calendarSelector.getCalendars().setAll(calendars);
    calendarSelector.setCalendar(entry.getCalendar());
    Bindings.bindBidirectional(calendarSelector.calendarProperty(), entry.calendarProperty());

    titleField.getStyleClass().add("default-style-entry-popover-title"); //$NON-NLS-1$

    add(titleField, 0, 0);
    add(calendarSelector, 1, 0, 1, 2);
    add(locationField, 0, 1);

    RowConstraints row1 = new RowConstraints();
    row1.setValignment(VPos.TOP);
    row1.setFillHeight(true);

    RowConstraints row2 = new RowConstraints();
    row2.setValignment(VPos.TOP);
    row2.setFillHeight(true);

    getRowConstraints().addAll(row1, row2);

    ColumnConstraints col1 = new ColumnConstraints();
    col1.setFillWidth(true);
    col1.setHgrow(Priority.ALWAYS);

    ColumnConstraints col2 = new ColumnConstraints();
    col2.setFillWidth(true);
    col2.setHgrow(Priority.NEVER);

    getColumnConstraints().addAll(col1, col2);

    getStyleClass().add("popover-header"); //$NON-NLS-1$

    titleField.getStyleClass().add("title"); //$NON-NLS-1$
    titleField.setPromptText(Messages.getString("EntryHeaderView.PROMPT_TITLE")); //$NON-NLS-1$
    titleField.setMaxWidth(500);

    Calendar calendar = entry.getCalendar();

    titleField.getStyleClass().add(calendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$

    entry.calendarProperty()
            .addListener((observable, oldCalendar, newCalendar) -> {
                if (oldCalendar != null) {
                    titleField.getStyleClass().remove(oldCalendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$
                }
                if (newCalendar != null) {
                    titleField.getStyleClass().add(newCalendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$
                }
            });
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:72,代碼來源:EntryHeaderView.java

示例12: buildDays

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
private void buildDays() {
        WeekView weekView = getSkinnable();
        List<WeekDayView> weekDayViews = weekView.getWeekDayViews();

        // before rebuilding make sure to unbind previous day view children
        weekDayViews.forEach(view -> getSkinnable().unbind(view));

        dayGridPane.getChildren().clear();
        dayGridPane.getColumnConstraints().clear();

        weekDayViews.clear();

        Callback<WeekView.WeekDayParameter, WeekDayView> weekDayViewFactory = weekView.getWeekDayViewFactory();

        int numberOfDays = weekView.getNumberOfDays();

        for (int i = 0; i < numberOfDays; i++) {
            ColumnConstraints con = new ColumnConstraints();
            con.setPercentWidth((double) 100 / (double) numberOfDays);
            dayGridPane.getColumnConstraints().add(con);

            WeekView.WeekDayParameter param = new WeekView.WeekDayParameter(weekView);
            WeekDayView weekDayView = weekDayViewFactory.call(param);
            weekDayView.getProperties().put("week.view", weekView); //$NON-NLS-1$

            weekDayView.earliestTimeUsedProperty().addListener(it -> updateUsedTimes());
            weekDayView.latestTimeUsedProperty().addListener(it -> updateUsedTimes());

            if (i == 0) {
                weekDayView.getStyleClass().add("first-day");
            } else if (i == numberOfDays - 1) {
                weekDayView.getStyleClass().add("last-day");
            }

            GridPane.setHgrow(weekDayView, Priority.ALWAYS);
            GridPane.setVgrow(weekDayView, Priority.ALWAYS);

            final int dayCount = i;

            final InvalidationListener updateListener = it -> updateDate(weekDayView, dayCount);
            weekView.dateProperty().addListener(updateListener);
            weekView.weekFieldsProperty().addListener(updateListener);

            updateDate(weekDayView, dayCount);

            getSkinnable().bind(weekDayView, false);

            Bindings.bindBidirectional(weekDayView.startTimeProperty(), weekView.startTimeProperty());
            Bindings.bindBidirectional(weekDayView.endTimeProperty(), weekView.endTimeProperty());

//            weekDayView.startTimeProperty().bind(weekView.startTimeProperty());
//            weekDayView.endTimeProperty().bind(weekView.endTimeProperty());

            dayGridPane.add(weekDayView, i, 0);

            weekDayViews.add(weekDayView);
        }
    }
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:59,代碼來源:WeekViewSkin.java

示例13: onStart

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
@Override
protected void onStart() {

	checkLog.setSelected(SettingsUtil.settings.show_log_window);
	checkTracking.setSelected(SettingsUtil.settings.tracking);
	checkCloseLauncher.setSelected(SettingsUtil.settings.close_launcher_with_minecraft);
	buttonSave.setOnAction(event -> {
		SettingsUtil.settings.show_log_window = checkLog.isSelected();
		SettingsUtil.settings.tracking = checkTracking.isSelected();
		SettingsUtil.settings.close_launcher_with_minecraft = checkCloseLauncher.isSelected();
		SettingsUtil.settings.minecraftMinMemory = minMemory.getValue();
		SettingsUtil.settings.minecraftMaxMemory = maxMemory.getValue();
		SettingsUtil.settings.arguments = argumentBox.getText();
		SettingsUtil.settings.wrapperCommand = wrapperBox.getText();
		try {
			SettingsUtil.saveSetting();
		} catch (IOException e) {
			OneClientLogging.error(e);
		}
		if (SettingsUtil.settings.show_log_window) {
			OneClientLogging.showLogWindow();
		} else {
			OneClientLogging.hideLogWindow();
		}
	});

	maxMemory = new SpinnerValueFactory.IntegerSpinnerValueFactory(128, (int) OperatingSystem.getOSTotalMemory(), SettingsUtil.settings.minecraftMaxMemory, 128);
	minMemory = new SpinnerValueFactory.IntegerSpinnerValueFactory(128, (int) OperatingSystem.getOSTotalMemory(), SettingsUtil.settings.minecraftMinMemory, 128);

	maxMemory.valueProperty().addListener((observableValue, a, b) -> {
		if (minMemory.getValue() > maxMemory.getValue())
			minMemory.setValue(maxMemory.getValue());
	});
	minMemory.valueProperty().addListener((observableValue, a, b) -> {
		if (minMemory.getValue() > maxMemory.getValue())
			maxMemory.setValue(minMemory.getValue());
	});

	spinnerMinRAM.focusedProperty().addListener((observable, oldValue, newValue) -> {
		if (!newValue) {
			spinnerMinRAM.increment(0); // won't change value, but will commit editor
		}
	});

	spinnerMaxRAM.focusedProperty().addListener((observable, oldValue, newValue) -> {
		if (!newValue) {
			spinnerMaxRAM.increment(0); // won't change value, but will commit editor
		}
	});

	spinnerMinRAM.setValueFactory(minMemory);
	spinnerMaxRAM.setValueFactory(maxMemory);

	spinnerMinRAM.setEditable(true);
	spinnerMaxRAM.setEditable(true);

	argumentBox.setText(SettingsUtil.settings.arguments);
	buttonFindJava.setOnAction(event -> {
		JavaUtil.JavaInstall java = new JavaDialog().showAndWait().orElse(null);
		if (java != null)
			SettingsUtil.settings.setJavaPath(java.path);
	});
	Bindings.bindBidirectional(fieldJavaPath.textProperty(), SettingsUtil.settings.javaPath);

	buttonJavaPath.setOnAction(this::openChooser);

}
 
開發者ID:HearthProject,項目名稱:OneClient,代碼行數:68,代碼來源:SettingsPane.java

示例14: initializeBindings

import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
/**
 * initializes the bindings of the sliders and the analysis pane
 */
private void initializeBindings() {
    //First, bind the LoadedData.analyzeAll boolean property to the radio buttons
    LoadedData.analyzeSelectedProperty().bind(compareSelectedSamplesButton.selectedProperty());

    //Since the slider value property is double and the text field property is a string, we need to convert them
    //Defining own class to avoid exceptions
    class MyNumberStringConverter extends NumberStringConverter {
        @Override
        public Number fromString(String value) {
            try {
                return super.fromString(value);
            } catch (RuntimeException ex) {
                return 0;
            }
        }
    }
    StringConverter<Number> converter = new MyNumberStringConverter();
    //Bind every slider to its corresponding text field and vice versa
    Bindings.bindBidirectional(minPosCorrelationText.textProperty(), posCorrelationRangeSlider.lowValueProperty(), converter);
    Bindings.bindBidirectional(maxPosCorrelationText.textProperty(), posCorrelationRangeSlider.highValueProperty(), converter);
    Bindings.bindBidirectional(minNegCorrelationText.textProperty(), negCorrelationRangeSlider.lowValueProperty(), converter);
    Bindings.bindBidirectional(maxNegCorrelationText.textProperty(), negCorrelationRangeSlider.highValueProperty(), converter);
    Bindings.bindBidirectional(maxPValueText.textProperty(), maxPValueSlider.valueProperty(), converter);
    Bindings.bindBidirectional(minFrequencyText.textProperty(), frequencyRangeSlider.lowValueProperty(), converter);
    Bindings.bindBidirectional(maxFrequencyText.textProperty(), frequencyRangeSlider.highValueProperty(), converter);
    Bindings.bindBidirectional(excludeFrequencyText.textProperty(), excludeFrequencySlider.valueProperty(), converter);

    //Bind the internal filter properties to the slider values
    AnalysisData.posCorrelationLowerFilterProperty().bind(posCorrelationRangeSlider.lowValueProperty());
    AnalysisData.posCorrelationUpperFilterProperty().bind(posCorrelationRangeSlider.highValueProperty());
    AnalysisData.negCorrelationLowerFilterProperty().bind(negCorrelationRangeSlider.lowValueProperty());
    AnalysisData.negCorrelationUpperFilterProperty().bind(negCorrelationRangeSlider.highValueProperty());
    AnalysisData.minFrequencyProperty().bind(frequencyRangeSlider.lowValueProperty());
    AnalysisData.maxFrequencyProperty().bind(frequencyRangeSlider.highValueProperty());
    AnalysisData.maxPValueProperty().bind(maxPValueSlider.valueProperty());
    AnalysisData.excludeFrequencyThresholdProperty().bind(excludeFrequencySlider.valueProperty());

    //The values of the negative slider can't be set to values below 0 via FXML for reasons beyond human understanding,
    // so we set them manually
    negCorrelationRangeSlider.setLowValue(-1);
    negCorrelationRangeSlider.setHighValue(-0.5);

    //We want the graph to be redone if one of the following occurs:
    //1. Radio button switches between "Analyze All" and "Analyze Selected"
    compareSelectedSamplesButton.selectedProperty().addListener(observable -> {
        if ((!compareSelectedSamplesButton.isSelected() || LoadedData.getSelectedSamples().size() >= 3)
                && rankChoiceBox.getValue() != null)
            startAnalysis();
    });
    //2. Rank selection changes
    rankChoiceBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && LoadedData.getSamplesToAnalyze().size()>=3) {
            AnalysisData.setLevel_of_analysis(newValue.toLowerCase());
            startAnalysis();
        }
    });
    //3. Sample selection changes while "Analyze Selected" is selected AND at least three samples are selected
    LoadedData.getSelectedSamples().addListener((InvalidationListener) observable -> {
        if (compareSelectedSamplesButton.isSelected() && LoadedData.getSelectedSamples().size() >= 3) {
            startAnalysis();
        }
    });
    //4. Correlation radio button is changed
    pearsonCorrelationButton.selectedProperty().addListener(o -> startAnalysis());
    spearmanCorrelationButton.selectedProperty().addListener(o -> startAnalysis());
    kendallCorrelationButton.selectedProperty().addListener(o -> startAnalysis());
    //5. Global frequency threshold is changed
    excludeFrequencySlider.valueProperty().addListener(o -> startAnalysis());
}
 
開發者ID:jmueller95,項目名稱:CORNETTO,代碼行數:73,代碼來源:MainStageController.java


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