本文整理汇总了Java中javafx.beans.binding.IntegerBinding类的典型用法代码示例。如果您正苦于以下问题:Java IntegerBinding类的具体用法?Java IntegerBinding怎么用?Java IntegerBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntegerBinding类属于javafx.beans.binding包,在下文中一共展示了IntegerBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PointingHeroIcon
import javafx.beans.binding.IntegerBinding; //导入依赖的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));
}
示例2: testDivideSafeIntegerWithDefaultValue
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
@Test
public void testDivideSafeIntegerWithDefaultValue(){
IntegerProperty a = new SimpleIntegerProperty();
IntegerProperty b = new SimpleIntegerProperty();
IntegerProperty defaultValue = new SimpleIntegerProperty(10);
final IntegerBinding quotient = NumberBindings.divideSafe(a, b, defaultValue);
assertThat(quotient).hasSameValue(defaultValue);
a.set(10);
assertThat(quotient).hasSameValue(defaultValue);
b.set(5);
assertThat(quotient).hasValue(2);
a.set(12);
assertThat(quotient).hasValue(2);
b.set(0);
assertThat(quotient).hasSameValue(defaultValue);
}
示例3: convertXModelCoordinateToXPixelCoordinate
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
private IntegerBinding convertXModelCoordinateToXPixelCoordinate(ObservableDoubleValue xModel)
{
return new IntegerBinding() {
{
this.bind(xModel,oneUnitInModelEqualsHowManyPixels,pixelOffsetToSimulateNegativeXCoordinate);
}
@Override
protected int computeValue() {
int newValue = (int) Math.round(xModel.get() * oneUnitInModelEqualsHowManyPixels.get() +
pixelOffsetToSimulateNegativeXCoordinate.doubleValue());
assert newValue >= 0; //new value must always be positive!
return newValue;
}
};
}
示例4: convertYModelCoordinateToYPixelCoordinate
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
private IntegerBinding convertYModelCoordinateToYPixelCoordinate(ObservableDoubleValue yModel)
{
return new IntegerBinding() {
{
this.bind(yModel,oneUnitInModelEqualsHowManyPixels,pixelOffsetToSimulateNegativeYCoordinate);
}
@Override
protected int computeValue() {
int newValue = (int) Math.round(yModel.get() * oneUnitInModelEqualsHowManyPixels.get() +
pixelOffsetToSimulateNegativeYCoordinate.doubleValue());
assert newValue >= 0; //new value must always be positive!
return newValue;
}
};
}
示例5: test
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
@Test
public void test() {
IntegerProperty src = new SimpleIntegerProperty(0);
IntegerBinding twice = src.multiply(2);
Var<Number> twiceVar = Var.fromVal(twice, n -> src.set(n.intValue() / 2));
List<Number> values = new ArrayList<>();
EventStreams.valuesOf(twiceVar).subscribe(values::add);
src.set(1);
twiceVar.setValue(4);
twiceVar.setValue(5); // no effect
twiceVar.setValue(7); // will become 6
assertEquals(Arrays.asList(0, 2, 4, 6), values);
}
示例6: toIntegerBinding
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
public static IntegerBinding toIntegerBinding(ObservableValue<? extends Number> ov) {
return new IntegerBinding() {
{
bind(ov);
}
@Override
protected int computeValue() {
return ov.getValue() == null ? 0 : ov.getValue().intValue();
}
};
}
示例7: getTeamColor
import javafx.beans.binding.IntegerBinding; //导入依赖的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);
}
示例8: getPlayerColor
import javafx.beans.binding.IntegerBinding; //导入依赖的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);
}
示例9: failedRunsCountProperty
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
public IntegerBinding failedRunsCountProperty() {
return Bindings.createIntegerBinding(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
int result = 0;
for (TestRunModel testRunModel : getTestRuns()) {
if (testRunModel.getRun().isFailedRun()) result++;
}
return result;
}
}, testRunsProperty());
}
示例10: setupStatesPane
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
private Pane setupStatesPane() {
final Label titleLabel = new Label("All execution states (0)");
nbStates.addListener((v, o, n) -> {
String s = "All execution states (" + n.intValue() + ")";
Platform.runLater(() -> {
titleLabel.setText(s);
titleLabel.setContentDisplay(ContentDisplay.RIGHT);
final ImageView nodeGraphic = new ImageView();
nodeGraphic.setImage(playGraphic);
titleLabel.setGraphic(nodeGraphic);
isInReplayMode.addListener((val, old, neu) -> {
if (old != neu) {
if (neu) {
nodeGraphic.setImage(replayGraphic);
} else {
nodeGraphic.setImage(playGraphic);
}
}
});
});
});
titleLabel.setFont(statesFont);
VBox.setMargin(titleLabel, HALF_MARGIN_INSETS);
titleLabel.setAlignment(Pos.CENTER);
final ScrollBar scrollBar = new ScrollBar();
scrollBar.setVisibleAmount(1);
scrollBar.setBlockIncrement(10);
scrollBar.setMin(0);
final IntegerBinding statesRange = visibleStatesRange.subtract(1);
scrollBar.disableProperty().bind(statesRange.lessThanOrEqualTo(0));
scrollBar.maxProperty().bind(statesRange);
scrollBar.valueProperty().addListener((v, o, n) -> {
if (o.intValue() != n.intValue() && n.intValue() != currentState.intValue()) {
currentState.set(n.intValue());
}
});
currentState.addListener((v, o, n) -> {
if (o.intValue() != n.intValue() && n.intValue() != scrollBar.valueProperty().intValue()) {
scrollBar.setValue(n.intValue());
}
});
final HBox hBox = new HBox();
final Polygon arrow = new Polygon(2.5, 10, 10, 5, 2.5, 0);
HBox.setMargin(arrow, HALF_MARGIN_INSETS);
final Label toggleValuesLabel = new Label("Timeline for dynamic information ");
toggleValuesLabel.setFont(statesFont);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().addAll(arrow, toggleValuesLabel);
hBox.setCursor(Cursor.HAND);
hBox.setOnMouseClicked((e) -> {
if (bodyScrollPane.isVisible()) {
bodyScrollPane.setVisible(false);
arrow.setRotate(0);
} else {
bodyScrollPane.setVisible(true);
arrow.setRotate(90);
}
});
VBox.setMargin(hBox, HALF_MARGIN_INSETS);
headerPane.getChildren().addAll(scrollBar, titleLabel, statesPane, hBox);
VBox.setMargin(statesPane, MARGIN_INSETS);
return headerPane;
}
示例11: CalculateNewIndicatorCanvasHeight
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
public void CalculateNewIndicatorCanvasHeight(){
//This binding will make sure the main chart height is always roughly twice as indicator's height
IntegerBinding size = (IntegerBinding) Bindings.size(chartPaneList).add(new SimpleIntegerProperty(2));
NumberBinding sub = Bindings.divide(chartAreaHeight, size);
indicatorCanvasHeightProperty.setValue(sub.getValue());
}
示例12: selectInteger
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
public IntegerBinding selectInteger(Function<S, ? extends ObservableIntegerValue> childPropertyAccessor) {
return selectInteger(childPropertyAccessor, 0);
}
示例13: mapToInteger
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
public IntegerBinding mapToInteger(Function<S, Integer> childValueAccessor) {
return mapToInteger(childValueAccessor, 0);
}
示例14: getCellX
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
protected IntegerBinding getCellX() {
return Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "CBodyComponent.m_cellX", 0));
}
示例15: getCellY
import javafx.beans.binding.IntegerBinding; //导入依赖的package包/类
protected IntegerBinding getCellY() {
return Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "CBodyComponent.m_cellY", 0));
}