Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32499

Re: Self-updating relationship

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.c, comp.lang.java.programmer
Subject Re: Self-updating relationship
Date Thu, 03 Sep 2015 13:03:47 -0400
Organization A noiseless patient Spider
Lines 76
Message-ID <ms9ugt$163$1@dont-email.me> (permalink)
References <relationship-20150902211808@ram.dialup.fu-berlin.de> <55E766BD.3060303@verizon.net> <spaces-20150902222406@ram.dialup.fu-berlin.de> <55E77D04.6080200@verizon.net> <properties-20150903001216@ram.dialup.fu-berlin.de> <55E78636.5000908@verizon.net> <ms8g5j$o5k$1@dont-email.me> <ms9llv$pto$1@dont-email.me> <ms9mpb$srk$1@dont-email.me> <ms9p30$8vc$1@dont-email.me> <ms9rm4$ki2$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 3 Sep 2015 17:03:25 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="a78aad8b483612fbf45d18e918df0cca"; logging-data="1219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EVIhXW9q2uY10Uevelh9uDBMT7dT5lys="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0
In-Reply-To <ms9rm4$ki2$1@dont-email.me>
Cancel-Lock sha1:L2NiaUQ3s2hV1oC628CIgRGtouc=
Xref csiph.com comp.lang.c:69164 comp.lang.java.programmer:32499

Cross-posted to 2 groups.

Show key headers only | View raw


On 09/03/2015 12:16 PM, James Kuyper wrote:

> OK - I thought I was beginning to understand  what was going on, but now
> I'm thoroughly confused. You're saying that this behavior (Specifically,
> the behavior of re-calculating the subtraction each time
> spaces.getValue() is used) is a property of the
> javafx.beans.property.Property<T> interface, rather than a property of
> the javafx.beans.binding.Binding<T> interface, despite the fact that it
> happens when he uses javafx.beans.binding.NumberBinding, and doesn't
> happen when he uses javafx.beans.property.SimpleIntegerProperty?
>
> How does that work? Does javafx.beans.binding.NumberBinding use
> javafx.beans.property.Property<T> while
> javafx.beans.property.SimpleIntegerProperty uses
> javafx.beans.binding.Binding<T>? That's not at all what I would have
> expected, based solely upon the names.
>
>
Perhaps our discussion is going beside itself it the threads.
I would like to use the example code that I posted elsewhere
and neglect the javafx.beans.binding package, in particular
the NumberBinding interface if that is acceptable.

If so I will reproduce the example here.
You'll need access to the JavaFX documentation, located here:
With frames
<https://docs.oracle.com/javase/8/javafx/api/index.html?overview-summary.html>
No frames
<https://docs.oracle.com/javase/8/javafx/api/overview-summary.html>


import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

public class Main
{ public static void main(String[] args)
   {

     final IntegerProperty height
     = new SimpleIntegerProperty();

     final IntegerProperty number
     = new SimpleIntegerProperty();

     final IntegerProperty spaces
     = new SimpleIntegerProperty();

     spaces.bind(height.subtract(number));

     height.set(10);
     number.set(2);
     System.out.print(spaces.get()); // 8

     spaces.unbind();
     height.set(20);
     System.out.print(spaces.get()); // 8

} }

Here spaces is a SimpleIntegerProperty, a subclass of
IntegerPropertyBase which is an implementation of the
Property<T> interface. IntegerPropertyBase is where the
Property.bind(ObservableValue<? extends T> observable) and
Property.unbind() are implemented.

The expression height.subtract(number) creates an
ObservableValue<Number>, through NumberExpression ( so much
for neglecting the javafx.beans.binding package) which
IntegerPropertyBase uses to bind height and number to spaces
as specified in his documentation.

As I stated elsewhere, the plethora of mixin interfaces
makes it difficult (for me) to discuss, but writing code
that uses it is simple.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 17:14 -0400
  Re: Self-updating relationship Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-02 17:46 -0400
    Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-03 21:06 -0400
      Re: Self-updating relationship e.d.programmer@gmail.com - 2015-09-04 04:46 -0700
        Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 19:43 -0400
    Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 11:49 -0400
      Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 19:45 -0400
        Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 22:10 -0400
          Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 22:31 -0400
            Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 22:38 -0400
            Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 22:51 -0400
  Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 18:49 -0400
    Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 19:28 -0400
      Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-02 23:52 -0400
        Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 10:32 -0400
          Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 10:53 -0400
            Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:31 -0400
              Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:35 -0400
              Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:49 -0400
              Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 12:16 -0400
                Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 13:03 -0400
          Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 10:55 -0400
      Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 00:06 -0400
    Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-02 23:38 -0400
      Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 01:22 -0400

csiph-web