Created
July 24, 2013 08:50
-
-
Save komax/6068992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm | |
require 'jrubyfx' | |
class MyDoubleBinding < Java::javafx.beans.binding.DoubleBinding | |
def initialize(a, b, c, d) | |
@a, @b, @c, @d = a, b, c, d | |
super() | |
bind(@a, @b, @c, @d) | |
end | |
java_signature 'protected double computeValue()' | |
def compute_value | |
(@a.get * @b.get) + (@c.get * @d.get) | |
end | |
end | |
module LowLevelBindingDemo | |
import Java::javafx.beans.property.SimpleDoubleProperty | |
def self.main | |
a = SimpleDoubleProperty.new(1) | |
b = SimpleDoubleProperty.new(2) | |
c = SimpleDoubleProperty.new(3) | |
d = SimpleDoubleProperty.new(4) | |
db = MyDoubleBinding.new(a, b, c, d) | |
puts db.get | |
b.value = 3 | |
puts db.get | |
end | |
end | |
LowLevelBindingDemo.main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment