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

📄 guipanel.java

📁 nesC写的heed算法
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// $Id: GuiPanel.java,v 1.9.4.4 2003/08/21 20:48:28 smadden 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. *//* * QueryFrame.java * Main class to allow users to build and distribute queries over the network... * Created on May 21, 2002, 10:16 AM *//** * * @author  madden */package net.tinyos.tinydb;import java.awt.*;import javax.swing.*;import javax.swing.event.*;import java.awt.event.*;import java.util.*;import javax.swing.border.*;import java.io.*;import java.sql.*;import net.tinyos.tinydb.awtextra.*;import net.tinyos.tinydb.topology.*;import net.tinyos.tinydb.parser.*;public class GuiPanel extends JPanel implements CatalogListener {    //constants for UI layout    static final int PANEL_WID = 530; //width of main panel (excluding buttons on right side)    static final int BUT_SEP = 10; //separator between buttons    static final int SEND_BUT_TOP = 5;    static final int BUT_HEIGHT = 30; //height of buttons    static final int CHECK_BOX_LEFT = 10;    static final int CHECK_BOX_WID = 20; //width of check box without labels    static final int ATTR_POPUP_WID = 120; //width of an attribute popup    static final int GROUP_LABEL_WID = 100; //width of "group by" label    static final int GRP_OPS_WID = 60;  //width of group by operations combo box    static final int GRP_CONST_WID = 60;  //width of group by constant field box    static final int SELECT_PANEL_HEIGHT = 105;     //height of select panel    static final int SCROLLER_LABEL_WID = 200;	 //width of labels at top of scroller panels    static final int SCROLLER_HEIGHT = 150; //height of scroller box    static final int SCROLLER_TOP = 60; //top of scroller box    static final int L_SCROLLER_LEFT = 20; //left side of scroller box    static final int EPOCH_LABEL_WID = 150; //width of "epoch duration" label    static final int TOP_ROW = 5; //where the top row begins    static final int TEXT_HEIGHT = 20; //height of text items    static final int SQL_BOX_HEIGHT = 90; //height of SQL string text box    static final int TRIGGER_LABEL_WID = 150; //width of "trigger action" label    static final int TRIGGER_ACTION_WID = 190; //width of trigger action popup    static final int LOG_CHECK_WID = 200;        static final int SEND_BUT_LEFT = PANEL_WID + BUT_SEP;    static final int TOPO_BUT_TOP = SEND_BUT_TOP + BUT_HEIGHT + BUT_SEP;    static final int MAGNET_BUT_TOP = TOPO_BUT_TOP + BUT_HEIGHT + BUT_SEP;    static final int GROUP_LABEL_LEFT = CHECK_BOX_LEFT + CHECK_BOX_WID;    static final int ATTR_POPUP_LEFT = GROUP_LABEL_LEFT + GROUP_LABEL_WID;    static final int GRP_OPS_LEFT = ATTR_POPUP_LEFT + ATTR_POPUP_WID;    static final int GRP_CONST_LEFT = GRP_OPS_LEFT + GRP_OPS_WID;    static final int NEW_PRED_LEFT = GRP_CONST_LEFT + GRP_CONST_WID + BUT_SEP - 5;  //the side of the button was being cut off, thus -5    static final int GROUP_PANEL_HEIGHT = BUT_HEIGHT;    static final int SCROLLER_WIDTH = SCROLLER_LABEL_WID - 20;    static final int AGG_BOX_LEFT = L_SCROLLER_LEFT + SCROLLER_WIDTH + BUT_SEP;    static final int SEL_BUTTON_LEFT = AGG_BOX_LEFT + 20;    static final int AGG_BOX_WID = ATTR_POPUP_WID;    static final int R_SCROLLER_LEFT = AGG_BOX_LEFT + AGG_BOX_WID + BUT_SEP;    static final int ATTR_BUT_TOP = SCROLLER_TOP + BUT_HEIGHT; //top of scroller attribute button    static final int SEL_BUT_TOP = ATTR_BUT_TOP + BUT_HEIGHT + 5;    static final int EPOCH_BOX_WID = ATTR_POPUP_WID;    static final int EPOCH_BOX_LEFT = L_SCROLLER_LEFT + EPOCH_LABEL_WID;        static final int SCROLLER_LABEL_TOP = SCROLLER_TOP - TEXT_HEIGHT;    static final int SQL_BOX_LEFT = L_SCROLLER_LEFT;    static final int SQL_BOX_TOP = SCROLLER_TOP + SCROLLER_HEIGHT + BUT_SEP;    static final int SQL_BOX_WID = (R_SCROLLER_LEFT - L_SCROLLER_LEFT) + SCROLLER_WIDTH;    static final int GROUP_PANEL_TOP = SQL_BOX_TOP + SQL_BOX_HEIGHT + BUT_SEP; //was 310    static final int SELECT_PANEL_TOP = GROUP_PANEL_TOP + GROUP_PANEL_HEIGHT+ BUT_SEP;	    static final int TRIGGER_TOP = SELECT_PANEL_TOP + SELECT_PANEL_HEIGHT + BUT_SEP;    static final int TRIGGER_LABEL_LEFT = GROUP_LABEL_LEFT;    static final int TRIGGER_ACTION_LEFT = TRIGGER_LABEL_LEFT + TRIGGER_LABEL_WID + BUT_SEP;    static final int LOG_CHECK_LEFT = TRIGGER_ACTION_LEFT + TRIGGER_ACTION_WID + BUT_SEP;    static final int TRIGGER_PANEL_WID = LOG_CHECK_LEFT + LOG_CHECK_WID;        /** Creates new panel GuiPanel */    public GuiPanel(TinyDBNetwork nw) {		//init ui		this.nw = nw;		initComponents();		Catalog.curCatalog.addListener(this);    }        //construct the UI    private void initComponents() {		UIManager.put("Label.font", normalFont);		UIManager.put("Button.font", normalFont);		UIManager.put("CheckBox.font", normalFont);		UIManager.put("ComboBox.font", normalFont);		setFont(normalFont);		setFont(normalFont);				selectGroupPanel = new JPanel();		selectGroupPanel.setFont(normalFont);		groupByPanel = new JPanel();		groupCheckBox = new JCheckBox();		groupLabel = new JLabel();				groupBox = new JComboBox();		groupBox.setLightWeightPopupEnabled(false);		addFieldsToMenu(groupBox);				groupByOps = new JComboBox();		groupByOps.setLightWeightPopupEnabled(false);		addArithOpsToMenu(groupByOps);		groupByOps.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						JComboBox cb = (JComboBox)evt.getSource();						String op = (String)cb.getSelectedItem();						if (!op.equals("")) {							groupByConst.setEnabled(true);						} else {							groupByConst.setEnabled(false);						}						updateSQL();						//updateAttributeLists();					}				});				groupByConst = new JTextField();		groupByConst.setEnabled(false);		groupByConst.getDocument().addDocumentListener(new DocumentListener() {					public void changedUpdate(DocumentEvent e){						updateSQL();					}					public void insertUpdate(DocumentEvent e){						updateSQL();					}					public void removeUpdate(DocumentEvent e){						updateSQL();					}				});		groupByConst.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						//updateAttributeLists();					}				});				attenuationBox = new JComboBox(attens);		attenuationBox.setLightWeightPopupEnabled(false);		aggregateBox = new JComboBox();		aggregateBox.setLightWeightPopupEnabled(false);		addAggsToMenu(aggregateBox);		epochBox = new JComboBox();		epochBox.setLightWeightPopupEnabled(false);		addEpochsToMenu(epochBox);		newPredButton = new JButton();		selectSrcList = new JList();		selectSrcList.setFont(textBoxFont);		selectDestList = new JList();		selectDestList.setFont(textBoxFont);		removeSelButton = new JButton();		addSelButton = new JButton();		selectFieldsLabel = new JLabel();		selectedLabel = new JLabel();		sqlString = new JTextArea();		sqlString.setLineWrap(true);		sqlString.setEditable(false);		sqlString.setBorder(new LineBorder(new java.awt.Color(0, 0, 0)));		sqlString.setFont(textBoxFont);				triggerCheckBox = new JCheckBox();		triggerLabel = new JLabel("TRIGGER ACTION");		triggerActionBox = new JComboBox(triggerActions);		triggerActionBox.setLightWeightPopupEnabled(false);		triggerPanel = new JPanel();				logCheckBox = new JCheckBox("Log to Database");		logCheckBox.setSelected(false);				jSeparator2 = new JSeparator();				setLayout(new AbsoluteLayout());		final GuiPanel queryFrame = this;				selectGroupPanel.setLayout(new java.awt.GridLayout(3, 0, 5, 5));		//        selectGroupPanel.setBackground(java.awt.Color.white);		selectGroupPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));				groupByPanel.setLayout(new AbsoluteLayout());				//        groupByPanel.setBackground(java.awt.Color.white);				groupBox.setEnabled(false);		oldGroup = groupBox.getSelectedItem();		groupBox.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						if (oldGroup != groupBox.getSelectedItem()) {							if (!checkSelectionConsistency(selectDestList,null)) {								groupBox.setSelectedItem(oldGroup);							} else {								oldGroup = groupBox.getSelectedItem();								constrainAggregateChoices();							}						}					}				});				groupLabel.setEnabled(false);		groupByOps.setEnabled(false);		groupByConst.setEnabled(false);				//        groupCheckBox.setBackground(java.awt.Color.white);						groupCheckBox.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						groupCheckBoxAction(evt);					}				});								groupByPanel.add(groupCheckBox, new AbsoluteConstraints(CHECK_BOX_LEFT, 0, CHECK_BOX_WID, BUT_HEIGHT));						groupLabel.setText("GROUP BY");		groupByPanel.add(groupLabel, new AbsoluteConstraints(GROUP_LABEL_LEFT, 0, GROUP_LABEL_WID, BUT_HEIGHT));		groupByPanel.add(groupBox, new AbsoluteConstraints(ATTR_POPUP_LEFT, 0, ATTR_POPUP_WID, BUT_HEIGHT));		groupByPanel.add(groupByOps, new AbsoluteConstraints(GRP_OPS_LEFT, 0, GRP_OPS_WID, BUT_HEIGHT));		groupByPanel.add(groupByConst, new AbsoluteConstraints(GRP_CONST_LEFT, 0, GRP_CONST_WID, BUT_HEIGHT));				add(groupByPanel, new AbsoluteConstraints(0,GROUP_PANEL_TOP, PANEL_WID, GROUP_PANEL_HEIGHT));				add(selectGroupPanel, new AbsoluteConstraints(0, SELECT_PANEL_TOP , PANEL_WID, SELECT_PANEL_HEIGHT));				newPredButton.setText("New Predicate");		newPredButton.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						newPredButtonActionPerformed(evt);					}				});				groupByPanel.add(newPredButton, new AbsoluteConstraints(NEW_PRED_LEFT, 0, -1, BUT_HEIGHT));				///////////////////////////////////		// List of available attributes				selectSrcList.setBorder(new LineBorder(new java.awt.Color(0, 0, 0)));		selectSrcList.setMinimumSize(new java.awt.Dimension(100, 100));		selectSrcList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);		addSelectChoices(selectSrcList);				selectSrcList.addMouseListener(new MouseAdapter() {					public void mouseClicked(MouseEvent evt) {						constrainAggregateChoices();						//add to dest list if double click						if (evt.getClickCount() > 1) {							addSelButtonActionPerformed();						}					}				});				JScrollPane srcScroller = new JScrollPane(selectSrcList);		add(srcScroller, new AbsoluteConstraints(L_SCROLLER_LEFT, SCROLLER_TOP,												 SCROLLER_WIDTH, SCROLLER_HEIGHT));				////////////////////////////////////		// List of attributes in query				selectDestList.setBorder(new LineBorder(new java.awt.Color(0, 0, 0)));		selectDestList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);				selectDestList.addMouseListener(new MouseAdapter() {					public void mouseClicked(MouseEvent evt) {						if (evt.getClickCount() > 1) {							removeSelButtonActionPerformed();						}					}				});				JScrollPane destScroller = new JScrollPane(selectDestList);		add(destScroller, new AbsoluteConstraints(R_SCROLLER_LEFT, SCROLLER_TOP,												  SCROLLER_WIDTH,												  SCROLLER_HEIGHT));								removeSelButton.setText("<<<");		removeSelButton.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						removeSelButtonActionPerformed();					}				});				add(aggregateBox, new AbsoluteConstraints(AGG_BOX_LEFT, ATTR_BUT_TOP, AGG_BOX_WID,BUT_HEIGHT));				add(addSelButton, new AbsoluteConstraints(SEL_BUTTON_LEFT, SEL_BUT_TOP, -1, -1));				add(removeSelButton, new AbsoluteConstraints(SEL_BUTTON_LEFT, SEL_BUT_TOP + BUT_HEIGHT, -1, -1));				addSelButton.setText(">>>");		addSelButton.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						addSelButtonActionPerformed();					}				});										JLabel epochsLabel = new JLabel();		epochsLabel.setText("Sample Period");		add(epochsLabel, new AbsoluteConstraints(L_SCROLLER_LEFT, TOP_ROW + 5, -1, TEXT_HEIGHT));				add(epochBox, new AbsoluteConstraints(EPOCH_BOX_LEFT, TOP_ROW ,ATTR_POPUP_WID,BUT_HEIGHT));		epochBox.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						epochDur = ((Integer)epochBox.getSelectedItem()).intValue();						updateSQL();					}									});				selectFieldsLabel.setText("Available Attributes");		selectFieldsLabel.setFont(boldFont);		add(selectFieldsLabel, new AbsoluteConstraints(L_SCROLLER_LEFT, SCROLLER_LABEL_TOP,													   SCROLLER_LABEL_WID, TEXT_HEIGHT));				selectedLabel.setText("Projected Attributes");		selectedLabel.setFont(boldFont);		add(selectedLabel, new AbsoluteConstraints(R_SCROLLER_LEFT, SCROLLER_LABEL_TOP,												   SCROLLER_LABEL_WID, TEXT_HEIGHT));				add(jSeparator2, new AbsoluteConstraints(-10, 30, 600, 0));				add(sqlString, new AbsoluteConstraints(SQL_BOX_LEFT, SQL_BOX_TOP,											   SQL_BOX_WID, SQL_BOX_HEIGHT));		updateSQL();								triggerPanel.setLayout(new AbsoluteLayout());				triggerActionBox.setEnabled(false);		triggerActionBox.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						updateSQL();					}				});				triggerLabel.setEnabled(false);				triggerCheckBox.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						triggerCheckBoxAction();					}				});		triggerPanel.add(triggerCheckBox, new AbsoluteConstraints(CHECK_BOX_LEFT, 0, CHECK_BOX_WID, BUT_HEIGHT));		triggerPanel.add(triggerLabel, new AbsoluteConstraints(TRIGGER_LABEL_LEFT, 0, TRIGGER_LABEL_WID, BUT_HEIGHT));		triggerPanel.add(triggerActionBox, new AbsoluteConstraints(TRIGGER_ACTION_LEFT, 0, TRIGGER_ACTION_WID, BUT_HEIGHT));		triggerPanel.add(logCheckBox, new AbsoluteConstraints(LOG_CHECK_LEFT,0,LOG_CHECK_WID,-1));				add(triggerPanel, new AbsoluteConstraints(0,TRIGGER_TOP, TRIGGER_PANEL_WID, BUT_HEIGHT));				    }        public void magnetDemo() {		byte qid = MainFrame.allocateQID();		MagnetFrame mf = new MagnetFrame(qid, nw);		mf.show();		if (resultWins.size() <= (qid + 1))			resultWins.setSize(qid+1);		resultWins.setElementAt(mf,qid);    }	    public void displayTopology() {		if (topologyWindowUp)			return;				try {			topologyFrame = new MainClass(nw, MainFrame.allocateQID());		} catch (Exception e) { }    }	    public void sendQuery() {	    byte qid = MainFrame.allocateQID();			    updateSQL();	    TinyDBQuery curQuery = generateQuery(qid, epochDur);	    if (curQuery == null)			return;	    curQuery.setSQL(sqlString.getText());	    if (curQuery != null) {			ResultFrame rf = new ResultFrame(curQuery, nw);			

⌨️ 快捷键说明

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