本文整理汇总了Java中javafx.beans.binding.DoubleExpression类的典型用法代码示例。如果您正苦于以下问题:Java DoubleExpression类的具体用法?Java DoubleExpression怎么用?Java DoubleExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleExpression类属于javafx.beans.binding包,在下文中一共展示了DoubleExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:cmlanche,项目名称:easyMvvmFx,代码行数:22,代码来源:CompositeCommand.java
示例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();
});
}
开发者ID:dejv78,项目名称:j.commons,代码行数:24,代码来源:RadialMenuSkinBase.java
示例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;
}
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:18,代码来源:RadialMenuSectionDynamic.java
示例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;
}
}
}
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:26,代码来源:TransparentBinding.java
示例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);
}
开发者ID:salimvanak,项目名称:myWMS,代码行数:9,代码来源:MyWMS.java
示例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);
}
开发者ID:dejv78,项目名称:j.commons,代码行数:13,代码来源:ObservableBounds.java
示例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);
}
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:28,代码来源:RadialMenuDynamic.java
示例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);
}
开发者ID:lestard,项目名称:assertj-javafx,代码行数:9,代码来源:DoubleTest.java
示例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;
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:10,代码来源:TransparentBinding.java
示例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);
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:9,代码来源:BidirectionalDifferenceBinding.java
示例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;
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:12,代码来源:BidirectionalDifferenceBinding.java
示例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);
}
开发者ID:dejv78,项目名称:j.commons,代码行数:7,代码来源:ObservablePoint2D.java
示例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);
}
开发者ID:dejv78,项目名称:j.commons,代码行数:7,代码来源:ObservableDimension2D.java
示例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)));
}
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:52,代码来源:RadialItem.java
示例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);
}
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:6,代码来源:RadialDebug.java
示例16: RadialMenuSectionDynamic
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
public RadialMenuSectionDynamic(Params params, RadialPane radialPane, RadialMenuSectionDynamic parentSection, DoubleExpression streakAngleDeg) {
this.params = params;
this.radialPane = radialPane;
this.parentSection = parentSection;
this.radialPane.addRadialSection(this);
if (streakAngleDeg != null) {
this.streakAngleDeg.bind(streakAngleDeg);
} else {
this.streakAngleDeg.bind(params.angleFromDegProperty()
.add(params.angleToDegProperty().subtract(params.angleFromDegProperty()).multiply(0.5d)));
}
itemsCount = new SimpleListProperty<>(items).sizeProperty();
final DoubleExpression itemRadiusHalf = params.buttonSizeProperty().multiply(0.5);
if (parentSection != null) {
innerRadius.bind(parentSection.outerRadiusProperty().add(itemRadiusHalf.multiply(params.spacingFactorProperty().multiply(2))));
} else {
innerRadius.bind(params.minRadiusProperty());
}
final DoubleExpression angleDeg = params.angleToDegProperty().subtract(params.angleFromDegProperty());
final DoubleExpression angleRad = new FunctionDoubleBinding(Math::toRadians, angleDeg);
final DoubleExpression availablePerimeter = angleRad.multiply(innerRadius.add(itemRadiusHalf));
final DoubleExpression gapSize = params.buttonSizeProperty().multiply(params.gapFactorProperty());
final DoubleExpression allItemsSize = params.buttonSizeProperty().multiply(itemsCount.subtract(1));
final DoubleExpression totalSize = allItemsSize.add(gapSize.multiply(itemsCount.subtract(1)));
final NumberBinding candidateNominalRadius = new When(availablePerimeter.greaterThan(totalSize))
.then(innerRadius.add(itemRadiusHalf))
.otherwise(totalSize.divide(angleRad));
final DoubleExpression candidateAngularTotalSizeDeg = new FunctionDoubleBinding(Math::toDegrees, totalSize.divide(candidateNominalRadius));
final DoubleExpression candidateAngularItemSizeDeg = candidateAngularTotalSizeDeg.divide(itemsCount);
final DoubleExpression angularTotalSizeWithOverlapDeg = candidateAngularTotalSizeDeg.add(candidateAngularItemSizeDeg);
nominalRadius.bind(candidateNominalRadius.add(new When(angularTotalSizeWithOverlapDeg.greaterThan(TWO_PI))
.then(totalSize.divide(angularTotalSizeWithOverlapDeg.subtract(TWO_PI)))
.otherwise(0)));
angularTotalSizeDeg = new FunctionDoubleBinding(Math::toDegrees, totalSize.divide(nominalRadius));
// TODO: Make sure, that outerRadius is reasonably small to prevent "large texture" errors
outerRadius.bind(nominalRadius.add(itemRadiusHalf.add(params.buttonWidthOffsetProperty())));
params.centerOffsetProperty().add(outerRadius);
fromAngleDeg.bind(this.streakAngleDeg.subtract(angularTotalSizeDeg.multiply(0.5)));
toAngleDeg.bind(this.streakAngleDeg.add(angularTotalSizeDeg.multiply(0.5)));
correctedStreakAngleDeg.bind(this.streakAngleDeg.add(new When(fromAngleDeg.lessThan(params.angleFromDegProperty()))
.then(params.angleFromDegProperty().subtract(fromAngleDeg))
.otherwise(new When(toAngleDeg.greaterThan(params.angleToDegProperty()))
.then(params.angleToDegProperty().subtract(toAngleDeg))
.otherwise(0))));
toAngleDeg.bind(fromAngleDeg.add(angularTotalSizeDeg));
angularItemSizeDeg.bind(angularTotalSizeDeg.divide(itemsCount));
final Circle perimeter = setupPerimeter(params);
radialPane.getChildren().add(perimeter);
params.centerOffsetProperty().addListener(observable -> radialPane.layout());
totalSize.addListener((sender, oldV, newV) -> System.out.println(this + " [" + itemsCount.intValue() + "] totalSize: " + newV));
nominalRadius.addListener((sender, oldV, newV)-> System.out.println(this + " [" + itemsCount.intValue() + "] nominalRadius: " + newV));
angularTotalSizeDeg.addListener((sender, oldV, newV)-> System.out.println(this + " [" + itemsCount.intValue() + "] ang. size (deg): " + newV));
}
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:75,代码来源:RadialMenuSectionDynamic.java
示例17: TransparentBinding
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
private TransparentBinding(DoubleProperty property1,
DoubleExpression property2) {
cachedHashCode = property1.hashCode() * property2.hashCode();
propertyRef1 = new WeakReference<DoubleProperty>(property1);
propertyRef2 = new WeakReference<DoubleExpression>(property2);
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:7,代码来源:TransparentBinding.java
示例18: getProperty2
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
protected DoubleExpression getProperty2() {
return propertyRef2.get();
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:4,代码来源:TransparentBinding.java
示例19: getDifference
import javafx.beans.binding.DoubleExpression; //导入依赖的package包/类
protected DoubleExpression getDifference() {
return differenceRef.get();
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:4,代码来源:BidirectionalDifferenceBinding.java
示例20: 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 DoubleProperty property2 = propertyRef2.get();
final DoubleExpression difference = differenceRef.get();
if ((property1 == null) || (property2 == null)
|| (difference == null)) {
if (property1 != null) {
property1.removeListener(this);
}
if (property2 != null) {
property2.removeListener(this);
}
if (difference != null) {
difference.removeListener(this);
}
} else {
try {
updating = true;
if (property2 == sourceProperty) {
if (!property1.isBound()) {
property1.set(newValue.doubleValue()
- difference.doubleValue());
} else {
System.out
.println("Property 2 changed, Property 1 bound");
}
} else if (property1 == sourceProperty) {
if (!property2.isBound()) {
property2.set(newValue.doubleValue()
+ difference.doubleValue());
} else {
System.out
.println("Property 1 changed, Property 2 bound");
}
} else {
if (!property2.isBound()) {
property2.set(property1.doubleValue()
+ newValue.doubleValue());
} else if (!property1.isBound()) {
property1.set(property2.doubleValue()
- newValue.doubleValue());
} else {
System.out
.println("Difference Changed, Properties 1 & 2 bound");
}
}
} catch (RuntimeException e) {
e.printStackTrace();
if (property2 == sourceProperty) {
property2.set(oldValue.doubleValue());
System.out
.println("Exception thrown, Property 2 reset");
} else if (property1 == sourceProperty) {
property1.set(oldValue.doubleValue());
System.out
.println("Exception thrown, Property 1 reset");
}
throw new RuntimeException(
"BidirectionalDifferenceBinding binding failed, setting to the previous value",
e);
} finally {
updating = false;
}
}
}
}
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:70,代码来源:BidirectionalDifferenceBinding.java
注:本文中的javafx.beans.binding.DoubleExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论