Merge pull request #368 from DSheirer/96-disable-spectral-display-option

#96 Disable Spectral Display Option
This commit is contained in:
Denny Sheirer
2018-07-14 16:05:00 -04:00
committed by GitHub
12 changed files with 700 additions and 516 deletions

View File

@@ -40,10 +40,13 @@ import io.github.dsheirer.record.RecorderManager;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.settings.SettingsManager;
import io.github.dsheirer.source.SourceManager;
import io.github.dsheirer.source.tuner.Tuner;
import io.github.dsheirer.source.tuner.TunerEvent;
import io.github.dsheirer.source.tuner.TunerModel;
import io.github.dsheirer.source.tuner.TunerSpectralDisplayManager;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationModel;
import io.github.dsheirer.spectrum.ClearTunerMenuItem;
import io.github.dsheirer.spectrum.ShowTunerMenuItem;
import io.github.dsheirer.spectrum.SpectralDisplayPanel;
import io.github.dsheirer.util.ThreadPool;
import io.github.dsheirer.util.TimeStamp;
@@ -174,10 +177,10 @@ public class SDRTrunk implements Listener<TunerEvent>
mapService, mSettingsManager, mSourceManager, tunerModel);
mSpectralPanel = new SpectralDisplayPanel(mChannelModel,
mChannelProcessingManager, mSettingsManager);
mChannelProcessingManager, mSettingsManager, tunerModel);
TunerSpectralDisplayManager tunerSpectralDisplayManager = new TunerSpectralDisplayManager(mSpectralPanel,
mChannelModel, mChannelProcessingManager, mSettingsManager);
mChannelModel, mChannelProcessingManager, mSettingsManager, tunerModel);
tunerModel.addListener(tunerSpectralDisplayManager);
tunerModel.addListener(this);
@@ -325,6 +328,15 @@ public class SDRTrunk implements Listener<TunerEvent>
JMenu viewMenu = new JMenu("View");
viewMenu.add(new BroadcastStatusVisibleMenuItem(mControllerPanel));
viewMenu.add(new JSeparator());
for(Tuner tuner: mSourceManager.getTunerModel().getTuners())
{
viewMenu.add(new ShowTunerMenuItem(mSpectralPanel, tuner));
}
viewMenu.add(new JSeparator());
viewMenu.add(new ClearTunerMenuItem(mSpectralPanel));
menuBar.add(viewMenu);

View File

@@ -29,6 +29,7 @@ public class TunerEvent
CHANNEL_COUNT,
FREQUENCY,
SAMPLE_RATE,
CLEAR_MAIN_SPECTRAL_DISPLAY,
REQUEST_MAIN_SPECTRAL_DISPLAY,
REQUEST_NEW_SPECTRAL_DISPLAY;
}

View File

@@ -1,5 +1,6 @@
package io.github.dsheirer.source.tuner;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.source.Source;
import io.github.dsheirer.source.SourceException;
@@ -9,6 +10,7 @@ import io.github.dsheirer.source.tuner.channel.TunerChannel;
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationModel;
import io.github.dsheirer.spectrum.SpectralDisplayPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -177,10 +179,16 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
*/
public void requestFirstTunerDisplay()
{
if(mTuners.size() > 0)
SystemProperties properties = SystemProperties.getInstance();
boolean enabled = properties.get(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, true);
if(enabled && mTuners.size() > 0)
{
broadcast(new TunerEvent(mTuners.get(0),
Event.REQUEST_MAIN_SPECTRAL_DISPLAY));
broadcast(new TunerEvent(mTuners.get(0), Event.REQUEST_MAIN_SPECTRAL_DISPLAY));
}
else
{
broadcast(new TunerEvent(null, Event.CLEAR_MAIN_SPECTRAL_DISPLAY));
}
}

View File

