本文整理汇总了Java中javafx.beans.binding.When类的典型用法代码示例。如果您正苦于以下问题:Java When类的具体用法?Java When怎么用?Java When使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
When类属于javafx.beans.binding包,在下文中一共展示了When类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParent
import javafx.beans.binding.When; //导入依赖的package包/类
@Override
public void setParent(IComposition parent) {
this.parent = parent;
final FilterPropertiesComponent fpc = parent.getComponent(FilterPropertiesComponent.class);
// TODO maybe make this more error prone
if (fpc != null) {
Platform.runLater(() -> {
shape.fillProperty().unbind();
shape.fillProperty().bind(new When(fpc.hasColorProperty()).then(fpc.activeColorProperty()).otherwise(colorPicked));
});
}
}
示例2: addItem
import javafx.beans.binding.When; //导入依赖的package包/类
public RadialItem addItem(MenuItem item) {
final DoubleExpression idx = new SimpleDoubleProperty(items.size());
final NumberExpression itemRange = new When(params.directionProperty().isEqualTo(Direction.CW))
.then(idx.divide(itemsCount.subtract(1)))
.otherwise(itemsCount.subtract(idx.add(1)).divide(itemsCount.subtract(1)));
final DoubleExpression itemAngleDeg = correctedStreakAngleDeg.add(angularTotalSizeDeg.multiply(itemRange)).subtract(angularTotalSizeDeg.multiply(0.5));
final RadialItem itemButton = new RadialItem(params, item.getGraphic(), item.getText(), this, itemAngleDeg,
(parentSection != null) ? parentSection.nominalRadius : new SimpleDoubleProperty(0),
(item instanceof Menu));
items.add(itemButton);
radialPane.getChildren().add(itemButton);
return itemButton;
}
示例3: initButtons
import javafx.beans.binding.When; //导入依赖的package包/类
private void initButtons() {
btnBack.disableProperty().bind(currentStep.lessThanOrEqualTo(0));
btnNext.disableProperty().bind(currentStep.greaterThanOrEqualTo(steps.size() - 1));
btnCancel.textProperty().bind(
new When(currentStep.lessThan(steps.size() - 1))
.then("Cancel")
.otherwise("Start Over")
);
}
示例4: createIndicatorCircle
import javafx.beans.binding.When; //导入依赖的package包/类
private Circle createIndicatorCircle(int i) {
Circle circle = new Circle(INDICATOR_RADIUS, Color.WHITE);
circle.setStroke(Color.BLACK);
circle.fillProperty().bind(
new When(
currentStep.greaterThanOrEqualTo(i))
.then(Color.DODGERBLUE)
.otherwise(Color.WHITE));
return circle;
}
示例5: when
import javafx.beans.binding.When; //导入依赖的package包/类
/**
* A more general version of {@link Bindings#when(ObservableBooleanValue)}
* that can accept general boolean properties as conditions.
*
* @param condition the condition to bind to
*
* @see Bindings#when(ObservableBooleanValue)
*/
public static When when(Property<Boolean> condition) {
if (condition instanceof ObservableBooleanValue) {
return Bindings.when((ObservableBooleanValue) condition);
}
SimpleBooleanProperty realCondition = new SimpleBooleanProperty();
realCondition.bind(condition);
return Bindings.when(realCondition);
}
示例6: initializeProgressIndicator
import javafx.beans.binding.When; //导入依赖的package包/类
private void initializeProgressIndicator() {
// Find the progress indicator
final JFXSpinner progressIndicator = (JFXSpinner) lookup("#progressIndicator");
// If the query is running show the indicator, otherwise hide it
progressIndicator.visibleProperty().bind(new When(query.queryStateProperty().isEqualTo(QueryState.RUNNING)).then(true).otherwise(false));
}
示例7: initMenu
import javafx.beans.binding.When; //导入依赖的package包/类
private void initMenu() {
Menu fileMenu = new Menu(EditorConfig.MENU_FILE);
MenuItem openFile = new MenuItem(EditorConfig.MENU_FILE_OPEN);
FontAwesomeIconView openView = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN);
openFile.setGraphic(openView);
MenuItem saveFile = new MenuItem(EditorConfig.MENU_FILE_SAVE);
FontAwesomeIconView saveView = new FontAwesomeIconView(FontAwesomeIcon.SAVE);
saveFile.setGraphic(saveView);
fileMenu.getItems().addAll(openFile, saveFile);
Menu toolMenu = new Menu(EditorConfig.MENU_TOOL);
MenuItem randomName = new MenuItem(EditorConfig.MENU_TOOL_RANDOM);
BooleanBinding when = new When(Bindings.createBooleanBinding(() -> torrentProperty.getValue() == null, torrentProperty)).then(true).otherwise(false);
randomName.disableProperty().bind(when);
saveFile.disableProperty().bind(when);
centerBtn.visibleProperty().bind(when);
fileTree.visibleProperty().bind(when.not());
toolMenu.getItems().add(randomName);
menuBar.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null)));
menuBar.getMenus().addAll(fileMenu, toolMenu);
openFile.setOnAction(event -> openFile());
saveFile.setOnAction((event) -> saveFile());
randomName.setOnAction(event -> randomNameAll(itemRoot));
}
示例8: initialize
import javafx.beans.binding.When; //导入依赖的package包/类
@FXML
private void initialize() {
mControlOffsetX.set(100.0);
mControlOffsetY.set(50.0);
mControlDirectionX1.bind(new When (
node_link.startXProperty().greaterThan(node_link.endXProperty()))
.then(-1.0).otherwise(1.0));
mControlDirectionX2.bind(new When (
node_link.startXProperty().greaterThan(node_link.endXProperty()))
.then(1.0).otherwise(-1.0));
node_link.controlX1Property().bind(
Bindings.add(
node_link.startXProperty(), mControlOffsetX.multiply(mControlDirectionX1)
)
);
node_link.controlX2Property().bind(
Bindings.add(
node_link.endXProperty(), mControlOffsetX.multiply(mControlDirectionX2)
)
);
node_link.controlY1Property().bind(
Bindings.add(
node_link.startYProperty(), mControlOffsetY.multiply(mControlDirectionY1)
)
);
node_link.controlY2Property().bind(
Bindings.add(
node_link.endYProperty(), mControlOffsetY.multiply(mControlDirectionY2)
)
);
}
示例9: initButtons
import javafx.beans.binding.When; //导入依赖的package包/类
private void initButtons() {
btnBack.disableProperty().bind( currentStep.lessThanOrEqualTo(0) );
btnNext.disableProperty().bind( currentStep.greaterThanOrEqualTo(steps.size()-1) );
btnCancel.textProperty().bind(
new When(
currentStep.lessThan(steps.size()-1)
)
.then("Cancel")
.otherwise("Start Over")
);
}
示例10: createIndicatorCircle
import javafx.beans.binding.When; //导入依赖的package包/类
private Circle createIndicatorCircle(int i) {
Circle circle = new Circle(INDICATOR_RADIUS, Color.WHITE);
circle.setStroke(Color.BLACK);
circle.fillProperty().bind(
new When(
currentStep.greaterThanOrEqualTo(i))
.then(Color.DODGERBLUE)
.otherwise(Color.WHITE));
return circle;
}
示例11: RfxTabButton
import javafx.beans.binding.When; //导入依赖的package包/类
public RfxTabButton(RfxWindow rfxWindow, View tab) {
super(tab.getViewTitle());
this.rfxWindow = rfxWindow;
this.tab = tab;
setButtonType(ButtonType.FLAT);
setMinHeight(HEIGHT);
setPadding(new Insets(0, PADDING, 0, PADDING));
setMaxWidth(MAX_WIDTH);
When whenTabSelected = Bindings.when(rfxWindow.getSelectedTabProperty().isEqualTo(tab));
ObservableValue<String> styleBinding = createStyleBinding(whenTabSelected);
styleProperty().bind(styleBinding);
setOnAction(this::onAction);
}
示例12: createStyleBinding
import javafx.beans.binding.When; //导入依赖的package包/类
private ObservableValue<String> createStyleBinding(
When whenTabSelected) {
String selectedTabStyle = new RfxStyleProperties().setTextFill(MaterialColorSetCssName.PRIMARY.FOREGROUND1())
.setBorderWidth(0,0,4,0)
.setBorderColor(MaterialColorSetCssName.ACCENT.BACKGROUND())
.setFont(MaterialFont.getBody2(DisplayScale.NONE_DENSE)).toString();
String unselectedTabStyle = new RfxStyleProperties().setTextFill(MaterialColorSetCssName.PRIMARY.FOREGROUND2())
.setBorderWidth(0,0,4,0)
.setBorderColor(MaterialColorSetCssName.PRIMARY.BACKGROUND())
.setFont(MaterialFont.getBody2(DisplayScale.NONE_DENSE)).toString();
ObservableValue<String> styleBinding=whenTabSelected.then(selectedTabStyle).otherwise(unselectedTabStyle);
return styleBinding;
}
示例13: initializeLabel
import javafx.beans.binding.When; //导入依赖的package包/类
private void initializeLabel() {
final Label label = (Label) lookup("#label");
final JFXTextField textField = (JFXTextField) lookup("#textField");
final Path shape = (Path) lookup("#shape");
final Insets insets = new Insets(0,2,0,2);
textField.setPadding(insets);
label.setPadding(insets);
final int padding = 0;
label.layoutBoundsProperty().addListener((obs, oldBounds, newBounds) -> {
double newWidth = Math.max(newBounds.getWidth(), 10);
final double res = GRID_SIZE * 2 - (newWidth % (GRID_SIZE * 2));
newWidth += res;
textField.setMinWidth(newWidth);
textField.setMaxWidth(newWidth);
l2.setX(newWidth + padding);
l3.setX(newWidth + padding);
setMinWidth(newWidth + padding);
setMaxWidth(newWidth + padding);
textField.setMinHeight(TAG_HEIGHT);
textField.setMaxHeight(TAG_HEIGHT);
textField.focusedProperty().addListener((observable, oldFocused, newFocused) -> {
if (newFocused) {
shape.setTranslateY(2);
textField.setTranslateY(2);
}
});
if (getWidth() >= 1000) {
setWidth(newWidth);
setHeight(TAG_HEIGHT);
shape.setTranslateY(-1);
textField.setTranslateY(-1);
}
// Fixes the jumping of the shape when the text field is empty
if (textField.getText().isEmpty()) {
shape.setLayoutX(0);
}
});
label.textProperty().bind(new When(textField.textProperty().isNotEmpty()).then(textField.textProperty()).otherwise(textField.promptTextProperty()));
}
示例14: initializeLabel
import javafx.beans.binding.When; //导入依赖的package包/类
private Label initializeLabel() {
final Label label = new Label();
// Add the caption text-size class, and make the text white
label.getStyleClass().addAll("caption", "white-text");
DoubleBinding lx = new DoubleBinding() {
{
super.bind(ax, bx, cx, label.widthProperty());
}
@Override
protected double computeValue() {
return (ax.get() + bx.get() + cx.get()) / 3 - label.widthProperty().get() / 2;
}
};
DoubleBinding ly = new DoubleBinding() {
{
super.bind(ay, by, cy, label.heightProperty());
}
@Override
protected double computeValue() {
return (ay.get() + by.get() + cy.get()) / 3 - label.heightProperty().get() / 2;
}
};
// Bind the label to the centroid of the triangle
label.layoutXProperty().bind(lx);
label.layoutYProperty().bind(ly);
// Display the label U - for urgent
label.setText("U");
// Bind the isUrgent stringBinder to hide and show the label
label.opacityProperty().bind(new When(isUrgent).then(1d).otherwise(0d));
// Rotate the label back so that it is always displayed as U
label.rotateProperty().bind(this.rotateProperty().multiply(-1));
return label;
}
示例15: initialize
import javafx.beans.binding.When; //导入依赖的package包/类
public void initialize() {
comments.showingProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
AppBar appBar = getApp().getAppBar();
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e ->
getApp().showLayer(DRAWER_LAYER)));
appBar.setTitleText("Comments");
}
});
FloatingActionButton floatingActionButton = new FloatingActionButton();
floatingActionButton.textProperty().bind(new When(userProperty().isNotNull())
.then(MaterialDesignIcon.ADD.text)
.otherwise(MaterialDesignIcon.CLOUD_DOWNLOAD.text));
floatingActionButton.setOnAction(e -> {
if (service.getUser() == null) {
service.retrieveComments();
} else {
EDITION_VIEW.switchView();
}
});
comments.getLayers().add(floatingActionButton.getLayer());
commentsList.setCellFactory(cell -> {
final CommentListCell commentListCell = new CommentListCell(
service,
// left button: delete comment, only author's comment can delete it
c -> {
if (service.getUser().getNetworkId().equals(c.getNetworkId())) {
showDialog(c);
}
},
// right button: edit comment, everybody can view it, only author can edit it
c -> {
service.activeCommentProperty().set(c);
EDITION_VIEW.switchView();
});
// notify view that cell is sliding
sliding.bind(commentListCell.slidingProperty());
return commentListCell;
});
final Label label = new Label(SIGN_IN_MESSAGE);
label.textProperty().bind(new When(userProperty().isNotNull())
.then(NO_COMMENTS_MESSAGE)
.otherwise(SIGN_IN_MESSAGE));
commentsList.setPlaceholder(label);
commentsList.disableProperty().bind(service.userProperty().isNull());
commentsList.setItems(service.commentsProperty());
comments.addEventHandler(LifecycleEvent.SHOWN, new EventHandler<LifecycleEvent>() {
@Override
public void handle(LifecycleEvent event) {
comments.removeEventHandler(LifecycleEvent.SHOWN, this);
service.retrieveComments();
}
});
// block scrolling when sliding
comments.addEventFilter(ScrollEvent.ANY, e -> {
if (sliding.get() && e.getDeltaY() != 0) {
e.consume();
}
});
}