Skip to content

Commit

Permalink
#1854 Tuner minimum frequency of 1 Hertz now supported. Resolves issu…
Browse files Browse the repository at this point in the history
…e where the FrequencyTextField wouldn't accept minimum frequency values smaller than 1 MHz on initial setup. (#1855)

Co-authored-by: Dennis Sheirer <[email protected]>
  • Loading branch information
DSheirer and Dennis Sheirer authored Feb 12, 2024
1 parent 1d2ba8c commit ca2509e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
public class FrequencyTextField extends JTextField
{
private static final Logger LOGGER = LoggerFactory.getLogger(FrequencyTextField.class);
private static final String REGEX = "[1-9][0-9]{0,3}(\\.[0-9]{0,6})?";
//Value range: 0.000001 to 9999.999999
private static final String REGEX = "^[0-9]{0,4}[.]?[0-9]{0,6}$";
//This lets users start typing a really small number like 1 Hertz ... 0.00000
private static final String ZEROS_REGEX = "^0?([.]0{0,5})?$";
private double mMinimum;
private double mMaximum;

Expand Down Expand Up @@ -110,7 +113,7 @@ public void setFrequency(long frequency)
*/
private boolean isValid(String value)
{
if(value == null || value.isEmpty())
if(value == null || value.isEmpty() || value.matches(ZEROS_REGEX))
{
return true;
}
Expand Down Expand Up @@ -183,7 +186,7 @@ public static void main(String[] args)
{
JFrame frame = new JFrame("Frequency Control Test");
frame.setSize(300, 200);
FrequencyTextField ftf = new FrequencyTextField(20, 2_000_000_000, 101_100_000);
FrequencyTextField ftf = new FrequencyTextField(1, 9_999_999_999l, 101_100_000);
frame.setLayout(new MigLayout());
frame.add(ftf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class TunerEditor<T extends Tuner,C extends TunerConfiguration>
implements IDiscoveredTunerStatusListener, Listener<TunerEvent>
{
private Logger mLog = LoggerFactory.getLogger(TunerEditor.class);
private static final long DEFAULT_MINIMUM_FREQUENCY = 1_000_000;
private static final long DEFAULT_MINIMUM_FREQUENCY = 1;
private static final long DEFAULT_MAXIMUM_FREQUENCY = 9_999_999_999l;
private static final String BUTTON_STATUS_ENABLE = "Enable";
private static final String BUTTON_STATUS_DISABLE = "Disable";
Expand Down

0 comments on commit ca2509e

Please sign in to comment.