@@ -1,3 +1,18 @@
/*******************************************************************************
* sdr-trunk
* Copyright (C) 2014-2018 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
package io.github.dsheirer.source.tuner;
import io.github.dsheirer.controller.channel.ChannelModel;
@@ -7,7 +22,7 @@ import io.github.dsheirer.settings.SettingsManager;
import io.github.dsheirer.spectrum.SpectralDisplayPanel;
import io.github.dsheirer.spectrum.SpectrumFrame;
import java.awt.*;
import java.awt.EventQueue;
public class TunerSpectralDisplayManager implements Listener<TunerEvent>
{
@@ -15,16 +30,19 @@ public class TunerSpectralDisplayManager implements Listener<TunerEvent>
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
private TunerModel mTunerModel;
public TunerSpectralDisplayManager(SpectralDisplayPanel panel,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager )
SettingsManager settingsManager,
TunerModel tunerModel)
{
mSpectralDisplayPanel = panel;
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
mTunerModel = tunerModel;
}
@Override
@@ -32,12 +50,15 @@ public class TunerSpectralDisplayManager implements Listener<TunerEvent>
{
switch(event.getEvent())
{
case CLEAR_MAIN_SPECTRAL_DISPLAY:
mSpectralDisplayPanel.clearTuner();
break;
case REQUEST_MAIN_SPECTRAL_DISPLAY:
mSpectralDisplayPanel.showTuner(event.getTuner());
break;
case REQUEST_NEW_SPECTRAL_DISPLAY:
final SpectrumFrame frame = new SpectrumFrame(mChannelModel,
mChannelProcessingManager, mSettingsManager, event.getTuner() );
mChannelProcessingManager, mSettingsManager, mTunerModel, event.getTuner());
EventQueue.invokeLater(new Runnable()
{

View File

@@ -0,0 +1,46 @@
/*******************************************************************************
* sdr-trunk
* Copyright (C) 2014-2018 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
package io.github.dsheirer.spectrum;
import io.github.dsheirer.properties.SystemProperties;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClearTunerMenuItem extends JMenuItem
{
private SpectralDisplayPanel mSpectralDisplayPanel;
public ClearTunerMenuItem(SpectralDisplayPanel spectralDisplayPanel)
{
super("Disable Spectrum & Waterfall");
mSpectralDisplayPanel = spectralDisplayPanel;
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
mSpectralDisplayPanel.clearTuner();
SystemProperties properties = SystemProperties.getInstance();
properties.set(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, false);
}
});
}
}

View File

@@ -164,6 +164,8 @@ public class DFTProcessor implements Listener<ReusableComplexBuffer>, ISourceEve
}
public void start()
{
if(mProcessorTaskHandle == null)
{
//Schedule the DFT to run calculations at a fixed rate
int initialDelay = 0;
@@ -172,6 +174,7 @@ public class DFTProcessor implements Listener<ReusableComplexBuffer>, ISourceEve
mProcessorTaskHandle = ThreadPool.SCHEDULED.scheduleAtFixedRate(new DFTCalculationTask(), initialDelay, period,
TimeUnit.MILLISECONDS);
}
}
public void stop()
{
@@ -179,9 +182,15 @@ public class DFTProcessor implements Listener<ReusableComplexBuffer>, ISourceEve
if(mProcessorTaskHandle != null)
{
mProcessorTaskHandle.cancel(true);
mProcessorTaskHandle = null;
}
}
public boolean isRunning()
{
return mProcessorTaskHandle != null;
}
public void restart()
{
stop();

View File

@@ -342,6 +342,10 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, ISourc
{
minor = 1;
}
if(label == 0)
{
label = 1;
}
//Adjust the start frequency to a multiple of the minor tick spacing
long frequency = minFrequency - (minFrequency % minor);

View File

@@ -0,0 +1,52 @@
/*******************************************************************************
* sdr-trunk
* Copyright (C) 2014-2018 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
package io.github.dsheirer.spectrum;
import io.github.dsheirer.source.tuner.Tuner;
import javax.swing.JMenuItem;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ShowTunerMenuItem extends JMenuItem
{
private SpectralDisplayPanel mSpectralDisplayPanel;
private Tuner mTuner;
public ShowTunerMenuItem(SpectralDisplayPanel spectralDisplayPanel, Tuner tuner)
{
super(tuner != null ? "Show: " + tuner.getName() : "(empty)");
mSpectralDisplayPanel = spectralDisplayPanel;
mTuner = tuner;
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mSpectralDisplayPanel.showTuner(mTuner);
}
});
}
});
}
}

View File

@@ -22,7 +22,6 @@ import io.github.dsheirer.controller.channel.ChannelProcessingManager;
import io.github.dsheirer.controller.channel.ChannelUtils;
import io.github.dsheirer.dsp.filter.Window.WindowType;
import io.github.dsheirer.dsp.filter.smoothing.SmoothingFilter.SmoothingType;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.SampleType;
@@ -33,6 +32,7 @@ import io.github.dsheirer.settings.SettingsManager;
import io.github.dsheirer.source.ISourceEventProcessor;
import io.github.dsheirer.source.SourceEvent;
import io.github.dsheirer.source.tuner.Tuner;
import io.github.dsheirer.source.tuner.TunerModel;
import io.github.dsheirer.spectrum.OverlayPanel.ChannelDisplay;
import io.github.dsheirer.spectrum.converter.ComplexDecibelConverter;
import io.github.dsheirer.spectrum.converter.DFTResultsConverter;
@@ -71,7 +71,6 @@ import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -82,9 +81,8 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
private final static Logger mLog = LoggerFactory.getLogger(SpectralDisplayPanel.class);
private static DecimalFormat sCURSOR_FORMAT = new DecimalFormat("000.00000");
public static final String FFT_SIZE_PROPERTY = "spectral.display.dft.size";
public static final String SPECTRAL_DISPLAY_ENABLED = "spectral.display.enabled";
public static final int NO_ZOOM = 0;
public static final int MAX_ZOOM = 6;
@@ -102,6 +100,7 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
private TunerModel mTunerModel;
private Tuner mTuner;
/**
@@ -118,11 +117,13 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
*/
public SpectralDisplayPanel(ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager)
SettingsManager settingsManager,
TunerModel tunerModel)
{
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
mTunerModel = tunerModel;
mSpectrumPanel = new SpectrumPanel(mSettingsManager);
mOverlayPanel = new OverlayPanel(mSettingsManager, mChannelModel);
@@ -428,6 +429,8 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
mDFTProcessor.clearBuffer();
mDFTProcessor.start();
mTuner = tuner;
if(mTuner != null)
@@ -462,6 +465,11 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
mTuner.getTunerController().removeBufferListener(mDFTProcessor);
mTuner = null;
}
mDFTProcessor.stop();
mDFTProcessor.clearBuffer();
mSpectrumPanel.clearSpectrum();
mWaterfallPanel.clearWaterfall();
}
/**
@@ -614,6 +622,7 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
if(event.getComponent() == mWaterfallPanel)
{
contextMenu.add(new PauseItem(mWaterfallPanel, "Pause"));
contextMenu.add(new JSeparator());
}
long frequency =
@@ -643,22 +652,6 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
}
// JMenu frequencyMenu = new JMenu(
// sCURSOR_FORMAT.format((float) frequency / 1000000.0f));
//
// JMenu decoderMenu = new JMenu("Add Decoder");
//
// for(DecoderType type : DecoderType.getPrimaryDecoders())
// {
// decoderMenu.add(new DecoderItem(type, frequency));
// }
//
// frequencyMenu.add(decoderMenu);
//
// contextMenu.add(frequencyMenu);
//
// contextMenu.add(new JSeparator());
/**
* Color Menus
*/
@@ -791,6 +784,27 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
contextMenu.add(zoomMenu);
if(mTuner != null)
{
contextMenu.add(new JSeparator());
contextMenu.add(new ClearTunerMenuItem(SpectralDisplayPanel.this));
}
boolean separatorAdded = false;
for(Tuner tuner: mTunerModel.getTuners())
{
if(mTuner == null || mTuner != tuner)
{
if(!separatorAdded)
{
contextMenu.add(new JSeparator());
separatorAdded = true;
}
contextMenu.add(new ShowTunerMenuItem(SpectralDisplayPanel.this, tuner));
}
}
if(contextMenu != null)
{
@@ -920,34 +934,4 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ReusableCom
});
}
}
/**
* Context menu item to provide one-click access to starting a channel
* processing with the selected decoder
*/
public class DecoderItem extends JMenuItem
{
private static final long serialVersionUID = 1L;
private ChannelModel mChannelModel;
private long mFrequency;
private DecoderType mDecoder;
public DecoderItem(DecoderType type, long frequency)
{
super(type.getDisplayString());
mFrequency = frequency;
mDecoder = type;
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
mChannelModel.createChannel(mDecoder, mFrequency);
}
});
}
}
}

