⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vojxtadialogpanel.java

📁 jxta官方例程
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * VoJxtaDialogPanel.java * * Created on February 26, 2005, 1:56 PM */package net.jxta.myjxta.plugins.vojxta;import java.awt.CardLayout;import java.awt.EventQueue;import java.awt.Font;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.io.File;import java.util.Dictionary;import java.util.Hashtable;import java.util.ResourceBundle;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JSeparator;import javax.swing.JSlider;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import net.jxta.myjxta.View;import net.jxta.myjxta.dialog.Dialog;import net.jxta.myjxta.dialog.DialogMessage;import net.jxta.myjxta.plugin.PluginPanel;import net.jxta.myjxta.util.Resources;import org.apache.log4j.Level;import org.apache.log4j.Logger;import net.jxta.myjxta.ui.*;/** * *   * * @author Jeff Moore, Ravi * @modified 2005-03-04 jamoore : add call control panel, audio controls * @modified 2005-03-14 jamoore : add config panel * @modified 2005-03-15 jamoore : add stats panel, UI update thread * @modified 2005-03-22 jamoore : add stats per interval * @modified 2005-03-26 jamoore : add resource strings */public class VoJxtaDialogPanel extends JPanel implements PluginPanel {        static final Logger LOG = Logger.getLogger (VoJxtaDialogPanel.class);        private static final ResourceBundle STRINGS = Resources.getStrings();    //hACK!    public static final String INITIATED_LOCALLY = "VoJxtaDialogInitiatedLocally";        /** display strings... replace with resources */        private static final String DISPLAY_SESSION_VOJXTA_DISCONNECTED = STRINGS.getString ("label.vojxta.disconnected");        private static final String DISPLAY_SESSION_VOJXTA_DISCONNECTING = STRINGS.getString ("label.vojxta.disconnecting");        private static final String DISPLAY_SESSION_VOJXTA_CONNECTED = STRINGS.getString ("label.vojxta.connected");        private static final String DISPLAY_SESSION_VOJXTA_CONNECTING = STRINGS.getString ("label.vojxta.connecting");;        private static final String DEFAULT_SESSION_FILE_NAME = "MyJxtaAudioLog.speex";        private static final String DISPLAY_SESSION_VOJXTA_STARTING = STRINGS.getString ("label.vojxta.starting");        private static final String DISPLAY_SESSION_VOJXTA_STARTED = STRINGS.getString ("label.vojxta.started");        private static final String DISPLAY_SESSION_VOJXTA_ENDING = STRINGS.getString ("label.vojxta.ending");        private static final String DISPLAY_SESSION_VOJXTA_ENDED = STRINGS.getString ("label.vojxta.ended");        private static final String DISPLAY_SESSION_VOJXTA_INCALL = STRINGS.getString ("label.vojxta.incall");        private static final String DISPLAY_SESSION_VOJXTA_HOLDING = STRINGS.getString ("label.vojxta.holding");        /** Panel names for card layout*/        private static final String CONFIG_PANEL = "ConfigPanel";        private static final String STATS_PANEL = "StatsPanel";        private static final String CALL_PANEL = "CallPanel";        /** sleep time for the UI update thread*/        private static final int UI_UPDATE_INTERVAL = 1000;        /** sleep time while waiting for dialog pipe to connect */        private static final int CONNECT_SLEEP_TIME = 200;        /** UI constructs */        private JButton startCallButton  = null;        private JButton endCallButton  = null;        private JButton configButton  = null;        private JButton holdCallButton  = null;        private JButton dismissButton = null;        private JLabel messageLabel = null;        private JLabel incomingBufferSizeLabel = null;        private JLabel incomingBufferCapacityLabel = null;        private JLabel outgoingBufferSizeLabel = null;        private JLabel outgoingBufferCapacityLabel = null;        private JLabel sessionLogFileNameLabel = null;        private JLabel statusLabel = null;        private JSlider qualitySlider = null;        private JSlider speakerVolumeSlider = null;    private JSlider outgoingMessageSizeSlider = null;        private JSlider micVolumeSlider = null;        private JCheckBox speakerMuteCheckBox  = null;        private JCheckBox saveConvoCheckBox  = null;        private JCheckBox micMuteCheckBox  = null;        private JLabel bytesReceivedLabel = null;        private JLabel messagesReceivedLabel = null;        private JLabel bytesSentLabel = null;        private JLabel outgoingMessageSizeSliderValueLabel = null;        private JLabel messagesSentLabel = null;        private CardLayout cardLayout = null;        private JPanel deckPanel = null;        private JLabel speakerLabel = null;        private JButton statsButton = null;        private JLabel encodedBufferSizeLabel = null;        private JLabel audioBlockSizeLabel = null;        private JLabel encodedBlockSizeLabel = null;        private JLabel callElapsedTimeLabel = null;        private JLabel callStartTimeLabel = null;        private JLabel callEndTimeLabel = null;        private JLabel outgoingMessagesPerSecondLabel = null;        private JLabel incomingMessagesPerSecondLabel = null;        private JLabel outgoingBytesPerSecondLabel = null;        private JLabel incomingBytesPerSecondLabel = null;        private JLabel compressionRatioLabel = null;        private JLabel qualityLabel = null;        private JLabel averageDecodeTimeLabel = null;        private JLabel averageEncodeTimeLabel = null;    private JLabel encodedMessageSizeLabel = null;        private JLabel pcmBufferSizeLabel = null;        private JLabel sourceLineAvailableLabel =  null;    private JLabel micLabel     = null;        Insets panelInsets =null;        Insets subComponentInsets = null;        /** dilaog on which to receive messages */    private Dialog vojxtaDialog = null;        /** controller */    private View view = null;        /** if we initiated the audio session this static is set to true. at present        it is set in the UI action for vojxta*/    private static boolean initiatedLocally = false;        /** Only one audio session at a time may be initiated  */    private static boolean inSession = false;    /** This table is used by the encode/decode routines to map quality levels        to ecoded block size in bytes. This will allow us to change the quality      *  on startup and in the future dynamically while in a call      */    Dictionary qualityLabelTable = null;        /** recreating a new dialog message takes too much time. use this indstaed*/    private DialogMessage templateMessage = null;        /** cycles for updates to the UI, used for stats collection*/    private UIUpdateThread updateThread = null;        /** protocol handler for jxta audio*/    private VoJxtaCallControl callControl = null;        /** Updates the UI with statistical info*/            /** statistics */    private long previousIncomingBytesValue = 0;        /** statistics */    private long previousOutgoingBytesValue = 0;        /** statistics */    private long previousIncomingMessagesValue = 0;        /** statistics */    private long previousOutgoingMessagesValue = 0;        /** Creates a new instance of VOJXTADialogPanelent tag denoting  */    public VoJxtaDialogPanel (View p_view, Dialog dialog) {                super ();                /** lookup table for slider tick labels */        qualityLabelTable = new Hashtable () ;        qualityLabelTable.put (new Integer(0), new JLabel ("Good"));        qualityLabelTable.put (new Integer(1), new JLabel ("1"));        qualityLabelTable.put (new Integer(2), new JLabel ("2"));        qualityLabelTable.put (new Integer(3), new JLabel ("3"));        qualityLabelTable.put (new Integer(4), new JLabel ("4"));        qualityLabelTable.put (new Integer(5), new JLabel ("5"));        qualityLabelTable.put (new Integer(6), new JLabel ("6"));        qualityLabelTable.put (new Integer(7), new JLabel ("7"));        qualityLabelTable.put (new Integer(8), new JLabel ("8"));        qualityLabelTable.put (new Integer(9), new JLabel ("9"));        qualityLabelTable.put (new Integer(10), new JLabel ("Best"));                        LOG.setLevel (Level.INFO);                        panelInsets = new Insets (5,5,5,5);        subComponentInsets = new Insets (3,3,3,3);                if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("start vojxtadialogpanel");        }                this.view = p_view;                this.vojxtaDialog = dialog;                this.callControl  = new VoJxtaCallControl (this, this.view,  dialog, initiatedLocally);                if(!this.vojxtaDialog.isConnected ()) {            if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("Constructor : VoJxtaDialog not connected");        }                        localActionDismiss();                 }else{                    UI();                        /** UI update thread for stats, call times etc*/        updateThread = new UIUpdateThread ();                updateThread.setDaemon (true);                setVisible (true);        //LOG.setLevel (Level.ERROR);        }    }        /**     *  We need to inject who inititated the audio session. This is problematic.      *  Since there is only one set of hardware (mic, speaker) there can only be      *  one session running at a time. We can logically separate sessions but     *  they all must access the same hardware. At the moment the solution is to     *  keep audio session limited to one. If another session i sactive, by calling      *  VoXJTADialog.isInSession() then we fail the invite.     */    public static void setInitiatedLocally(boolean initiatedLocally) {                VoJxtaDialogPanel.initiatedLocally = initiatedLocally;                setInSession(initiatedLocally);            }        /**     * Returns if this audio session was inited locally (true) or initiated from     * a remote peer (false)     */    protected static boolean isInitiatedLocally() {                return VoJxtaDialogPanel.initiatedLocally;    }        /**     *  Returns if a call is already in session.  At the moment only one audio      *  session per myjxta instance is allowed.     */    public static boolean isInSession() {                return VoJxtaDialogPanel.inSession;    }        protected static void setInSession( boolean inSession) {                VoJxtaDialogPanel.inSession = inSession;    }        /**     *  Switch cardlayout to show a new panel     */    protected void localActionShowPanel (final String panelName) {                EventQueue.invokeLater (new Runnable () {                        public void run () {                                cardLayout.show (deckPanel, panelName);                            }        });    }        public void dismiss() {        if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("Dismiss called");        }           // any close operations go here        this.vojxtaDialog.clear();                 if(getCallControl() != null) {            this.getCallControl ().destroy ();        }                this.callControl = null;    }        public Dialog getDialog() {                return this.vojxtaDialog;    }        /**     *  Signal from the UI denoting a change in the speaker volume sluder     */    private void localActionSpeakerGainChanged (float newValue) {                getCallControl ().adjustSpeakerGainControl (newValue);            }        /**     *  UI action denoting config setting have been accepted     */    private void localActionApplyConfigSettings () {                getCallControl ().setLocalVoiceQuality (qualitySlider.getValue ());                cardLayout.show (deckPanel, this.CALL_PANEL);            }            /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -