当前位置: 首页>>代码示例>>Java>>正文


Java NumberBinding类代码示例

本文整理汇总了Java中javafx.beans.binding.NumberBinding的典型用法代码示例。如果您正苦于以下问题:Java NumberBinding类的具体用法?Java NumberBinding怎么用?Java NumberBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NumberBinding类属于javafx.beans.binding包,在下文中一共展示了NumberBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDouble

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:28,代码来源:TimelineSceneSynchronizer.java

示例2: RfxAppTitleBar

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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);
}
 
开发者ID:ntenhoeve,项目名称:Introspect-Framework,代码行数:24,代码来源:RfxAppTitleBar.java

示例3: main

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
/**
 * @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());
	
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:28,代码来源:Main.java

示例4: testDivideSafeDouble

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
@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);
}
 
开发者ID:lestard,项目名称:advanced-bindings,代码行数:22,代码来源:NumberBindingsTest.java

示例5: testDivideSafeDoubleWithDefaultValue

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
@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);
}
 
开发者ID:lestard,项目名称:advanced-bindings,代码行数:25,代码来源:NumberBindingsTest.java

示例6: bind

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
/**
 * {@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("%"));

    }
}
 
开发者ID:JRebirth,项目名称:MasteringTables,代码行数:26,代码来源:ResultModel.java

示例7: failureFractionProperty

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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());
}
 
开发者ID:MattiasBuelens,项目名称:junit,代码行数:19,代码来源:TestBatchModel.java

示例8: bindHeight

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:jamocha,代码行数:14,代码来源:NetworkVisualisation.java

示例9: bindWidth

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:jamocha,代码行数:14,代码来源:NetworkVisualisation.java

示例10: drawCurve

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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;
}
 
开发者ID:paolopavan,项目名称:circosFX,代码行数:39,代码来源:Circos.java

示例11: getDuration

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:curly,代码行数:12,代码来源:RunnerResult.java

示例12: LogLine

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
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" );
}
 
开发者ID:renatoathaydes,项目名称:LogFX,代码行数:10,代码来源:LogLine.java

示例13: LogView

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
@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 );
}
 
开发者ID:renatoathaydes,项目名称:LogFX,代码行数:40,代码来源:LogView.java

示例14: CustomTableView

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
@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);
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:34,代码来源:TableViewAutoSizeDemo.java

示例15: CustomTableView

import javafx.beans.binding.NumberBinding; //导入依赖的package包/类
@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);
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:37,代码来源:CustomTableViewColumnResizePolicyDemo.java


注:本文中的javafx.beans.binding.NumberBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。