From 1d2ba8c06cd28dead6afd74d6894a382ee58dfac Mon Sep 17 00:00:00 2001 From: Denny Sheirer Date: Mon, 12 Feb 2024 03:29:13 -0500 Subject: [PATCH] #1852 Spectral channel banners incorrect color for multi-frequency channels. (#1853) Co-authored-by: Dennis Sheirer --- .../dsheirer/spectrum/OverlayPanel.java | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/io/github/dsheirer/spectrum/OverlayPanel.java b/src/main/java/io/github/dsheirer/spectrum/OverlayPanel.java index b9e4d71c..4a674900 100644 --- a/src/main/java/io/github/dsheirer/spectrum/OverlayPanel.java +++ b/src/main/java/io/github/dsheirer/spectrum/OverlayPanel.java @@ -50,14 +50,15 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.apache.commons.math3.util.FastMath; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.swing.JPanel; public class OverlayPanel extends JPanel implements Listener, ISourceEventProcessor, SettingChangeListener { 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 static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING, @@ -533,39 +534,36 @@ public class OverlayPanel extends JPanel implements Listener, ISou { for(Channel channel : mVisibleChannels) { - if(mChannelDisplay == ChannelDisplay.ALL || - (mChannelDisplay == ChannelDisplay.ENABLED && channel.isProcessing())) + if(mChannelDisplay == ChannelDisplay.ALL || (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 tunerChannels = channel.getTunerChannels(); for(TunerChannel tunerChannel: tunerChannels) { 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(); - Rectangle2D.Double box = - new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width, getSize().getHeight() - mSpectrumInset); + Rectangle2D.Double box = new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width, + getSize().getHeight() - mSpectrumInset); //Fill the box with the correct color graphics.fill(box); - graphics.draw(box); //Change to the line color to render the channel name, etc. @@ -590,11 +588,8 @@ public class OverlayPanel extends JPanel implements Listener, ISou //Draw the decoder label drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(), this.getFont(), xAxis, yAxis, width); - long frequency = tunerChannel.getFrequency(); - double frequencyAxis = getAxisFromFrequency(frequency); - drawChannelCenterLine(graphics, frequencyAxis); /* Draw Automatic Frequency Control line */ @@ -603,7 +598,6 @@ public class OverlayPanel extends JPanel implements Listener, ISou if(correction != 0) { long error = frequency + correction; - drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction, tunerChannel.getFrequency()); }