Java Code Examples for javafx.beans.property.DoubleProperty#addListener()

The following examples show how to use javafx.beans.property.DoubleProperty#addListener() . 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: GlobalTransformManager.java    From paintera with GNU General Public License v2.0 7 votes vote down vote up
public synchronized void setTransform(final AffineTransform3D affine, final Duration duration) {
	if (duration.toMillis() == 0.0) {
		setTransform(affine);
		return;
	}
	final Timeline timeline = new Timeline(60.0);
	timeline.setCycleCount(1);
	timeline.setAutoReverse(false);
	final AffineTransform3D currentState = this.affine.copy();
	final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0);
	final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator(currentState, affine.copy());
	progressProperty.addListener((obs, oldv, newv) -> setTransform(interpolator.interpolateAt(newv.doubleValue())));
	final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH);
	timeline.getKeyFrames().add(new KeyFrame(duration, kv));
	timeline.play();
}
 
Example 2
Source File: Viewer3DFX.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public void setAffine(final Affine affine, final Duration duration) {
	if (duration.toMillis() == 0.0) {
		setAffine(affine);
		return;
	}
	final Timeline timeline = new Timeline(60.0);
	timeline.setCycleCount(1);
	timeline.setAutoReverse(false);
	final Affine currentState = new Affine();
	getAffine(currentState);
	final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0);
	final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator(
			Transforms.fromTransformFX(currentState),
			Transforms.fromTransformFX(affine)
		);
	progressProperty.addListener((obs, oldv, newv) -> setAffine(Transforms.toTransformFX(interpolator.interpolateAt(newv.doubleValue()))));
	final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH);
	timeline.getKeyFrames().add(new KeyFrame(duration, kv));
	timeline.play();
}
 
Example 3
Source File: UiUtil.java    From Recaf with MIT License 6 votes vote down vote up
private static void animate(Node node, long millis, int r, int g, int b) {
	DoubleProperty dblProp = new SimpleDoubleProperty(1);
	dblProp.addListener((ob, o, n) -> {
		InnerShadow innerShadow = new InnerShadow();
		innerShadow.setBlurType(BlurType.ONE_PASS_BOX);
		innerShadow.setChoke(1);
		innerShadow.setRadius(5);
		innerShadow.setColor(Color.rgb(r, g, b, n.doubleValue()));
		node.setEffect(innerShadow);
	});
	Timeline timeline = new Timeline();
	KeyValue kv = new KeyValue(dblProp, 0);
	KeyFrame kf = new KeyFrame(Duration.millis(millis), kv);
	timeline.getKeyFrames().add(kf);
	timeline.play();
}
 
Example 4
Source File: Scene3DHandler.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public Rotate(final String name, final DoubleProperty speed, final double factor, final Predicate<MouseEvent>
		eventFilter)
{
	super(name, eventFilter, true, affine, false);
	LOG.trace("rotation");
	this.factor.set(factor);
	this.speed.set(speed.get() * this.factor.get());

	speed.addListener((obs, old, newv) -> this.speed.set(this.factor.get() * speed.get()));
	this.factor.addListener((obs, old, newv) -> this.speed.set(speed.get()));
}
 
Example 5
Source File: MetaPanel.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public void listenOnMinMax(final DoubleProperty min, final DoubleProperty max)
{
	min.addListener((obs, oldv, newv) -> {
		if (Double.isFinite(newv.doubleValue()))
			this.min.setText(Double.toString(newv.doubleValue()));
	});

	max.addListener((obs, oldv, newv) -> {
		if (Double.isFinite(newv.doubleValue()))
			this.max.setText(Double.toString(newv.doubleValue()));
	});
}
 
Example 6
Source File: SessionManager.java    From mokka7 with Eclipse Public License 1.0 5 votes vote down vote up
public void bind(final DoubleProperty property, final String propertyName) {
    String value = props.getProperty(propertyName);
    if (value != null) {
        property.set(Double.valueOf(value));
    }
    property.addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable o) {
            props.setProperty(propertyName, property.getValue().toString());
        }
    });
}
 
Example 7
Source File: SessionContext.java    From jfxvnc with Apache License 2.0 5 votes vote down vote up
public void bind(final DoubleProperty property, final String propertyName) {
  String value = props.getProperty(propertyName);
  if (value != null) {
    property.set(Double.valueOf(value));
  }
  property.addListener(o -> {
    props.setProperty(propertyName, property.getValue().toString());
  });
}
 
Example 8
Source File: PointerEventHandler.java    From jfxvnc with Apache License 2.0 4 votes vote down vote up
public void registerZoomLevel(DoubleProperty zoom) {
  zoom.addListener(l -> zoomLevel = zoom.get());
}
 
Example 9
Source File: PointerEventHandler.java    From jfxvnc with Apache License 2.0 4 votes vote down vote up
public void registerZoomLevel(DoubleProperty zoom) {
  zoom.addListener(l -> zoomLevel = zoom.get());
}