mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 12:36:07 -05:00
* Removes the FlatLaf, JIDE, MigLayout and jiconfont-swing dependencies; the runtime image no longer includes javafx.swing. * Removes the Swing channelizer developer viewers and the Swing spectrum panel; the symbol, sync and filter debug viewers are plain JavaFX windows. * ChannelMapModel is no longer a Swing list model; removes unused Swing color menu items and models. * Removes the Swing image methods from the icon classes; icons load as JavaFX images. * Themes no longer use FlatLaf: each theme stores its palette and ThemeManager styles JavaFX only. * The channel auto-start countdown, the event and message filter editor and the alias and deadlock alerts are now JavaFX. The main window only stores split pane divider positions after the user drags a divider. * Main window converted to JavaFX, with a spectrum and waterfall display that can be hidden. * A hidden spectrum and waterfall is disposed so that it uses no processing or memory. Show or hide it from the View menu, Ctrl+Shift+S, the display settings panel or the bar shown while it is hidden. * Streaming status panel converted to JavaFX with status chips, a summary, configurable columns and a shortcut to the streaming editor. * BroadcastModel is no longer a Swing table model. * Audio panel converted to JavaFX and redesigned as a prominent playback display at the top of the main window. * Mono and stereo outputs show one display per channel with the TO alias, icon and color, the FROM radio, system/site/channel, elapsed time, a level meter and per-channel mute. The master section has mute all, volume and audio device settings. * Renames JavaFxWindowManager to WindowManager and removes its standalone launcher and the remaining Swing-era comments. Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2026 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.gui.audio;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import javax.sound.sampled.FloatControl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Audio display volume mapping and alias accent color.
|
||||
*/
|
||||
public class AudioViewTest
|
||||
{
|
||||
private static final FloatControl GAIN = new FloatControl(FloatControl.Type.MASTER_GAIN, -80.0f, 6.0f, 0.1f,
|
||||
0, 0.0f, "dB") {};
|
||||
|
||||
@Test
|
||||
public void volumeMidpointIsUnityGain()
|
||||
{
|
||||
assertEquals(0.0f, AudioView.toGain(GAIN, 50), 0.0f);
|
||||
assertEquals(-80.0f, AudioView.toGain(GAIN, 0), 1e-4f);
|
||||
assertEquals(6.0f, AudioView.toGain(GAIN, 100), 1e-4f);
|
||||
assertEquals(-40.0f, AudioView.toGain(GAIN, 25), 1e-4f);
|
||||
assertEquals(3.0f, AudioView.toGain(GAIN, 75), 1e-4f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void darkAliasColorIsLightenedForTheDisplay()
|
||||
{
|
||||
Color black = AudioChannelView.toReadable(0x000000);
|
||||
Color navy = AudioChannelView.toReadable(0x1E3A8A);
|
||||
assertTrue(contrast(black) >= 3.0, "black accent contrast " + contrast(black));
|
||||
assertTrue(contrast(navy) >= 3.0, "navy accent contrast " + contrast(navy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brightAliasColorIsUnchanged()
|
||||
{
|
||||
Color red = AudioChannelView.toReadable(0xD9381E);
|
||||
assertEquals(Color.rgb(0xD9, 0x38, 0x1E), red);
|
||||
}
|
||||
|
||||
private static double contrast(Color color)
|
||||
{
|
||||
return (luminance(color) + 0.05) / (luminance(Color.web("#161b22")) + 0.05);
|
||||
}
|
||||
|
||||
private static double luminance(Color color)
|
||||
{
|
||||
return 0.2126 * linear(color.getRed()) + 0.7152 * linear(color.getGreen()) + 0.0722 * linear(color.getBlue());
|
||||
}
|
||||
|
||||
private static double linear(double channel)
|
||||
{
|
||||
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user