mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
#1847 Updates spectral display to show channel overlay for all frequencies in a channel configuration that contains multiple frequencies. (#1848)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
* Copyright (C) 2014-2024 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
|
||||
@@ -550,60 +550,63 @@ public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISou
|
||||
graphics.setColor(mColorChannelConfig);
|
||||
}
|
||||
|
||||
TunerChannel tunerChannel = channel.getTunerChannel();
|
||||
List<TunerChannel> tunerChannels = channel.getTunerChannels();
|
||||
|
||||
if(tunerChannel != null)
|
||||
for(TunerChannel tunerChannel: tunerChannels)
|
||||
{
|
||||
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);
|
||||
|
||||
//Fill the box with the correct color
|
||||
graphics.fill(box);
|
||||
|
||||
graphics.draw(box);
|
||||
|
||||
//Change to the line color to render the channel name, etc.
|
||||
graphics.setColor(mColorSpectrumLine);
|
||||
|
||||
//Draw the labels starting at yAxis position 0
|
||||
double yAxis = 0;
|
||||
|
||||
//Draw the system label and adjust the y-axis position
|
||||
String system = channel.hasSystem() ? channel.getSystem() : " ";
|
||||
|
||||
yAxis += drawLabel(graphics, system, this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//Draw the site label and adjust the y-axis position
|
||||
String site = channel.hasSite() ? channel.getSite() : " ";
|
||||
|
||||
yAxis += drawLabel(graphics, site, this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//Draw the channel label and adjust the y-axis position
|
||||
yAxis += drawLabel(graphics, channel.getName(), this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//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 */
|
||||
int correction = channel.getChannelFrequencyCorrection();
|
||||
|
||||
if(correction != 0)
|
||||
if(tunerChannel.overlaps(getMinDisplayFrequency(), getMaxDisplayFrequency()))
|
||||
{
|
||||
long error = frequency + correction;
|
||||
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency());
|
||||
|
||||
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
|
||||
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);
|
||||
|
||||
//Fill the box with the correct color
|
||||
graphics.fill(box);
|
||||
|
||||
graphics.draw(box);
|
||||
|
||||
//Change to the line color to render the channel name, etc.
|
||||
graphics.setColor(mColorSpectrumLine);
|
||||
|
||||
//Draw the labels starting at yAxis position 0
|
||||
double yAxis = 0;
|
||||
|
||||
//Draw the system label and adjust the y-axis position
|
||||
String system = channel.hasSystem() ? channel.getSystem() : " ";
|
||||
|
||||
yAxis += drawLabel(graphics, system, this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//Draw the site label and adjust the y-axis position
|
||||
String site = channel.hasSite() ? channel.getSite() : " ";
|
||||
|
||||
yAxis += drawLabel(graphics, site, this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//Draw the channel label and adjust the y-axis position
|
||||
yAxis += drawLabel(graphics, channel.getName(), this.getFont(), xAxis, yAxis, width);
|
||||
|
||||
//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 */
|
||||
int correction = channel.getChannelFrequencyCorrection();
|
||||
|
||||
if(correction != 0)
|
||||
{
|
||||
long error = frequency + correction;
|
||||
|
||||
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
|
||||
tunerChannel.getFrequency());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,11 +799,14 @@ public class OverlayPanel extends JPanel implements Listener<ChannelEvent>, ISou
|
||||
|
||||
for(Channel config : mVisibleChannels)
|
||||
{
|
||||
TunerChannel channel = config.getTunerChannel();
|
||||
List<TunerChannel> channels = config.getTunerChannels();
|
||||
|
||||
if(channel != null && channel.getMinFrequency() <= frequency && channel.getMaxFrequency() >= frequency)
|
||||
for(TunerChannel channel: channels)
|
||||
{
|
||||
configs.add(config);
|
||||
if(channel != null && channel.getMinFrequency() <= frequency && channel.getMaxFrequency() >= frequency)
|
||||
{
|
||||
configs.add(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user