Added a workaround for spectrum selector being rebuilt too often
@@ -44,9 +44,6 @@ import net.sf.mzmine.util.GUIUtils;
*/
class SpectraBottomPanel extends JPanel implements TreeModelListener {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private Logger logger = Logger.getLogger(this.getClass().getName());
@@ -64,7 +61,14 @@ class SpectraBottomPanel extends JPanel implements TreeModelListener {
private RawDataFile dataFile;
private SpectraVisualizerWindow masterFrame;
- SpectraBottomPanel(SpectraVisualizerWindow masterFrame, RawDataFile dataFile) {
+ // Last time the data set was redrawn.
+ private static long lastRebuildTime = System.currentTimeMillis();
+
+ // Refresh interval (in milliseconds).
+ private static final long REDRAW_INTERVAL = 1000L;
+
+ SpectraBottomPanel(SpectraVisualizerWindow masterFrame,
+ RawDataFile dataFile) {
super(new BorderLayout());
this.dataFile = dataFile;
@@ -149,6 +153,10 @@ class SpectraBottomPanel extends JPanel implements TreeModelListener {
*/
void rebuildPeakListSelector() {
+ // Refresh every REDRAW_INTERVAL ms.
+ if (System.currentTimeMillis() - lastRebuildTime < REDRAW_INTERVAL)
+ return;
+
logger.finest("Rebuilding the peak list selector");
PeakList selectedPeakList = (PeakList) peakListSelector
@@ -174,6 +182,10 @@ class SpectraBottomPanel extends JPanel implements TreeModelListener {
else
peakListSelector.setSelectedIndex(0);
}
+
+ // Update last rebuild time
+ lastRebuildTime = System.currentTimeMillis();
+
}
@Override
