本文整理汇总了Java中javafx.beans.binding.DoubleExpression类的典型用法代码示例。如果您正苦于以下问题:Java DoubleExpression类的具体用法?Java DoubleExpression怎么用?Java DoubleExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleExpression类属于javafx.beans.binding包,在下文中一共展示了DoubleExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initProgressBinding
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private void initProgressBinding() {
DoubleExpression tmp = constantOf(0);
for (Command command : registeredCommands) {
final ReadOnlyDoubleProperty progressProperty = command.progressProperty();
/**
* When the progress of a command is "undefined", the progress property has a value of -1.
* But in our use case we like to have a value of 0 in this case.
* Therefore we create a custom binding here.
*/
final DoubleBinding normalizedProgress = Bindings
.createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(),
progressProperty);
tmp = tmp.add(normalizedProgress);
}
int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size();
progress.bind(Bindings.divide(tmp, divisor));
}
示例2: bindCoords
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private void bindCoords() {
final DoubleExpression radius = model.sizeProperty().multiply(0.5);
final Translate translation = new Translate();
translation.xProperty().bind(transformRadius);
final Rotate rotation = new Rotate();
rotation.pivotXProperty().bind(transformRadius.subtract(radius).multiply(-1));
rotation.pivotYProperty().bind(radius);
rotation.angleProperty().bind(transformAngle);
button.getTransforms().addAll(translation, rotation);
final Rotate twist = new Rotate();
twist.pivotXProperty().bind(radius);
twist.pivotYProperty().bind(radius);
twist.angleProperty().bind(transformAngle.multiply(-1.0d));
button.getTransforms().add(twist);
model.visibleProperty().addListener((observable) -> {
updateVisibility();
});
}
示例3: addItem
import javafx.beans.binding.DoubleExpression; //导入依赖的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;
}
示例4: changed
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends Number> sourceProperty,
Number oldValue, Number newValue) {
if (!updating) {
final DoubleProperty property1 = propertyRef1.get();
final DoubleExpression property2 = propertyRef2.get();
if ((property1 == null) || (property2 == null)) {
if (property2 != null) {
property2.removeListener(this);
}
} else {
try {
updating = true;
property1.setValue(property2.getValue());
} catch (RuntimeException e) {
property1.setValue(oldValue.doubleValue());
throw new RuntimeException(
"TransparentBinding binding failed, setting to the previous value",
e);
} finally {
updating = false;
}
}
}
}
示例5: createZoomMenus
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public MenuItem createZoomMenus() {
Integer zoomValue = getDefaultZoom();
R.mainStyle.fontSizeProperty().bind(DoubleExpression.doubleExpression(zoomSpinner.valueProperty()).multiply(0.13d));
zoomSpinner.getValueFactory().setValue(zoomValue.doubleValue());
Label l = new Label("Zoom", zoomSpinner);
l.setContentDisplay(ContentDisplay.RIGHT);
return new CustomMenuItem(l, false);
}
示例6: ObservableBounds
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public ObservableBounds(DoubleExpression minX, DoubleExpression minY, DoubleExpression maxX, DoubleExpression maxY) {
this();
requireNonNull(minX, "Parameter 'minX' is null");
requireNonNull(minY, "Parameter 'minY' is null");
requireNonNull(maxX, "Parameter 'maxX' is null");
requireNonNull(maxY, "Parameter 'maxY' is null");
this.minX.bind(minX);
this.minY.bind(minY);
this.maxX.bind(maxX);
this.maxY.bind(maxY);
}
示例7: regenerateMenu
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private void regenerateMenu(Menu menu, Node parentNode, RadialMenuSectionDynamic parentSection) {
final Optional<RadialItem> oParentItem = ((parentNode != null) && (parentSection != null))
? parentSection.getItems().stream().filter(radialItem -> radialItem.getNode().equals(parentNode)).findFirst()
: Optional.empty();
final DoubleExpression streakAngle = oParentItem.isPresent() ? oParentItem.get().angleProperty() : null;
final RadialMenuSectionDynamic menuSection = new RadialMenuSectionDynamic(params, radialPane, parentSection, streakAngle);
if (params.getTopSection() == null) params.setTopSection(menuSection);
menu.getItems().forEach((item) -> {
final RadialItem itemButton = menuSection.addItem(item);
if (item instanceof Menu) {
final Menu subMenu = (Menu) item;
createTrigger(itemButton, subMenu, menuSection);
regenerateMenu(subMenu, itemButton, menuSection);
} else {
createAction(itemButton, item);
}
});
sections.put(menu, menuSection);
}
示例8: testDoubleExpression
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
@Test
public void testDoubleExpression(){
final DoubleExpression actual = DoubleExpression.doubleExpression(new SimpleDoubleProperty(12.2));
assertThat(actual).hasValue(12.2);
assertThat(actual).hasSameValue(actual);
}
示例9: bind
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public static TransparentBinding bind(DoubleProperty property1,
DoubleExpression property2) {
checkParameters(property1, property2);
final TransparentBinding binding = new TransparentBinding(property1,
property2);
property1.setValue(property2.getValue());
property2.addListener(binding);
return binding;
}
示例10: BidirectionalDifferenceBinding
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private BidirectionalDifferenceBinding(DoubleProperty property1,
DoubleProperty property2, DoubleExpression difference) {
cachedHashCode = property1.hashCode() * property2.hashCode()
* difference.hashCode();
propertyRef1 = new WeakReference<DoubleProperty>(property1);
propertyRef2 = new WeakReference<DoubleProperty>(property2);
differenceRef = new WeakReference<DoubleExpression>(difference);
}
示例11: bind
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public static BidirectionalDifferenceBinding bind(DoubleProperty property1,
DoubleProperty property2, DoubleExpression difference) {
checkParameters(property1, property2, difference);
final BidirectionalDifferenceBinding binding = new BidirectionalDifferenceBinding(
property1, property2, difference);
property2.setValue(property1.getValue() - difference.getValue());
property1.addListener(binding);
property2.addListener(binding);
difference.addListener(binding);
return binding;
}
示例12: ObservablePoint2D
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public ObservablePoint2D(DoubleExpression x, DoubleExpression y) {
LOGGER.trace("ObservablePoint2D(x={}, y={})", x, y);
this.x.bind(x);
this.y.bind(y);
}
示例13: ObservableDimension2D
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public ObservableDimension2D(DoubleExpression width, DoubleExpression height) {
LOGGER.trace("ObservableDimension2D(width={}, height={})", width, height);
this.width.bind(width);
this.height.bind(height);
}
示例14: RadialItem
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public RadialItem(Params params, Node graphics, String text, RadialMenuSectionDynamic parentPane, DoubleExpression angle, DoubleExpression fromRadius, boolean withCaret) {
this.button = generateButton(params, graphics, text);
this.angle.bind(angle);
this.parentPane = parentPane;
this.fromRadius = fromRadius;
diameter.bind(button.prefHeightProperty());
transformOpacity.set(0);
transformAngle.set(0);
transformRadius.set(0);
final DoubleBinding itemRadius = diameter.multiply(0.5);
final Translate translation = new Translate();
translation.xProperty().bind(transformRadius);
final Rotate rotation = new Rotate();
rotation.pivotXProperty().bind(transformRadius.subtract(itemRadius).multiply(-1));
rotation.pivotYProperty().bind(itemRadius);
rotation.angleProperty().bind(transformAngle);
final Rotate twist = new Rotate();
twist.pivotXProperty().bind(itemRadius);
twist.pivotYProperty().bind(itemRadius);
twist.angleProperty().bind(transformAngle.multiply(-1.0d));
setVisible(false);
setMouseTransparent(true);
getTransforms().addAll(translation, rotation);
button.getTransforms().add(twist);
opacityProperty().bind(transformOpacity);
getChildren().add(button);
if (withCaret) {
this.caret = generateCaret();
final Translate caretTranslation = new Translate();
caretTranslation.xProperty().bind(diameter.add(params.buttonWidthOffsetProperty().multiply(0.5)));
caret.getTransforms().add(caretTranslation);
getChildren().add(caret);
}
else {
caret = null;
}
//this.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN, null, null)));
//this.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, null, BorderWidths.DEFAULT)));
}
示例15: setupCircle
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private void setupCircle(Circle c, DoubleExpression centerOffset, DoubleExpression radius) {
c.radiusProperty().bind(radius);
c.centerXProperty().bind(centerOffset);
c.centerYProperty().bind(centerOffset);
}