#1852 Spectral channel banners incorrect color for multi-frequency channels. (#1853)

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2024-02-12 03:29:13 -05:00
committed by GitHub
parent 73275aa8ae
commit 1d2ba8c06c

View File

@@ -50,14 +50,15 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.FastMath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISourceEventProcessor, SettingChangeListener public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISourceEventProcessor, SettingChangeListener
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
// private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
private final DecimalFormat PPM_FORMATTER = new DecimalFormat( "#.0" ); private final DecimalFormat PPM_FORMATTER = new DecimalFormat( "#.0" );
private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING, private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
@@ -533,39 +534,36 @@ public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISou
{ {
for(Channel channel : mVisibleChannels) for(Channel channel : mVisibleChannels)
{ {
if(mChannelDisplay == ChannelDisplay.ALL || if(mChannelDisplay == ChannelDisplay.ALL || (mChannelDisplay == ChannelDisplay.ENABLED && channel.isProcessing()))
(mChannelDisplay == ChannelDisplay.ENABLED && channel.isProcessing()))
{ {
//Choose the correct background color to use
if(channel.isSelected())
{
graphics.setColor(mColorChannelConfigSelected);
}
else if(channel.isProcessing())
{
graphics.setColor(mColorChannelConfigProcessing);
}
else
{
graphics.setColor(mColorChannelConfig);
}
List<TunerChannel> tunerChannels = channel.getTunerChannels(); List<TunerChannel> tunerChannels = channel.getTunerChannels();
for(TunerChannel tunerChannel: tunerChannels) for(TunerChannel tunerChannel: tunerChannels)
{ {
if(tunerChannel.overlaps(getMinDisplayFrequency(), getMaxDisplayFrequency())) if(tunerChannel.overlaps(getMinDisplayFrequency(), getMaxDisplayFrequency()))
{ {
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency()); //Choose the correct background color to use
if(channel.isSelected())
{
graphics.setColor(mColorChannelConfigSelected);
}
else if(channel.isProcessing())
{
graphics.setColor(mColorChannelConfigProcessing);
}
else
{
graphics.setColor(mColorChannelConfig);
}
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency());
double width = (double)(tunerChannel.getBandwidth()) / (double)getDisplayBandwidth() * getSize().getWidth(); double width = (double)(tunerChannel.getBandwidth()) / (double)getDisplayBandwidth() * getSize().getWidth();
Rectangle2D.Double box = Rectangle2D.Double box = new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width,
new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width, getSize().getHeight() - mSpectrumInset); getSize().getHeight() - mSpectrumInset);
//Fill the box with the correct color //Fill the box with the correct color
graphics.fill(box); graphics.fill(box);
graphics.draw(box); graphics.draw(box);
//Change to the line color to render the channel name, etc. //Change to the line color to render the channel name, etc.
@@ -590,11 +588,8 @@ public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISou
//Draw the decoder label //Draw the decoder label
drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(), drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(),
this.getFont(), xAxis, yAxis, width); this.getFont(), xAxis, yAxis, width);
long frequency = tunerChannel.getFrequency(); long frequency = tunerChannel.getFrequency();
double frequencyAxis = getAxisFromFrequency(frequency); double frequencyAxis = getAxisFromFrequency(frequency);
drawChannelCenterLine(graphics, frequencyAxis); drawChannelCenterLine(graphics, frequencyAxis);
/* Draw Automatic Frequency Control line */ /* Draw Automatic Frequency Control line */
@@ -603,7 +598,6 @@ public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISou
if(correction != 0) if(correction != 0)
{ {
long error = frequency + correction; long error = frequency + correction;
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction, drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
tunerChannel.getFrequency()); tunerChannel.getFrequency());
} }