View File

@@ -1,19 +1,17 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
* sdr-trunk
* Copyright (C) 2014-2018 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
package io.github.dsheirer.spectrum;
@@ -21,10 +19,11 @@ import io.github.dsheirer.controller.channel.ChannelModel;
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
import io.github.dsheirer.settings.SettingsManager;
import io.github.dsheirer.source.tuner.Tuner;
import io.github.dsheirer.source.tuner.TunerModel;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import javax.swing.JFrame;
import java.awt.EventQueue;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
@@ -37,6 +36,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
public SpectrumFrame(ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
TunerModel tunerModel,
Tuner tuner)
{
setTitle("SDRTRunk [" + tuner.getName() + "]");
@@ -46,7 +46,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
setLayout(new MigLayout("insets 0 0 0 0", "[grow]", "[grow]"));
mSpectralDisplayPanel = new SpectralDisplayPanel(channelModel,
channelProcessingManager, settingsManager );
channelProcessingManager, settingsManager, tunerModel);
mSpectralDisplayPanel.showTuner(tuner);
add(mSpectralDisplayPanel, "grow");
@@ -70,15 +70,32 @@ public class SpectrumFrame extends JFrame implements WindowListener
}
@Override
public void windowActivated( WindowEvent arg0 ) {}
@Override
public void windowClosing( WindowEvent arg0 ) {}
@Override
public void windowDeactivated( WindowEvent arg0 ) {}
@Override
public void windowDeiconified( WindowEvent arg0 ) {}
@Override
public void windowIconified( WindowEvent arg0 ) {}
@Override
public void windowOpened( WindowEvent arg0 ) {}
public void windowActivated(WindowEvent arg0)
{
}
@Override
public void windowClosing(WindowEvent arg0)
{
}
@Override
public void windowDeactivated(WindowEvent arg0)
{
}
@Override
public void windowDeiconified(WindowEvent arg0)
{
}
@Override
public void windowIconified(WindowEvent arg0)
{
}
@Override
public void windowOpened(WindowEvent arg0)
{
}
}

