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

📄 mainframe.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// $Id: MainFrame.java,v 1.8 2004/10/21 22:26:38 selfreference Exp $/*									tab:4 * "Copyright (c) 2000-2003 The Regents of the University  of California.   * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. *  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE      * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,  * 94704.  Attention:  Intel License Inquiry. *//** * @author Wei Hong * @author Matt Welsh */package net.tinyos.surge;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import net.tinyos.surge.GraphDisplayPanel;import net.tinyos.surge.Dialog.*;public class MainFrame extends javax.swing.JFrame  {    public static Font defaultFont = new Font("Helvetica", Font.PLAIN, 10);    public static Font bigFont = new Font("Helvetica", Font.PLAIN, 12);    public static Font boldFont = new Font("Helvetica", Font.BOLD, 10);    public static Color labelColor = new Color(255, 0, 0);    public static volatile boolean DEBUG_MODE = false;    public static volatile boolean STATUS_MODE = true;    public static volatile boolean SENSOR_MODE = true;    // Constants    public static int MIN_BEACON_RATE = 1000;    public static int MAX_BEACON_RATE = 10000;    public static int DEFAULT_BEACON_RATE = 1000;    public static int MIN_SAMPLE_RATE = 1000;    public static int MAX_SAMPLE_RATE = 10000;    public static int DEFAULT_SAMPLE_RATE = 2000;    public static int bcast_seqno = 0;    // The UART address. This appears as the parent addr in messages    // from node 0 (physically connected to the base station)    public static final short UART_ADDRESS = 0x007e;    // Base address in beacon messages (here, the UART address)    public static final short BEACON_BASE_ADDRESS = UART_ADDRESS;    // Actual TOS address of the base    public static final short BASE_ADDRESS = 0x00;    public MainFrame()    {	// setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);	setTitle("Sensor Network Topology");	getContentPane().setLayout(new BorderLayout(0,0));	setSize(700,500);	setVisible(false);	MainPanel.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));	getContentPane().add(BorderLayout.NORTH, MainPanel);	MainToolBar.setAlignmentY(0.222222F);	MainToolBar.setDoubleBuffered(true);	MainPanel.add(MainToolBar);	SymWindow aSymWindow = new SymWindow();	this.addWindowListener(aSymWindow);	SymAction lSymAction = new SymAction();	// Main menubar buttons	fitNetworkNowButton.setFont(defaultFont);	startRootBeaconButton.setFont(defaultFont);	sendSleepButton.setFont(defaultFont);	sendWakeupButton.setFont(defaultFont);	sendUnfocusButton.setFont(defaultFont);	sendUnfocusButton.setEnabled(false);	debugButton.setFont(defaultFont);	debugButton.setSelected(DEBUG_MODE);	statusButton.setFont(defaultFont);	statusButton.setSelected(STATUS_MODE);	sensorButton.setFont(defaultFont);	sensorButton.setSelected(SENSOR_MODE);	fitNetworkNowButton.addActionListener(lSymAction);	MainToolBar.add(fitNetworkNowButton);	startRootBeaconButton.addActionListener(lSymAction);	MainToolBar.add(startRootBeaconButton);	controlPanel.setFont (defaultFont);	controlPanel.addActionListener(lSymAction);	controlPanel.setToolTipText("View Control Panel");	MainToolBar.add(controlPanel);	sendSleepButton.addActionListener(lSymAction);	MainToolBar.add(sendSleepButton);	sendWakeupButton.addActionListener(lSymAction);	MainToolBar.add(sendWakeupButton);	sendUnfocusButton.addActionListener(lSymAction);	MainToolBar.add(sendUnfocusButton);	debugButton.addActionListener(lSymAction);	MainToolBar.addSeparator();	MainToolBar.add(debugButton);	statusButton.addActionListener(lSymAction);	MainToolBar.addSeparator();	MainToolBar.add(statusButton);	sensorButton.addActionListener(lSymAction);	MainToolBar.addSeparator();	MainToolBar.add(sensorButton);	getContentPane().add(BorderLayout.CENTER, MainScrollPane);	MainScrollPane.setOpaque(true);	MainScrollPane.setViewportView(GraphDisplayPanel);			MainScrollPane.getViewport().add(GraphDisplayPanel);	GraphDisplayPanel.setBounds(0,0,430,270);	GraphDisplayPanel.setLayout(null);	GraphDisplayPanel.setAutoscrolls(true);	//GraphDisplayPanel.setBounds(0,0,100,100);	//GraphDisplayPanel.setPreferredSize(new Dimension(100,100));	MainScrollPane.getViewport().add(GraphDisplayPanel);    }    /**     * Creates a new instance of JFrame1 with the given title.     * @param sTitle the title for the new frame.     * @see #JFrame1()     */    public MainFrame(String sTitle) {	this();	setTitle(sTitle);    }    /**     * Notifies this component that it has been added to a container     * This method should be called by <code>Container.add</code>, and      * not by user code directly.     * Overridden here to adjust the size of the frame if needed.     * @see java.awt.Container#removeNotify     */    public void addNotify()    {	// Record the size of the window prior to calling parents addNotify.	Dimension size = getSize();	super.addNotify();	if (frameSizeAdjusted)	    return;	frameSizeAdjusted = true;	// Adjust size of frame according to the insets and menu bar	javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();	int menuBarHeight = 0;	if (menuBar != null)	    menuBarHeight = menuBar.getPreferredSize().height;	Insets insets = getInsets();	setSize(insets.left + insets.right + size.width, insets.top + insets.bottom + size.height + menuBarHeight);    }    // Used by addNotify    boolean frameSizeAdjusted = false;    javax.swing.JPanel MainPanel = new javax.swing.JPanel();    javax.swing.JToolBar MainToolBar = new javax.swing.JToolBar();    javax.swing.JScrollPane MainScrollPane = new javax.swing.JScrollPane();    net.tinyos.surge.GraphDisplayPanel GraphDisplayPanel = new net.tinyos.surge.GraphDisplayPanel();    JButton fitNetworkNowButton = new JButton("Fit to screen");    JButton startRootBeaconButton = new JButton("Start root beacon");    JButton controlPanel = new JButton ("Control Panel");    JButton sendSleepButton = new JButton("Send sleep");    JButton sendWakeupButton = new JButton("Send wakeup");    JButton sendUnfocusButton = new JButton("Cancel focus");    JCheckBox statusButton = new JCheckBox("Status");    JCheckBox sensorButton = new JCheckBox("Readings");    JCheckBox debugButton = new JCheckBox("Debug");    Integer focusedNode = null;    boolean root_beacon_on = false;    public int tentativeSampleRate = DEFAULT_SAMPLE_RATE;    public int sampleRate = DEFAULT_SAMPLE_RATE;    class SymWindow extends java.awt.event.WindowAdapter {	public void windowClosing(java.awt.event.WindowEvent event) {	    Object object = event.getSource();	    if (object == MainFrame.this)		MainFrame_windowClosing(event);	}    }    void MainFrame_windowClosing(java.awt.event.WindowEvent event) {	MainClass.displayManager.stopDisplayThread();	System.exit(0);    }    class SymAction implements java.awt.event.ActionListener    {	public void actionPerformed(java.awt.event.ActionEvent event)	{	    Object object = event.getSource();	    if (object == fitNetworkNowButton)		fitNetworkNowMenuItem_action(event);	    else if (object == startRootBeaconButton) 		startRootBeaconMenuItem_action(event);	    else if (object == sendSleepButton) 		sendSleepMenuItem_action(event);	    else if (object == sendWakeupButton) 		sendWakeupMenuItem_action(event);	    else if (object == sendUnfocusButton) 		sendUnfocusMenuItem_action(event);	    else if (object == debugButton) 		debugMenuItem_action(event);	    else if (object == statusButton) 		statusMenuItem_action(event);	    else if (object == sensorButton) 		sensorMenuItem_action(event);	    else if (object == controlPanel)		controlPanel_action(event);	}    }    public net.tinyos.surge.GraphDisplayPanel GetGraphDisplayPanel()    {	return GraphDisplayPanel;    }    public javax.swing.JScrollPane GetMainScrollPane()    {	return MainScrollPane;    }     void fitNetworkNowMenuItem_action(java.awt.event.ActionEvent event)    {	try {	    net.tinyos.surge.MainClass.mainFrame.GetGraphDisplayPanel().FitToScreen();	} catch (java.lang.Exception e) {	}    }    void controlPanel_action (java.awt.event.ActionEvent event)    {	try {	    ControlPanelDialog cp = new ControlPanelDialog();	    controlPanel.setEnabled(false);	    cp.show();	}	catch (java.lang.Exception e) {	}    }    public class ControlPanelDialog extends javax.swing.JDialog    {		JButton changeSampleRateButton = new JButton();	JSlider BeaconRate = new JSlider(JSlider.CENTER, MIN_BEACON_RATE, 					 MAX_BEACON_RATE, DEFAULT_BEACON_RATE);	JLabel BeaconRateLabel = new JLabel("Root beacon rate", JLabel.CENTER);	JSlider SampleRate = new JSlider (JSlider.CENTER, MIN_SAMPLE_RATE, 					  MAX_SAMPLE_RATE, DEFAULT_SAMPLE_RATE);	JLabel SampleRateLabel = new JLabel("Sample rate", JLabel.CENTER);	SymAction lSymAction = new SymAction();	SymChange lSymChange = new SymChange();	boolean beaconPressed = false;	public ControlPanelDialog()

⌨️ 快捷键说明

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