title: jgoodies bindings + coalescing frequent changes
body: <p>I have a java app that updates data at a variable rate (received from a fairly high-speed data stream out of my control, but up to 120Kbytes/sec), and I would like to display statistics like the # of bytes/packets received, using a dialog box.</p>
  
  <p>I'm looking into <a href="https://binding.dev.java.net/" rel="nofollow noreferrer">JGoodies bindings</a> and got something preliminarily working with artificial data received at low rates.</p>
  
  <p>What I would like to do, roughly, is:</p>
  
  <ol>
  <li><p>make a bean class something like this:</p>
  
  <pre><code>public class Statistics
  {
    private int bytes;
    private int goodPackets;
    private int badPackets;
    private int totalPackets;
  
    public int getBytes() { return bytes; }
    public int getGoodPackets() { return goodPackets; }
    public int getBadPackets() { return badPackets; }
    public int getTotalPackets() { return totalPackets; }
  
    public void update(/* TBD */) { /* updates the fields appropriately */ }
    public Statistics() { bytes=goodPackets=badPackets=totalPackets=0; }
  }
  
  Statistics stats;
  </code></pre></li>
  <li><p>bind the 4 fields to elements in my GUI</p></li>
  <li>be able to call <code>stats.update()</code> at whatever speed is necessary in my main application thread, where the call to "update" is what triggers the GUI's change listeners</li>
  <li>have the GUI "automatically" update at a lower rate that I can specify, approximately 5-20Hz, so it doesn't get overwhelmed with gobs of triggered events.</li>
  </ol>
  
  <p>Is there an appropriate mechanism that would let me do what I want? I'm looking at JGoodies DelayedReadValueModel but I don't really get how to use it.</p>
  
  <p>If I had to do it myself manually, I guess what I'd probably do is:</p>
  
  <ol>
  <li>have a mirrored copy of Statistics, and add some kind of update flag, as well as a link from the original to the mirrored copy, and a timer timeout</li>
  <li>when the <code>update()</code> method is called, set the update flag, and call a method like <code>maybePropagate()</code></li>
  <li><code>maybePropagate()</code>: if the timer timeout is in progress, or the link to the mirrored copy is null, it does nothing; otherwise it starts the timeout and sends the updated data to the mirrored copy, and clears the update flag</li>
  <li>when the timer timeout expires, if the update flag is set and the link to the mirrored copy is non-null, it sends the updated data to the mirrored copy and clears the update flag</li>
  <li>Having implemented the previous 4 elements, my mirrored copy has a maximum rate which it gets updated, and therefore I can just bind the GUI elements to the fields of the mirrored copy with the regular JGoodies BeanAdapter. </li>
  </ol>
  
  <p>Any suggestions?</p>