Java 类javafx.beans.binding.NumberBinding 实例源码

项目:fx-animation-editor    文件:TimelineSceneSynchronizer.java   
private NumberBinding getDouble(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) {
    DoubleBinding currentValue = ModelFunctions.toDoubleBinding(keyValue.valueProperty());
    KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame);
    KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame);

    if (earlier != null) {
        DoubleProperty earlierTime = earlier.absoluteTimeProperty();
        double earlierValue = (Double) earlier.getKeyValues().get(node).get(field).getValue();

        if (later != null) {
            DoubleProperty laterTime = later.absoluteTimeProperty();
            double laterValue = (Double) later.getKeyValues().get(node).get(field).getValue();

            DoubleBinding interpolated = Bindings.createDoubleBinding(() -> {
                double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get());
                double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction);
                return (double) Math.round(earlierValue + (laterValue - earlierValue) * 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;
    }
}
项目:Introspect-Framework    文件:RfxAppTitleBar.java   
public RfxAppTitleBar(UserInterfaceContainer userInterfaceContainer) {

    RfxWindow rfxWindow=userInterfaceContainer.get(RfxWindow.class);
    BooleanBinding windowExtraHighBinding = rfxWindow.getExtraHighBinding();

    setMinHeight(BAR_HEIGHT);

    visibleProperty().bind(windowExtraHighBinding);
    NumberBinding heightBinding = Bindings.when(windowExtraHighBinding).then(BAR_HEIGHT)
            .otherwise(0);
    minHeightProperty().bind(heightBinding);
    maxHeightProperty().bind(heightBinding);

    String title = getTitle(userInterfaceContainer);
    Label titleLabel = new Label(title);
    String style = new RfxStyleProperties()
            .setTextFill(MaterialColorSetCssName.PRIMARY.FOREGROUND1())
            .setAlignment(Pos.CENTER_LEFT).setFont(MaterialFont.getTitle())
            .setPadding(0, 0, 0, 16).toString();
    titleLabel.setStyle(style);

    getChildren().add(titleLabel);
}
项目:javafx-demos    文件:Main.java   
/**
 * @param args
 */
public static void main(String[] args) {
    Bill bill = new Bill();
    bill.amountDueProperty().addListener( new ChangeListener<Object>() {
        @Override
        public void changed(ObservableValue var, Object oldValue, Object newValue) {
            System.out.println("Bill is changed arg0 : "+var);
            System.out.println("Bill is changed arg1 : "+oldValue);
            System.out.println("Bill is changed arg2 : "+newValue);
        }
    });

    bill.setAmountDue(56);

    bill.setAmountDue(66);

    IntegerProperty num1 = new SimpleIntegerProperty(23);
    IntegerProperty num2 = new SimpleIntegerProperty(26);
    NumberBinding sum = num1.add(num2);
    System.out.println("Sum : "+sum.getValue());

    num2.set(56);
    System.out.println("Sum : "+sum.getValue());

}
项目:advanced-bindings    文件:NumberBindingsTest.java   
@Test
public void testDivideSafeDouble(){
    DoubleProperty a = new SimpleDoubleProperty();
    DoubleProperty b = new SimpleDoubleProperty();

    final NumberBinding quotient = NumberBindings.divideSafe(a, b);

    assertThat(quotient).hasValue(0.0);

    a.set(10);
    assertThat(quotient).hasValue(0.0);

    b.set(5);
    assertThat(quotient).hasValue(2.0);

    a.set(12);
    assertThat(quotient).hasValue(2.4);

    b.set(0);
    assertThat(quotient).hasValue(0.0);
}
项目:advanced-bindings    文件:NumberBindingsTest.java   
@Test
public void testDivideSafeDoubleWithDefaultValue(){
    DoubleProperty a = new SimpleDoubleProperty();
    DoubleProperty b = new SimpleDoubleProperty();

    DoubleProperty defaultValue = new SimpleDoubleProperty(3.2);

    final NumberBinding quotient = NumberBindings.divideSafe(a, b, defaultValue);

    assertThat(quotient).hasSameValue(defaultValue);
    assertThat(quotient).hasSameValue(defaultValue);

    a.set(10);
    assertThat(quotient).hasSameValue(defaultValue);

    b.set(5);
    assertThat(quotient).hasValue(2.0);

    a.set(12);
    assertThat(quotient).hasValue(2.4);

    b.set(0);
    assertThat(quotient).hasSameValue(defaultValue);
}
项目:MasteringTables    文件:ResultModel.java   
/**
 * {@inheritDoc}
 */
@Override
protected void bind() {

    final Game g = object();

    view().getTimeLabel().textProperty().bind(g.timeEllapsedProperty());

    // Bind number of success and failure to UI objects
    view().getSuccessLabel().textProperty().bind(g.successCountProperty().asString());
    view().getFailureLabel().textProperty().bind(g.failureCountProperty().asString());

    if (g.getSuccessCount() > 0) {
        // Compute Hit ratio
        final NumberBinding totalattempt = g.successCountProperty().add(g.failureCountProperty());
        final NumberBinding ratio = Bindings.when(totalattempt.greaterThan(0))
                                            .then(Bindings.divide(g.successCountProperty().multiply(100), totalattempt))
                                            .otherwise(0);

        view().getRatioLabel().textProperty().bind(ratio.asString().concat("%"));

    }
}
项目:junit    文件:TestBatchModel.java   
public NumberBinding failureFractionProperty() {
    /*
     * Note: a bug in JavaFX causes the division to be evaluated when
     * constructing the when binding, throwing an ArithmeticException.
     * 
     * As a workaround, we implement the conditional division ourselves.
     */
    // Bindings.when(runsCountProperty().isEqualTo(0)).then(0)
    // .otherwise(failedRunsCountProperty().divide(runsCountProperty()));
    return Bindings.createFloatBinding(new Callable<Float>() {
        @Override
        public Float call() throws Exception {
            int failedRuns = failedRunsCountProperty().get();
            int totalRuns = runsCountProperty().get();
            return (totalRuns == 0) ? 0f : ((float) failedRuns) / ((float) totalRuns);
        }
    }, failedRunsCountProperty(), testRunsProperty());
}
项目:jamocha    文件:NetworkVisualisation.java   
private void bindHeight() {
    if (this.groups.size() == 0) {
        this.internalHeightProperty.set(-1 * Y_SPACER);
        return;
    }
    NumberBinding lastHeight = null;
    for (GroupInterface aGroup : this.groups) {
        lastHeight = (null == lastHeight) ? Bindings.add(0, aGroup.heightProperty())
                : Bindings.max(lastHeight, aGroup.heightProperty());
    }
    if (null != this.node && this.node.isShared()) lastHeight = lastHeight.add(20);
    this.internalHeightProperty.bind(lastHeight);
}
项目:jamocha    文件:NetworkVisualisation.java   
private void bindWidth() {
    if (this.groups.size() == 0) {
        this.widthProperty.set(NODE_WIDTH);
        return;
    }
    NumberBinding lastWidth = null;
    for (GroupInterface aGroup : this.groups) {
        lastWidth = (null == lastWidth) ? Bindings.add(0, aGroup.widthProperty())
                : Bindings.add(lastWidth, aGroup.widthProperty()).add(X_SPACER);
    }
    if (null != this.node && this.node.isShared()) lastWidth = lastWidth.add(20);
    this.widthProperty.bind(lastWidth);
}
项目:circosFX    文件:Circos.java   
private QuadCurve drawCurve(double startAngle, double endAngle){
    // mmm there is something that escapes to me about getting radius back...
    DoubleProperty radius = new SimpleDoubleProperty(plotRadiusBinding.doubleValue());
    radius.bind(plotRadiusBinding);
    DoubleProperty center = new SimpleDoubleProperty(plotCenterBinding.doubleValue());
    center.bind(plotCenterBinding);

    NumberBinding xSourceBinding = new CartesianXBinding(radius, center, startAngle, circleThickness, sourceGapFromArc);
    NumberBinding ySourceBinding = new CartesianYBinding(radius, center, startAngle, circleThickness, sourceGapFromArc);
    NumberBinding xSinkBinding = new CartesianXBinding(radius, center, endAngle, circleThickness, sinkGapFromArc);
    NumberBinding ySinkBinding = new CartesianYBinding(radius, center, endAngle, circleThickness, sinkGapFromArc);

    QuadCurve quad = new QuadCurve();
    quad.setStroke(Color.GREY);


    // it could be managed also by a binder
    quad.setStrokeWidth(strokeWidth); 


    quad.setFill(null);

    quad.startXProperty().bind(xSourceBinding);
    quad.startYProperty().bind(ySourceBinding);
    quad.endXProperty().bind(xSinkBinding);
    quad.endYProperty().bind(ySinkBinding);
    quad.controlXProperty().bind(plotCenterBinding);
    quad.controlYProperty().bind(plotCenterBinding.add(linkTension));

    // Visualize arc only if it links two points that are distant enough. Check that: 
    //min(distance, 2*PI-distance) * plotRadius > threshold;
    double distance = abs(endAngle - startAngle);
    double l = min(distance, 2*PI-distance);
    BooleanBinding visibleBinding = Bindings.greaterThan(plotRadiusBinding.multiply(l), linkWidthThreshold);
    quad.visibleProperty().bind(visibleBinding);

    return quad;
}
项目:curly    文件:RunnerResult.java   
public NumberBinding getDuration() {
    return Bindings.createLongBinding(() -> {
        if (startTime.get() == -1) {
            return 0L;
        } else if (endTime.get() == -1) {
            return System.currentTimeMillis() - startTime.get();
        } else {
            return endTime.get() - startTime.get();
        }
    }, startTime, endTime);
}
项目:LogFX    文件:LogLine.java   
LogLine( BindableValue<Font> fontValue,
         NumberBinding widthProperty,
         Paint bkgColor, Paint fillColor ) {
    setBackground( FxUtils.simpleBackground( bkgColor ) );
    setTextFill( fillColor );
    fontProperty().bind( fontValue );
    minWidthProperty().bind( widthProperty );
    getStyleClass().add( "log-line" );
}
项目:LogFX    文件:LogView.java   
@MustCallOnJavaFXThread
public LogView( BindableValue<Font> fontValue,
                ReadOnlyDoubleProperty widthProperty,
                HighlightOptions highlightOptions,
                FileContentReader fileContentReader,
                TaskRunner taskRunner ) {
    this.highlightOptions = highlightOptions;
    this.fileContentReader = fileContentReader;
    this.taskRunner = taskRunner;
    this.selectionHandler = new SelectionHandler( this );
    this.file = fileContentReader.getFile();

    final LogLineColors logLineColors = highlightOptions.logLineColorsFor( "" );
    final NumberBinding width = Bindings.max( widthProperty(), widthProperty );

    logLineFactory = () -> new LogLine( fontValue, width,
            logLineColors.getBackground(), logLineColors.getFill() );

    for ( int i = 0; i < MAX_LINES; i++ ) {
        getChildren().add( logLineFactory.get() );
    }

    this.colorChangeListener = ( Observable observable ) -> {
        for ( int i = 0; i < MAX_LINES; i++ ) {
            updateLine( i );
        }
    };

    highlightOptions.getObservableExpressions().addListener( colorChangeListener );
    highlightOptions.getStandardLogColors().addListener( colorChangeListener );

    tailingFile.addListener( event -> {
        if ( tailingFile.get() ) {
            onFileChange();
        }
    } );

    this.fileChangeWatcher = new FileChangeWatcher( file, taskRunner, this::onFileChange );
}
项目:javafx-demos    文件:TableViewAutoSizeDemo.java   
@SuppressWarnings("rawtypes")
public CustomTableView(){
    this.table = new TableView<S>();
    final GridPane grid = new GridPane();
    this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) {
            grid.getColumnConstraints().clear();
            ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()];
            StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()];
            int i=0;
            for(TableColumn column : CustomTableView.this.table.getColumns()){
                CustomTableColumn col = (CustomTableColumn)column;
                ColumnConstraints consta = new ColumnConstraints();
                consta.setPercentWidth(col.getPercentWidth());

                StackPane sp = new StackPane();
                if(i==0){
                    NumberBinding diff = sp.widthProperty().subtract(3.75); // Quick fix for not showing the horizantal scroll bar.
                    column.prefWidthProperty().bind(diff);
                }else{
                    column.prefWidthProperty().bind(sp.widthProperty());
                }
                arr1[i] = consta;
                arr2[i] = sp;
                i++;
            }
            grid.getColumnConstraints().addAll(arr1);
            grid.addRow(0, arr2);
        }
    });
    getChildren().addAll(grid,table);
}
项目:javafx-demos    文件:CustomTableViewColumnResizePolicyDemo.java   
@SuppressWarnings("rawtypes")
public CustomTableView(){
    this.table = new TableView<S>();
    //this.table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    this.table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
    final GridPane grid = new GridPane();
    this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) {
            grid.getColumnConstraints().clear();
            ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()];
            StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()];
            int i=0;
            for(TableColumn column : CustomTableView.this.table.getColumns()){
                CustomTableColumn col = (CustomTableColumn)column;
                ColumnConstraints consta = new ColumnConstraints();
                consta.setPercentWidth(col.getPercentWidth());

                StackPane sp = new StackPane();
                if(i==0){
                    // Quick fix for not showing the horizantal scroll bar.
                    NumberBinding diff = sp.widthProperty().subtract(3.75); 
                    column.prefWidthProperty().bind(diff);
                }else{
                    column.prefWidthProperty().bind(sp.widthProperty());
                }
                arr1[i] = consta;
                arr2[i] = sp;
                i++;
            }
            grid.getColumnConstraints().addAll(arr1);
            grid.addRow(0, arr2);
        }
    });
    getChildren().addAll(grid,table);
}
项目:javafx-demos    文件:TableViewAutoSizeDemo.java   
@SuppressWarnings("rawtypes")
public CustomTableView(){
 this.table = new TableView<s>();
 final GridPane grid = new GridPane();

 this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){
  public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) {

   grid.getColumnConstraints().clear();
   ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()];
   StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()];

   int i=0;
   for(TableColumn column : CustomTableView.this.table.getColumns()){
    CustomTableColumn col = (CustomTableColumn)column;
    ColumnConstraints consta = new ColumnConstraints();
    consta.setPercentWidth(col.getPercentWidth());

    StackPane sp = new StackPane();
    if(i==0){
     // Quick fix for not showing the horizantal scroll bar.
     NumberBinding diff = sp.widthProperty().subtract(3.75); 
     column.prefWidthProperty().bind(diff);
    }else{
     column.prefWidthProperty().bind(sp.widthProperty());
    }
    arr1[i] = consta;
    arr2[i] = sp;
    i++;
   }

   grid.getColumnConstraints().addAll(arr1);
   grid.addRow(0, arr2);
  }
 });
 getChildren().addAll(grid,table);
}
项目:javafx-demos    文件:CustomTableView.java   
@SuppressWarnings("rawtypes")
public CustomTableView(){
    this.table = new TableView<S>();
    this.grid = new GridPane();
    this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) {
            grid.getColumnConstraints().clear();
            ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()];
            StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()];
            int i=0;
            for(TableColumn column : CustomTableView.this.table.getColumns()){
                CustomTableColumn col = (CustomTableColumn)column;
                ColumnConstraints consta = new ColumnConstraints();
                consta.setPercentWidth(col.getPercentWidth());

                StackPane sp = new StackPane();
                if(i==0){
                    NumberBinding diff = sp.widthProperty().subtract(3); // Quick fix for not showing the horizantal scroll bar.
                    column.prefWidthProperty().bind(diff);
                }else{
                    column.prefWidthProperty().bind(sp.widthProperty());
                }
                arr1[i] = consta;
                arr2[i] = sp;
                i++;
            }
            grid.getColumnConstraints().addAll(arr1);
            grid.addRow(0, arr2);
        }
    });
    getChildren().addAll(grid,table);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testSumOfFloatCollection() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding sum = CollectionBindings.sum(numbers);
    assertThat(sum).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f);

    assertThat(sum).hasValue(53.0);

    numbers.add(34f);

    assertThat(sum).hasValue(87.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfIntegerCollection() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 8, 13, 21);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfLongCollection() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfFloatCollection() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfDoubleCollection() {
    ObservableList<Double> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfIntegerCollection() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 8, 13, 21);

    assertThat(max).hasValue(21.0);

    numbers.add(34);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfLongCollection() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L);

    assertThat(max).hasValue(21.0);

    numbers.add(34L);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfFloatCollection() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f);

    assertThat(max).hasValue(21.0);

    numbers.add(34f);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfDoubleCollection() {
    ObservableList<Double> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d);

    assertThat(max).hasValue(21.0);

    numbers.add(34d);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfIntegerCollection() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 10, 21);

    assertThat(average).hasValue(7.0);

    numbers.add(42);

    assertThat(average).hasValue(12.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfLongCollection() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 10L, 21L);

    assertThat(average).hasValue(7.0);

    numbers.add(42L);

    assertThat(average).hasValue(12.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfFloatCollection() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 10f, 21f);

    assertThat(average).hasValue(7.0);

    numbers.add(42f);

    assertThat(average).hasValue(12.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfDoubleCollection() {
    ObservableList<Double> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1d, 2d, 3d, 5d, 10d, 21d);

    assertThat(average).hasValue(7.0);

    numbers.add(42d);

    assertThat(average).hasValue(12.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfIntegerCollectionWithSupplier() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, () -> 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 8, 13, 21);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfLongCollectionWithSupplier() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, () -> 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfFloatCollectionWithSupplier() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, () -> 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMinOfDoubleCollectionWithSupplier() {
    ObservableList<Double> numbers = FXCollections.observableArrayList();
    NumberBinding min = CollectionBindings.min(numbers, () -> 0);
    assertThat(min).hasValue(0.0);

    numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d);

    assertThat(min).hasValue(1.0);

    numbers.remove(0);

    assertThat(min).hasValue(2.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfIntegerCollectionWithSupplier() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, () -> 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 8, 13, 21);

    assertThat(max).hasValue(21.0);

    numbers.add(34);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfLongCollectionWithSupplier() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, () -> 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L);

    assertThat(max).hasValue(21.0);

    numbers.add(34L);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfFloatCollectionWithSupplier() {
    ObservableList<Float> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, () -> 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f);

    assertThat(max).hasValue(21.0);

    numbers.add(34f);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testMaxOfDoubleCollectionWithSupplier() {
    ObservableList<Double> numbers = FXCollections.observableArrayList();
    NumberBinding max = CollectionBindings.max(numbers, () -> 0);
    assertThat(max).hasValue(0.0);

    numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d);

    assertThat(max).hasValue(21.0);

    numbers.add(34d);

    assertThat(max).hasValue(34.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfIntegerCollectionWithSupplier() {
    ObservableList<Integer> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, () -> 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1, 2, 3, 5, 10, 21);

    assertThat(average).hasValue(7.0);

    numbers.add(42);

    assertThat(average).hasValue(12.0);
}
项目:advanced-bindings    文件:CollectionBindingsTest.java   
@Test
public void testAverageOfLongCollectionWithSupplier() {
    ObservableList<Long> numbers = FXCollections.observableArrayList();
    NumberBinding average = CollectionBindings.average(numbers, () -> 0);
    assertThat(average).hasValue(0.0);

    numbers.addAll(1L, 2L, 3L, 5L, 10L, 21L);

    assertThat(average).hasValue(7.0);

    numbers.add(42L);

    assertThat(average).hasValue(12.0);
}