diff --git a/src/rssi_graph/localization/JPanelDistanceInTime.java b/src/rssi_graph/localization/JPanelDistanceInTime.java index bc1086c..5cf75c4 100644 --- a/src/rssi_graph/localization/JPanelDistanceInTime.java +++ b/src/rssi_graph/localization/JPanelDistanceInTime.java @@ -157,6 +157,8 @@ protected void updateValues(){ ts = this.timeSeries.get(curTimeSerieKey); } + // age items in time series + ts.removeAgedItems(300000, false); ts.add(now, distanceFunction.getDistanceFromRSSI(floatingMean.get(curAnchor))); this.timeSeries.put(curTimeSerieKey, ts); } diff --git a/src/rssi_graph/localization/JPanelRSSIInTime.java b/src/rssi_graph/localization/JPanelRSSIInTime.java index d128ce9..2ce1589 100644 --- a/src/rssi_graph/localization/JPanelRSSIInTime.java +++ b/src/rssi_graph/localization/JPanelRSSIInTime.java @@ -51,6 +51,8 @@ */ public class JPanelRSSIInTime extends javax.swing.JPanel implements ActionListener { + public static final int MAX_MEMORY_ELEMENTS=10000; + private Timer grabTimer = null; private WorkerLocalization worker = null; private Map timeSeries = null; @@ -147,7 +149,7 @@ protected synchronized void updateValues(){ // generate key for time serie String curTimeSerieKey = "T"+mn.getMobile_nodeID()+";R"+curAnchor; TimeSeries ts = null; - + // does time serie exist? if (!this.timeSeries.containsKey(curTimeSerieKey)){ redrawGraphNeeded=true; @@ -161,6 +163,8 @@ protected synchronized void updateValues(){ ts = this.timeSeries.get(curTimeSerieKey); } + // age items in time series + ts.removeAgedItems(300000, false); ts.add(now, floatingMean.get(curAnchor)); this.timeSeries.put(curTimeSerieKey, ts); } @@ -287,7 +291,7 @@ protected void drawGraph(){ this.revalidate(); } - public void actionPerformed(ActionEvent e) { + public synchronized void actionPerformed(ActionEvent e) { if ("grabTimer".equals(e.getActionCommand())){ this.updateValues(); }