Skip to content

Commit 1d2ba8c

Browse files
DSheirerDennis Sheirer
andauthored
#1852 Spectral channel banners incorrect color for multi-frequency channels. (#1853)
Co-authored-by: Dennis Sheirer <[email protected]>
1 parent 73275aa commit 1d2ba8c

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

src/main/java/io/github/dsheirer/spectrum/OverlayPanel.java

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
import java.util.List;
5151
import java.util.concurrent.CopyOnWriteArrayList;
5252
import org.apache.commons.math3.util.FastMath;
53+
import org.slf4j.Logger;
54+
import org.slf4j.LoggerFactory;
5355

5456
import javax.swing.JPanel;
5557

5658
public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISourceEventProcessor, SettingChangeListener
5759
{
5860
private static final long serialVersionUID = 1L;
59-
60-
// private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
61+
private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
6162
private final DecimalFormat PPM_FORMATTER = new DecimalFormat( "#.0" );
6263

6364
private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
@@ -533,39 +534,36 @@ private void drawChannels(Graphics2D graphics)
533534
{
534535
for(Channel channel : mVisibleChannels)
535536
{
536-
if(mChannelDisplay == ChannelDisplay.ALL ||
537-
(mChannelDisplay == ChannelDisplay.ENABLED && channel.isProcessing()))
537+
if(mChannelDisplay == ChannelDisplay.ALL || (mChannelDisplay == ChannelDisplay.ENABLED && channel.isProcessing()))
538538
{
539-
//Choose the correct background color to use
540-
if(channel.isSelected())
541-
{
542-
graphics.setColor(mColorChannelConfigSelected);
543-
}
544-
else if(channel.isProcessing())
545-
{
546-
graphics.setColor(mColorChannelConfigProcessing);
547-
}
548-
else
549-
{
550-
graphics.setColor(mColorChannelConfig);
551-
}
552-
553539
List<TunerChannel> tunerChannels = channel.getTunerChannels();
554540

555541
for(TunerChannel tunerChannel: tunerChannels)
556542
{
557543
if(tunerChannel.overlaps(getMinDisplayFrequency(), getMaxDisplayFrequency()))
558544
{
559-
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency());
545+
//Choose the correct background color to use
546+
if(channel.isSelected())
547+
{
548+
graphics.setColor(mColorChannelConfigSelected);
549+
}
550+
else if(channel.isProcessing())
551+
{
552+
graphics.setColor(mColorChannelConfigProcessing);
553+
}
554+
else
555+
{
556+
graphics.setColor(mColorChannelConfig);
557+
}
560558

559+
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency());
561560
double width = (double)(tunerChannel.getBandwidth()) / (double)getDisplayBandwidth() * getSize().getWidth();
562561

563-
Rectangle2D.Double box =
564-
new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width, getSize().getHeight() - mSpectrumInset);
562+
Rectangle2D.Double box = new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width,
563+
getSize().getHeight() - mSpectrumInset);
565564

566565
//Fill the box with the correct color
567566
graphics.fill(box);
568-
569567
graphics.draw(box);
570568

571569
//Change to the line color to render the channel name, etc.
@@ -590,11 +588,8 @@ else if(channel.isProcessing())
590588
//Draw the decoder label
591589
drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(),
592590
this.getFont(), xAxis, yAxis, width);
593-
594591
long frequency = tunerChannel.getFrequency();
595-
596592
double frequencyAxis = getAxisFromFrequency(frequency);
597-
598593
drawChannelCenterLine(graphics, frequencyAxis);
599594

600595
/* Draw Automatic Frequency Control line */
@@ -603,7 +598,6 @@ else if(channel.isProcessing())
603598
if(correction != 0)
604599
{
605600
long error = frequency + correction;
606-
607601
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
608602
tunerChannel.getFrequency());
609603
}

0 commit comments

Comments
 (0)