javafx.beans.binding.NumberBinding Java Examples

The following examples show how to use javafx.beans.binding.NumberBinding. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainSceneController.java    From JavaFX-Tutorial-Codes with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(URL url, ResourceBundle rb) {
    SimpleIntegerProperty a = new SimpleIntegerProperty(5);
    SimpleIntegerProperty b = new SimpleIntegerProperty(10);
    NumberBinding sum = a.add(b);
    System.out.println(sum.getValue());
    a.set(20);
    System.out.println(sum.getValue());

    textField.textProperty().bind(stringProperty);
    MyTask myTask = new MyTask();
    textField.setOnMouseClicked(event -> {
        Timer timer = new Timer(true);
        timer.scheduleAtFixedRate(myTask, 0, 1 * 1000);
    });

    tf1.textProperty().bindBidirectional(tf2.textProperty());
}
 
Example #2
Source File: MainMenuControls.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
@FXML
@VisibleForTesting
void initialize() {
  mainOptions
      .lookupAll(".button")
      .forEach(
          node -> {
            final Function<Node, NumberBinding> hoverBinding =
                n -> Bindings.when(n.hoverProperty()).then(-10).otherwise(0);
            final NumberBinding numberBinding = hoverBinding.apply(node);
            node.translateYProperty().bind(numberBinding.multiply(-1));
            node.getParent()
                .translateYProperty()
                .bind(
                    !mainOptions.equals(node.getParent().getParent())
                        ? Bindings.add(
                            numberBinding,
                            hoverBinding
                                .apply(
                                    node.getParent().getParent().getChildrenUnmodifiable().get(0))
                                .multiply(-1))
                        : numberBinding);
          });
}
 
Example #3
Source File: MainSceneController.java    From JavaFX-Tutorial-Codes with Apache License 2.0 5 votes vote down vote up
private void sumObservable() {
    SimpleIntegerProperty a = new SimpleIntegerProperty(10);
    SimpleIntegerProperty b = new SimpleIntegerProperty(10);
    NumberBinding sum = a.add(b);
    System.out.println(sum.getValue());
    a.set(20);
    System.out.println(sum.getValue());
}
 
Example #4
Source File: Main.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

       Bill bill1 = new Bill();
       Bill bill2 = new Bill();
       Bill bill3 = new Bill();

       NumberBinding total =
         Bindings.add(bill1.amountDueProperty().add(bill2.amountDueProperty()),
             bill3.amountDueProperty());
       total.addListener(new InvalidationListener() {

       public void invalidated(Observable o) {
               System.out.println("The binding is now invalid.");
           }
       });

       // First call makes the binding invalid
       bill1.setAmountDue(200.00);

       // The binding is now invalid
       bill2.setAmountDue(100.00);
       bill3.setAmountDue(75.00);

       // Make the binding valid...
       System.out.println(total.getValue());

       // Make invalid... 
       bill3.setAmountDue(150.00);

       // Make valid...
       System.out.println(total.getValue());
       
       // Calling Money-API directly
       System.out.println(bill1.getNewAmountDue());
       System.out.println(bill2.getNewAmountDue().add(bill1.getNewAmountDue()));
   }
 
Example #5
Source File: LogView.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
@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.expressionsChangeListener = ( Observable o ) -> immediateOnFileChange();

    highlightOptions.getObservableExpressions().addListener( expressionsChangeListener );
    highlightOptions.getStandardLogColors().addListener( expressionsChangeListener );
    highlightOptions.filterEnabled().addListener( expressionsChangeListener );

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

    this.fileChangeWatcher = new FileChangeWatcher( file, taskRunner, this::onFileChange );
}
 
Example #6
Source File: LogLine.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
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" );
}
 
Example #7
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding markedProperty() {
    return marked;
}
 
Example #8
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding totalProperty() {
    return total;
}
 
Example #9
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding knownPercentProperty() {
    return knownPercent;
}
 
Example #10
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding unknownPercentProperty() {
    return unknownPercent;
}
 
Example #11
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding unseenUnfilteredPercentProperty() {
    return unseenUnfilteredPercent;
}
 
Example #12
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding unseenFilteredPercentProperty() {
    return unseenFilteredPercent;
}
 
Example #13
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding markedPercentVisibleProperty() {
    return markedPercentVisible;
}
 
Example #14
Source File: ProgressModelTest.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
private void validatePercentage(final String name, final int expected, final NumberBinding property) {
    assertEquals(expected, Math.round(property.doubleValue()), name);
}
 
Example #15
Source File: RunnerResult.java    From curly with Apache License 2.0 4 votes vote down vote up
public NumberBinding getDuration() {
    return durationBinding;
}
 
Example #16
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public NumberBinding unseenUnfilteredPercentVisibleProperty() {
    return unseenUnfilteredPercentVisible;
}
 
Example #17
Source File: ProgressModel.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
private NumberBinding bindPercentage(final NumberExpression property, final NumberBinding total) {
    return Bindings.when(property.isEqualTo(0)).then(0).otherwise(property.multiply(PERCENT).divide(total));
}
 
Example #18
Source File: MemoryInfoTableModel.java    From Noexes with GNU General Public License v3.0 4 votes vote down vote up
public NumberBinding endProperty(){
    return end;
}