changeset 657:be076fc26f78

Only update Chart view when done updating model Update the chart in the Memory Analyzer view only when all the model updates are done. Otherwise each model update will redraw the UI even though the next model update will discard the previous result. Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-October/003678.html
author Omair Majid <omajid@redhat.com>
date Tue, 09 Oct 2012 11:32:51 -0400
parents 3befd8ddad2f
children 7d527b84f5b9
files client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/chart/OverviewChart.java
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java	Thu Oct 04 17:35:18 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java	Tue Oct 09 11:32:51 2012 -0400
@@ -228,7 +228,6 @@
                         max =+ space.maxCapacity;
                     }
                 }
-                // model will automatically update view
                 model.addData(memoryStats.getTimeStamp(), used, capacity);
                 
                 NumberFormat formatter = DecimalFormat.getInstance();
@@ -241,6 +240,8 @@
                 
                 view.updateUsedAndCapacity(_used, _capacity);
             }
+
+            model.notifyListenersOfModelChange();
         }
     }
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/chart/OverviewChart.java	Thu Oct 04 17:35:18 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/chart/OverviewChart.java	Tue Oct 09 11:32:51 2012 -0400
@@ -147,18 +147,25 @@
         Millisecond millisecond = new Millisecond(new Date(timeStamp));
         synchronized (lock) {            
             if (this.total.getValue(millisecond) == null) {
-                this.total.add(millisecond, total);
+                this.total.add(millisecond, total, false);
                 this.total.removeAgedItems(true);
             }
             
             if (this.used.getValue(millisecond) == null) {
-                this.used.add(millisecond, used);
+                this.used.add(millisecond, used, false);
                 this.used.removeAgedItems(true);
             }
         }
         
     }
 
+    public void notifyListenersOfModelChange() {
+        synchronized (lock) {
+            this.total.fireSeriesChanged();
+            this.used.fireSeriesChanged();
+        }
+    }
+
     public void setRange(int seconds) {
         total.setMaximumItemCount(seconds);
         used.setMaximumItemCount(seconds);