changeset 690:36953156f57e

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:59:26 -0400
parents 330a2a8e91e1
children 44a3fceb264d
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	Tue Oct 09 11:55:07 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java	Tue Oct 09 11:59:26 2012 -0400
@@ -237,7 +237,6 @@
                         max =+ space.maxCapacity;
                     }
                 }
-                // model will automatically update view
                 model.addData(memoryStats.getTimeStamp(), used, capacity);
                 
                 NumberFormat formatter = DecimalFormat.getInstance();
@@ -250,6 +249,8 @@
                 
                 view.updateUsedAndCapacity(_used, _capacity);
             }
+
+            model.notifyListenersOfModelChange();
         }
     }
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/chart/OverviewChart.java	Tue Oct 09 11:55:07 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/chart/OverviewChart.java	Tue Oct 09 11:59:26 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);