From 54227703a25c0837567675a353daa928f275acbd Mon Sep 17 00:00:00 2001 From: Denny Date: Sun, 11 Feb 2018 06:12:57 -0500 Subject: [PATCH] Cleanup from last PR. --- .../instrument/gui/DecoderSelectionFrame.java | 41 +++--- .../gui/viewer/DemodulatorViewerFX.java | 120 ++++++++++++++++++ .../gui/viewer/PlaybackController.java | 81 ++++++++++++ .../instrument/gui/viewer/ViewerDesktop.java | 50 ++++++++ 4 files changed, 277 insertions(+), 15 deletions(-) create mode 100644 src/main/java/io/github/dsheirer/instrument/gui/viewer/DemodulatorViewerFX.java create mode 100644 src/main/java/io/github/dsheirer/instrument/gui/viewer/PlaybackController.java create mode 100644 src/main/java/io/github/dsheirer/instrument/gui/viewer/ViewerDesktop.java diff --git a/src/main/java/io/github/dsheirer/instrument/gui/DecoderSelectionFrame.java b/src/main/java/io/github/dsheirer/instrument/gui/DecoderSelectionFrame.java index 00df6945..bc3f28d4 100644 --- a/src/main/java/io/github/dsheirer/instrument/gui/DecoderSelectionFrame.java +++ b/src/main/java/io/github/dsheirer/instrument/gui/DecoderSelectionFrame.java @@ -2,15 +2,19 @@ package io.github.dsheirer.instrument.gui; import io.github.dsheirer.alias.AliasModel; import io.github.dsheirer.audio.broadcast.BroadcastModel; +import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.ChannelModel; import io.github.dsheirer.controller.channel.map.ChannelMapModel; import io.github.dsheirer.module.decode.DecodeConfigurationEditor; +import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.playlist.PlaylistManager; import io.github.dsheirer.source.IControllableFileSource; import net.miginfocom.swing.MigLayout; -import javax.swing.*; -import java.awt.*; +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JInternalFrame; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -18,14 +22,14 @@ public class DecoderSelectionFrame extends JInternalFrame { private static final long serialVersionUID = 1L; + private Channel mChannel = new Channel(); private DecodeConfigurationEditor mDecodeEditor = new DecodeConfigurationEditor(null); private PlaylistManager mPlaylistManager; private IControllableFileSource mSource; private JDesktopPane mDesktop; - public DecoderSelectionFrame(JDesktopPane desktop, - IControllableFileSource source) + public DecoderSelectionFrame(JDesktopPane desktop, IControllableFileSource source) { AliasModel aliasModel = new AliasModel(); BroadcastModel broadcastModel = new BroadcastModel(null); @@ -37,6 +41,7 @@ public class DecoderSelectionFrame extends JInternalFrame mDesktop = desktop; mSource = source; + mDecodeEditor.setItem(mChannel); initGUI(); } @@ -72,17 +77,23 @@ public class DecoderSelectionFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent arg0) { -// DecodeConfiguration config = mDecodeEditor.getDecodeConfig(); -// -// if( config != null ) -// { -// DecoderViewFrame decoderFrame = new DecoderViewFrame( -// mPlaylistManager, null, mSource ); -// -// decoderFrame.setVisible( true ); -// -// mDesktop.add( decoderFrame ); -// } + mDecodeEditor.save(); + + Channel channel = mDecodeEditor.getItem(); + + if(channel != null) + { + DecodeConfiguration config = channel.getDecodeConfiguration(); + + if( config != null ) + { + DecoderViewFrame decoderFrame = new DecoderViewFrame(mPlaylistManager, channel, mSource ); + + decoderFrame.setVisible( true ); + + mDesktop.add( decoderFrame ); + } + } } }); } diff --git a/src/main/java/io/github/dsheirer/instrument/gui/viewer/DemodulatorViewerFX.java b/src/main/java/io/github/dsheirer/instrument/gui/viewer/DemodulatorViewerFX.java new file mode 100644 index 00000000..a0747fb9 --- /dev/null +++ b/src/main/java/io/github/dsheirer/instrument/gui/viewer/DemodulatorViewerFX.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * sdr-trunk + * Copyright (C) 2014-2018 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 + * + ******************************************************************************/ +package io.github.dsheirer.instrument.gui.viewer; + +import javafx.application.Application; +import javafx.application.Platform; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Menu; +import javafx.scene.control.MenuBar; +import javafx.scene.control.MenuItem; +import javafx.scene.control.SeparatorMenuItem; +import javafx.scene.layout.BorderPane; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +import java.io.File; + +/** + * Application for viewing and working with demodulators and recording files. + */ +public class DemodulatorViewerFX extends Application +{ + private Stage mStage; + private MenuBar mMenuBar; + private ViewerDesktop mViewerDesktop; + + @Override + public void start(Stage primaryStage) throws Exception + { + mStage = primaryStage; + mStage.setTitle("Demodulator Viewer FX"); + + BorderPane borderPane = new BorderPane(); + borderPane.setTop(getMenuBar()); + borderPane.setCenter(getViewerDesktop()); + + Scene scene = new Scene(borderPane, 1200, 800); + + mStage.setScene(scene); + mStage.show(); + } + + private ViewerDesktop getViewerDesktop() + { + if(mViewerDesktop == null) + { + mViewerDesktop = new ViewerDesktop(); + } + + return mViewerDesktop; + } + + private MenuBar getMenuBar() + { + if(mMenuBar == null) + { + mMenuBar = new MenuBar(); + + Menu menuFile = new Menu("File"); + MenuItem menuItemOpen = new MenuItem("Open ..."); + menuItemOpen.setOnAction(new EventHandler() + { + @Override + public void handle(ActionEvent event) + { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Open an I/Q recording file"); + File file = fileChooser.showOpenDialog(mStage); + getViewerDesktop().load(file); + } + }); + + MenuItem menuItemClose = new MenuItem("Close"); + menuItemClose.setOnAction(new EventHandler() + { + @Override + public void handle(ActionEvent event) + { + getViewerDesktop().close(); + } + }); + + MenuItem menuItemExit = new MenuItem("Exit"); + menuItemExit.setOnAction(new EventHandler() + { + @Override + public void handle(ActionEvent event) + { + Platform.exit(); + } + }); + + menuFile.getItems().addAll(menuItemOpen, menuItemClose, new SeparatorMenuItem(), menuItemExit); + + mMenuBar.getMenus().addAll(menuFile); + } + + return mMenuBar; + } + + public static void main(String[] args) + { + launch(args); + } +} diff --git a/src/main/java/io/github/dsheirer/instrument/gui/viewer/PlaybackController.java b/src/main/java/io/github/dsheirer/instrument/gui/viewer/PlaybackController.java new file mode 100644 index 00000000..6d09b92b --- /dev/null +++ b/src/main/java/io/github/dsheirer/instrument/gui/viewer/PlaybackController.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * sdr-trunk + * Copyright (C) 2014-2018 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 + * + ******************************************************************************/ +package io.github.dsheirer.instrument.gui.viewer; + +import javafx.scene.control.Button; +import javafx.scene.layout.HBox; + +import java.nio.file.Path; + +public class PlaybackController extends HBox +{ + private Button mPlay1Button; + private Button mPlay10Button; + private Button mPlay100Button; + private Button mPlay1000Button; + + public PlaybackController() + { + getChildren().addAll(getPlay1Button(), getPlay10Button(), getPlay100Button(), getPlay1000Button()); + + } + + public void load(Path path) + { + + } + + public Button getPlay1Button() + { + if(mPlay1Button == null) + { + mPlay1Button = new Button("> 1"); + } + + return mPlay1Button; + } + + public Button getPlay10Button() + { + if(mPlay10Button == null) + { + mPlay10Button = new Button(">> 10"); + } + + return mPlay10Button; + } + + public Button getPlay100Button() + { + if(mPlay100Button == null) + { + mPlay100Button = new Button(">> 100"); + } + + return mPlay100Button; + } + + public Button getPlay1000Button() + { + if(mPlay1000Button == null) + { + mPlay1000Button = new Button(">> 1000"); + } + + return mPlay1000Button; + } + +} diff --git a/src/main/java/io/github/dsheirer/instrument/gui/viewer/ViewerDesktop.java b/src/main/java/io/github/dsheirer/instrument/gui/viewer/ViewerDesktop.java new file mode 100644 index 00000000..85b774cd --- /dev/null +++ b/src/main/java/io/github/dsheirer/instrument/gui/viewer/ViewerDesktop.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * sdr-trunk + * Copyright (C) 2014-2018 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 + * + ******************************************************************************/ +package io.github.dsheirer.instrument.gui.viewer; + +import javafx.scene.layout.BorderPane; + +import java.io.File; + +public class ViewerDesktop extends BorderPane +{ + private PlaybackController mPlaybackController; + + public ViewerDesktop() + { + setBottom(getPlaybackController()); + } + + public void load(File file) + { + + } + + public void close() + { + + } + + private PlaybackController getPlaybackController() + { + if(mPlaybackController == null) + { + mPlaybackController = new PlaybackController(); + } + + return mPlaybackController; + } +}