View File

@@ -327,8 +327,7 @@ public class SpectrumPanel extends JPanel implements DFTResultsListener, Setting
*/
public void clearSpectrum()
{
mDisplayFFTBins = null;
Arrays.fill(mDisplayFFTBins, 0.0f);
repaint();
}

View File

@@ -25,12 +25,18 @@ import io.github.dsheirer.settings.SettingsManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.image.ColorModel;
import java.awt.image.MemoryImageSource;
import java.text.DecimalFormat;
import java.util.Arrays;
public class WaterfallPanel extends JPanel implements DFTResultsListener,
Pausable,
@@ -42,7 +48,8 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
LoggerFactory.getLogger(WaterfallPanel.class);
private static DecimalFormat CURSOR_FORMAT = new DecimalFormat("0.00000");
private static final String PAUSED = "PAUSED";
private static final String PAUSED = "PAUSED - Right Click to Unpause";
private static final String DISABLED = "DISABLED - Right Click to Select a Tuner";
private byte[] mPixels;
private byte[] mPausedPixels;
@@ -57,6 +64,7 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
private boolean mCursorVisible = false;
private long mCursorFrequency = 0;
private boolean mPaused = false;
private boolean mDisabled = true;
private int mZoom = 0;
private int mDFTZoomWindowOffset = 0;
@@ -135,6 +143,7 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
/**
* Returns current pause state
*
* @return true if paused, false otherwise
*/
public boolean isPaused()
@@ -142,6 +151,14 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
return mPaused;
}
/**
* Indicates if the waterfall is currently disabled.
*/
public boolean isDisabled()
{
return mDisabled;
}
/**
* Sets the current zoom level (2^zoom)
*
@@ -171,6 +188,7 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
/**
* Sets the zoom window offset from zero
*
* @param offset in DFT bins
*/
public void setZoomWindowOffset(int offset)
@@ -209,7 +227,8 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
}
@Override
public void settingDeleted( Setting setting ) { /* Not implemented */ }
public void settingDeleted(Setting setting)
{ /* Not implemented */ }
/**
* Sets the display location of the cursor. Cursor location monitoring is
@@ -237,6 +256,7 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
/**
* Toggles the visibility of the cursor
*
* @param visible
*/
public void setCursorVisible(boolean visible)
@@ -298,21 +318,16 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
if(mCursorVisible)
{
graphics.draw( new Line2D.Float( mCursorLocation.x,
0,
mCursorLocation.x,
(float)(getSize().getHeight() ) ) );
graphics.draw(new Line2D.Float(mCursorLocation.x, 0, mCursorLocation.x, (float)(getSize().getHeight())));
String frequency = CURSOR_FORMAT.format(mCursorFrequency / 1000000.0D);
graphics.drawString( frequency ,
mCursorLocation.x + 5,
mCursorLocation.y );
graphics.drawString(frequency, mCursorLocation.x + 5, mCursorLocation.y);
}
if( mPaused )
if(mDisabled)
{
graphics.drawString(DISABLED, 20, 20);
}
else if(mPaused)
{
graphics.drawString(PAUSED, 20, 20);
}
@@ -364,6 +379,8 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
@Override
public void receive(float[] update)
{
mDisabled = false;
//If our FFT size changes, reset our pixel map and image source
if(mDFTSize != update.length)
{
@@ -373,8 +390,7 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
}
//Move the pixels down a row to make room for the new results
System.arraycopy( mPixels, 0,
mPixels, mDFTSize, mPixels.length - mDFTSize );
System.arraycopy(mPixels, 0, mPixels, mDFTSize, mPixels.length - mDFTSize);
/**
* Find the average value and scale the display to it
@@ -428,4 +444,19 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
}
});
}
public void clearWaterfall()
{
Arrays.fill(mPixels, (byte)0);
mDisabled = true;
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mMemoryImageSource.newPixels(mPixels, mColorModel, 0, mDFTSize);
}
});
}
}