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

📄 formulaviewer.java

📁 Contiki是一个开源
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2006, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: FormulaViewer.java,v 1.3 2008/02/18 08:21:59 fros4943 Exp $ */package se.sics.mrm;import java.awt.*;import java.awt.event.*;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.text.NumberFormat;import java.util.*;import javax.swing.*;import org.apache.log4j.Logger;import org.jdom.Element;import se.sics.cooja.*;/** * This plugin allows a user to reconfigure current radio channel parameters. * * @author Fredrik Osterlind */@ClassDescription("MRM - Formula Viewer")@PluginType(PluginType.SIM_PLUGIN)public class FormulaViewer extends se.sics.cooja.VisPlugin {  private static final long serialVersionUID = 1L;  private static Logger logger = Logger.getLogger(FormulaViewer.class);  private Simulation currentSimulation;  private MRM currentRadioMedium;  private ChannelModel currentChannelModel;  private static Dimension labelDimension = new Dimension(240, 20);  private static NumberFormat doubleFormat = NumberFormat.getNumberInstance();  private static NumberFormat integerFormat = NumberFormat.getIntegerInstance();  private Vector<JFormattedTextField> allIntegerParameters = new Vector<JFormattedTextField>();  private Vector<JFormattedTextField> allDoubleParameters = new Vector<JFormattedTextField>();  private Vector<JCheckBox> allBooleanParameters = new Vector<JCheckBox>();  private JPanel areaGeneral;  private JPanel areaTransmitter;  private JPanel areaReceiver;  private JPanel areaRayTracer;  private JPanel areaShadowing;  /**   * Creates a new formula viewer.   *   * @param simulationToVisualize Simulation which holds the MRM channel model.   */  public FormulaViewer(Simulation simulationToVisualize, GUI gui) {    super("MRM - Formula Viewer", gui);    currentSimulation = simulationToVisualize;    currentRadioMedium = (MRM) currentSimulation.getRadioMedium();    currentChannelModel = currentRadioMedium.getChannelModel();    // -- Create and add GUI components --    JPanel allComponents = new JPanel();    allComponents.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));    allComponents.setLayout(new BoxLayout(allComponents, BoxLayout.Y_AXIS));    JScrollPane scrollPane = new JScrollPane(allComponents);    scrollPane.setPreferredSize(new Dimension(500,400));    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);    setContentPane(scrollPane);    JPanel collapsableArea;    // General parameters    collapsableArea = createCollapsableArea("General parameters", allComponents);    areaGeneral = collapsableArea;    addBooleanParameter(        "apply_random",        currentChannelModel.getParameterDescription("apply_random"),        collapsableArea,        currentChannelModel.getParameterBooleanValue("apply_random")    );    addDoubleParameter(        "snr_threshold",        currentChannelModel.getParameterDescription("snr_threshold"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("snr_threshold")    );    addDoubleParameter(        "bg_noise_mean",        currentChannelModel.getParameterDescription("bg_noise_mean"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("bg_noise_mean")    );    addDoubleParameter(        "bg_noise_var",        currentChannelModel.getParameterDescription("bg_noise_var"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("bg_noise_var")    );    addDoubleParameter(        "system_gain_mean",        currentChannelModel.getParameterDescription("system_gain_mean"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("system_gain_mean")    );    addDoubleParameter(        "system_gain_var",        currentChannelModel.getParameterDescription("system_gain_var"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("system_gain_var")    );    addDoubleParameter(        "wavelength",        currentChannelModel.getParameterDescription("wavelength"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("wavelength")    );    // Transmitter parameters    collapsableArea = createCollapsableArea("Transmitter parameters", allComponents);    areaTransmitter = collapsableArea;    addDoubleParameter(        "tx_power",        currentChannelModel.getParameterDescription("tx_power"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("tx_power")    );    addDoubleParameter(        "tx_antenna_gain",        currentChannelModel.getParameterDescription("tx_antenna_gain"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("tx_antenna_gain")    );    // Receiver parameters    collapsableArea = createCollapsableArea("Receiver parameters", allComponents);    areaReceiver = collapsableArea;    addDoubleParameter(        "rx_sensitivity",        currentChannelModel.getParameterDescription("rx_sensitivity"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rx_sensitivity")    );    addDoubleParameter(        "rx_antenna_gain",        currentChannelModel.getParameterDescription("rx_antenna_gain"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rx_antenna_gain")    );    // Ray Tracer parameters    collapsableArea = createCollapsableArea("Ray Tracer parameters", allComponents);    areaRayTracer = collapsableArea;    addBooleanParameter(        "rt_disallow_direct_path",        currentChannelModel.getParameterDescription("rt_disallow_direct_path"),        collapsableArea,        currentChannelModel.getParameterBooleanValue("rt_disallow_direct_path")    );    addBooleanParameter(        "rt_ignore_non_direct",        currentChannelModel.getParameterDescription("rt_ignore_non_direct"),        collapsableArea,        currentChannelModel.getParameterBooleanValue("rt_ignore_non_direct")    );    addBooleanParameter(        "rt_fspl_on_total_length",        currentChannelModel.getParameterDescription("rt_fspl_on_total_length"),        collapsableArea,        currentChannelModel.getParameterBooleanValue("rt_fspl_on_total_length")    );    addIntegerParameter(        "rt_max_rays",        currentChannelModel.getParameterDescription("rt_max_rays"),        collapsableArea,        currentChannelModel.getParameterIntegerValue("rt_max_rays")    );    addIntegerParameter(        "rt_max_refractions",        currentChannelModel.getParameterDescription("rt_max_refractions"),        collapsableArea,        currentChannelModel.getParameterIntegerValue("rt_max_refractions")    );    addIntegerParameter(        "rt_max_reflections",        currentChannelModel.getParameterDescription("rt_max_reflections"),        collapsableArea,        currentChannelModel.getParameterIntegerValue("rt_max_reflections")    );    addIntegerParameter(        "rt_max_diffractions",        currentChannelModel.getParameterDescription("rt_max_diffractions"),        collapsableArea,        currentChannelModel.getParameterIntegerValue("rt_max_diffractions")    );/*    addBooleanParameter(        "rt_use_scattering",        currentChannelModel.getParameterDescription("rt_use_scattering"),        collapsableArea,        currentChannelModel.getParameterBooleanValue("rt_use_scattering")    );*/    addDoubleParameter(        "rt_refrac_coefficient",        currentChannelModel.getParameterDescription("rt_refrac_coefficient"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rt_refrac_coefficient")    );    addDoubleParameter(        "rt_reflec_coefficient",        currentChannelModel.getParameterDescription("rt_reflec_coefficient"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rt_reflec_coefficient")    );    addDoubleParameter(        "rt_diffr_coefficient",        currentChannelModel.getParameterDescription("rt_diffr_coefficient"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rt_diffr_coefficient")    );/*    addDoubleParameter(        "rt_scatt_coefficient",        currentChannelModel.getParameterDescription("rt_scatt_coefficient"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("rt_scatt_coefficient")    );*/    // Shadowing parameters    collapsableArea = createCollapsableArea("Shadowing parameters", allComponents);    areaShadowing = collapsableArea;    addDoubleParameter(        "obstacle_attenuation",        currentChannelModel.getParameterDescription("obstacle_attenuation"),        collapsableArea,        currentChannelModel.getParameterDoubleValue("obstacle_attenuation")    );    // Add channel model observer responsible to keep all GUI components synched    currentChannelModel.addSettingsObserver(channelModelSettingsObserver);    // Set initial size etc.    pack();    setVisible(true);    // Tries to select this plugin    try {      setSelected(true);    } catch (java.beans.PropertyVetoException e) {      // Could not select    }  }  /**   * Creates a new collapsable area which may be used for holding model parameters.   * @param title Title of area

⌨️ 快捷键说明

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