本文整理汇总了Java中javafx.beans.binding.ObjectBinding类的典型用法代码示例。如果您正苦于以下问题:Java ObjectBinding类的具体用法?Java ObjectBinding怎么用?Java ObjectBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectBinding类属于javafx.beans.binding包,在下文中一共展示了ObjectBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncOrientationState
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
private void syncOrientationState() {
// Apply pseudo classes when orientation changes
labelPosition.addListener((observable, oldValue, newValue) -> {
if (newValue == HORIZONTAL) {
pseudoClassStateChanged(VERTICAL_PSEUDOCLASS_STATE, false);
pseudoClassStateChanged(HORIZONTAL_PSEUDOCLASS_STATE, true);
} else {
pseudoClassStateChanged(HORIZONTAL_PSEUDOCLASS_STATE, false);
pseudoClassStateChanged(VERTICAL_PSEUDOCLASS_STATE, true);
}
});
// Setup listeneres for wrapping
wrapWidth.addListener(((observable, oldValue, newValue) -> {
ObjectBinding<Orientation> responsiveOrientation =
createObjectBinding(() -> getWidth() < newValue ? VERTICAL : HORIZONTAL, widthProperty());
if (labelPositionProperty().isBound())
labelPositionProperty().unbind();
labelPositionProperty().bind(responsiveOrientation);
}));
}
示例2: makeOptionButton
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
/**
* Constructs one of the selection buttons for the catch selection screen.
* Binds the catch type displayed on this button to {@link CatchType#EMPTY} if place is 0, or to one of the top three catches for the trapline if place is between 1 and 3.
* @param place The button placement (ranges from 0 to 3)
* @return The catch selection button
*/
private Button makeOptionButton (int place) {
ObjectBinding<CatchType> catchType;
if (place == 0) {
catchType = Bindings.createObjectBinding(() -> CatchType.EMPTY);
} else {
catchType = Bindings.valueAt(catchTypes, place-1);
}
Button button = new Button();
button.getStyleClass().add("catch-select-option");
addBackgroundLoader(button, catchType);
button.textProperty().bind(Bindings.createStringBinding(() -> catchType.get() == null ? "..." : catchType.get().getName(), catchType));
button.setMaxSize(1000, 1000);
//button.getStyleClass().add("large-button");
GridPane.setConstraints(button, place % 2, place > 1 ? 2 : 0);
GridPane.setHgrow(button, Priority.ALWAYS);
GridPane.setVgrow(button, Priority.ALWAYS);
button.setOnAction(evt -> {
LOG.log(Level.FINE, "Selected catch: "+catchType.get());
setResult(new Catch(catchType.get()));
hide();
});
return button;
}
示例3: ItemTile
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public ItemTile(DisplayableItem item) {
Objects.requireNonNull(item);
getStyleClass().add(CSS_CLASS_ITEM_TILE);
textProperty().bind(item.getLocalizedName());
ImageView iconView = new ImageView();
iconView.imageProperty().bind(item.getIcon());
iconView.fitWidthProperty().bind(iconWidthProperty);
iconView.fitHeightProperty().bind(iconHeightProperty);
graphicProperty().bind(new ObjectBinding<Node>() {
{
bind(iconView.imageProperty());
}
@Override
protected Node computeValue() {
if (iconView.imageProperty().get() == null) {
return null;
} else {
return iconView;
}
}
});
}
示例4: computeEnd
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
static PerspectiveTransform computeEnd(ObservableValue<? extends Number> x, ObservableValue<? extends Number> y, ObservableValue<? extends Number> width, ObservableValue<? extends Number> height, ObservableValue<Pos> noEffectPos) {
double ratioX = x.getValue().doubleValue() / width.getValue().doubleValue() * 3;
double ratioY = y.getValue().doubleValue() / height.getValue().doubleValue() * 3;
ObjectBinding<Perspective> perspective = Bindings.createObjectBinding(() -> new Perspective(ratioX, ratioY, width.getValue().doubleValue(), height.getValue().doubleValue(), noEffectPos.getValue()), width, height, noEffectPos);
PerspectiveTransform effect = new PerspectiveTransform();
effect.ulxProperty().bind(createPerspectivePropertyBinding(p -> p.ulx, perspective));
effect.ulyProperty().bind(createPerspectivePropertyBinding(p -> p.uly, perspective));
effect.urxProperty().bind(createPerspectivePropertyBinding(p -> p.urx, perspective));
effect.uryProperty().bind(createPerspectivePropertyBinding(p -> p.ury, perspective));
effect.lrxProperty().bind(createPerspectivePropertyBinding(p -> p.lrx, perspective));
effect.lryProperty().bind(createPerspectivePropertyBinding(p -> p.lry, perspective));
effect.llxProperty().bind(createPerspectivePropertyBinding(p -> p.llx, perspective));
effect.llyProperty().bind(createPerspectivePropertyBinding(p -> p.lly, perspective));
return effect;
}
示例5: initialise
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public void initialise(final Button buttonUnseen, final Button buttonKnown, final Button buttonUnknown, final SessionModel sessionModel,
final ObjectBinding<WordState> wordStateProperty, final Runnable nextWordSelector) {
this.sessionModel = sessionModel;
this.nextWordSelector = nextWordSelector;
SimpleBooleanProperty editableProperty = sessionModel.editableProperty();
BooleanBinding resettableProperty = editableProperty.and(notEqual(WordState.UNSEEN, wordStateProperty));
buttonUnseen.visibleProperty().bind(resettableProperty);
buttonKnown.visibleProperty().bind(editableProperty);
buttonUnknown.visibleProperty().bind(editableProperty);
buttonUnseen.setOnAction(e -> processResponse(WordState.UNSEEN, false));
buttonKnown.setOnAction(e -> processResponse(WordState.KNOWN, true));
buttonUnknown.setOnAction(e -> processResponse(WordState.UNKNOWN, true));
}
示例6: PointingHeroIcon
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public PointingHeroIcon(ObservableEntity oe) {
super(oe);
shape = new Polygon(
0, -200, -120, 200, 120, 200
);
shape.fillProperty().bind(getPlayerColor());
ObjectBinding<Vector> angRotVector = oe.getPropertyBinding(Vector.class, "CBodyComponent.m_angRotation", null);
DoubleBinding angRot = Bindings.createDoubleBinding(() -> (double) angRotVector.get().getElement(1), angRotVector);
IntegerBinding angDiff = Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "m_anglediff", 0));
shape.translateXProperty().bind(getMapX());
shape.translateYProperty().bind(getMapY());
shape.rotateProperty().bind(getBaseAngle().add(angRot).add(angDiff));
}
示例7: doClassify
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
/**
* Perform cycle check and classification.
* @throws Exception if anything goes wrong
*/
public void doClassify() throws Exception {
// Make sure in application thread.
FxUtils.checkFxUserThread();
// Update UI.
rootName.setText(OTFUtility.getConPrefTerm(Taxonomies.SNOMED.getLenient()
.getNid()));
// Create classifier
classifier = new SnomedSnorocketClassifier();
// Do work in background.
task = new ClassifyTask();
// Bind cursor to task state.
ObjectBinding<Cursor> cursorBinding =
Bindings.when(task.runningProperty()).then(Cursor.WAIT)
.otherwise(Cursor.DEFAULT);
this.getScene().cursorProperty().bind(cursorBinding);
taskThread = new Thread(task, "classify");
taskThread.setDaemon(true);
taskThread.start();
}
示例8: VentaModel
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public VentaModel() {
subtotal = new ObjectBinding<BigDecimal>() {
@Override
protected BigDecimal computeValue() {
BigDecimal result = BigDecimal.ZERO;
for(PartidaModel pm : partidas)
result.add(pm.subtotalProperty().get());
return result;
}
};
montoDescuentos = new SimpleObjectProperty<>(BigDecimal.ZERO);
montoImpuestos = new SimpleObjectProperty<>(BigDecimal.ZERO);
total = new SimpleObjectProperty<>(BigDecimal.ZERO);
cliente = new SimpleObjectProperty<>();
partidas = FXCollections.observableArrayList();
partidas.addListener(new MyListListener());
}
示例9: init
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
private void init() {
setMnemonicParsing(false);
tooltipProperty().bind(new ObjectBinding<Tooltip>() {
{ bind(code); }
@Override
protected Tooltip computeValue() {
return new Tooltip(code.get());
}
});
}
示例10: toObjectBinding
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public static <T> ObjectBinding<T> toObjectBinding(ObservableValue<T> ov) {
return new ObjectBinding<T>() {
{
bind(ov);
}
@Override
protected T computeValue() {
return ov.getValue();
}
};
}
示例11: ColorPickerTool
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public ColorPickerTool(Color startColor) {
setMinWidth(USE_PREF_SIZE);
setMaxWidth(Double.MAX_VALUE);
setAlignment(Pos.BASELINE_LEFT);
getStyleClass().add("color-picker");
setTextFill(Color.WHITE);
color.set(startColor);
textProperty().bind(new StringBinding() {
{ bind(color); }
@Override protected String computeValue() {
return getWebColor(getColor());
}
});
setOnAction((ActionEvent arg0) -> {
if (popover == null) {
popover = new ColorPickerPopover();
popover.colorProperty().addListener((ObservableValue<? extends Color> arg1, Color arg2, Color newValue) -> {
setColor(newValue);
});
}
if (popover.isShowing()) {
popover.hide();
} else {
popover.setColor(getColor());
popover.show(ColorPickerTool.this);
}
});
Rectangle colorRect = new Rectangle();
colorRect.setWidth(16);
colorRect.setHeight(16);
colorRect.fillProperty().bind(new ObjectBinding<Paint>() { { bind(color); }
@Override protected Paint computeValue() {
return getColor();
}
});
colorRect.setEffect(new DropShadow(3, 0, 1, Color.rgb(0, 0, 0, 0.8)));
setGraphic(colorRect);
}
示例12: getColor
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
private ObjectBinding<Paint> getColor(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) {
ObjectBinding<Paint> currentValue = ModelFunctions.toPaintBinding(keyValue.valueProperty(), Color.TRANSPARENT);
KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame);
KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame);
if (earlier != null) {
DoubleProperty earlierTime = earlier.absoluteTimeProperty();
Color earlierValue = (Color) earlier.getKeyValues().get(node).get(field).getValue();
if (later != null) {
DoubleProperty laterTime = later.absoluteTimeProperty();
Color laterValue = (Color) later.getKeyValues().get(node).get(field).getValue();
ObjectBinding<Paint> interpolated = Bindings.createObjectBinding(() -> {
double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get());
double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction);
return earlierValue.interpolate(laterValue, interpolatorFactor);
}, earlierTime, laterTime, keyFrame.absoluteTimeProperty());
return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(interpolated);
} else {
return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(earlierValue);
}
} else {
return currentValue;
}
}
示例13: MainWordHandler
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
public MainWordHandler(final Label mainWord, final Label useCountLabel, final Pane mainWordPane, final SessionModel sessionModel, final ObjectBinding<WordState> wordStateProperty) {
this.mainWord = mainWord;
this.useCountLabel = useCountLabel;
this.mainWordPane = mainWordPane;
this.sessionModel = sessionModel;
this.wordStateProperty = wordStateProperty;
}
示例14: getTeamColor
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
protected ObjectBinding<Paint> getTeamColor() {
IntegerBinding teamNum = getTeamNum();
return Bindings.createObjectBinding(() -> {
int n = teamNum.get();
switch (n) {
case 2:
return Color.GREEN;
case 3:
return Color.RED;
default:
return Color.GRAY;
}
}, teamNum);
}
示例15: getPlayerColor
import javafx.beans.binding.ObjectBinding; //导入依赖的package包/类
protected ObjectBinding<Paint> getPlayerColor() {
IntegerBinding playerId = getPlayerId();
return Bindings.createObjectBinding(() -> {
int n = playerId.get();
if (n < 0 || n > 9) {
return Color.WHITE;
} else {
return PLAYER_COLORS[n];
}
}, playerId);
}