Skip to content

Instantly share code, notes, and snippets.

View RupprechJo's full-sized avatar

Johannes Rupprecht RupprechJo

  • NOVENTI Health SE
View GitHub Profile
@RupprechJo
RupprechJo / JavaFx Scaling Example
Created November 13, 2013 19:43
Example for my blog
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class ScalingDemo extends Application{
public void start(Stage primaryStage) throws Exception {
WebView webView = new WebView();
@RupprechJo
RupprechJo / JavaFx Zooming Example
Created November 13, 2013 20:10
Example for my blog
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane;
@RupprechJo
RupprechJo / gist:7527454
Last active December 28, 2015 16:09
NestedObjectProperty class
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.WeakChangeListener;
import java.util.function.Function;
/**
* A Property which is unidirectionally or bidirectionally bound to a property of a property. What that means:
* You have a property A. The object contained in that property A has itself a property B.
//Binding with the bind method of a property
StringProperty prop1 = new SimpleStringProperty();
StringProperty prop2 = new SimpleStringProperty();
prop1.bind(prop2);
prop2.set("Hello World");
Assert.assertEquals(prop1.get(), prop2.get());
//Binding with Bindings.add method
//Simple custom IntegerBinding implementation
IntegerProperty intVal = new SimpleIntegerProperty();
IntegerBinding modulo2 = new IntegerBinding() {
{ bind(intVal);}
protected int computeValue() {
return intVal.get() % 2;
}
};
intVal.set(3);
Assert.assertEquals(1, modulo2.get());