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

📄 arrivalratespanel.java

📁 一个用于排队系统仿真的开源软件,有非常形象的图象仿真过程!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * Copyright (C) 2006, Laboratorio di Valutazione delle Prestazioni - Politecnico di Milano

 * 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 2 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package jmt.gui.common.panels.parametric;

import jmt.gui.common.definitions.parametric.ParametricAnalysisChecker;
import jmt.gui.common.definitions.parametric.ArrivalRateParametricAnalysis;
import jmt.gui.common.definitions.parametric.ParametricAnalysis;
import jmt.gui.common.definitions.ClassDefinition;
import jmt.gui.common.definitions.StationDefinition;
import jmt.gui.common.definitions.SimulationDefinition;

import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import javax.swing.border.TitledBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.util.Vector;

/**
 * <p>Title: ArrivalRatesPanel</p>
 * <p>Description: this is the panel for the parametric analysis where the arrival
 *  rate for open classes is modified.</p>
 *
 * @author Francesco D'Aquino
 *         Date: 9-mar-2006
 *         Time: 16.08.09
 */
public class ArrivalRatesPanel extends ParameterOptionPanel {
    private JRadioButton allClass;
    private JRadioButton singleClass;
    private JLabel fromLabel;
    private JTextField from;
    private JLabel toLabel;
    private JSpinner to;
    private JLabel stepsLabel;
    private JSpinner steps;
    private JLabel classChooserLabel;
    private JComboBox classChooser;
    private JScrollPane scroll;
    private JTextArea description;
    private JScrollPane descrPane;
    private TitledBorder descriptionTitle;
    private ParametricAnalysisChecker checker;
    private String DESCRIPTION_SINGLE;
    private ArrivalRateParametricAnalysis ARPA;

    public ArrivalRatesPanel(ArrivalRateParametricAnalysis arpa,ClassDefinition classDef, StationDefinition stationDef, SimulationDefinition simDef) {
        super();
        ARPA = arpa;
        super.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        super.setDividerSize(3);

        DESCRIPTION = "Repeat the simulation with different arrival rate for all open " +
                "class.\n\n" +
                "The 'To' value represents the percentage of the final arrival rate with" +
                " respect of the initial value.\n\n" +
                "This option will not be available if there is at least one" +
                " open class with an interarrival time distribution with infinite or null mean value.\n\n";

        DESCRIPTION_SINGLE = "Repeat the simulation with different arrival rate for an open " +
                "class, provided that its distribution of interarrival time has a finite, not null, mean value. " +
                "The 'To' value is the final arrival rate.\n\n ";

        cd = classDef;
        sd = stationDef;
        simd = simDef;
        checker = new ParametricAnalysisChecker(cd,sd,simd);
        initialize();
    }

    public void initialize() {
        JPanel radioButtonsPanel = new JPanel(new GridLayout(2,1));
        allClass = new JRadioButton("Change arrival rates of all open classes");
        allClass.setToolTipText("Change arrival rates of all open classes");
        singleClass = new JRadioButton("Change the arrival rate of one open class");
        singleClass.setToolTipText("Change only the arrival rate of one open class");
        ButtonGroup group = new ButtonGroup();
        group.add(allClass);
        group.add(singleClass);
        radioButtonsPanel.add(allClass);
        radioButtonsPanel.add(singleClass);
        radioButtonsPanel.setBorder(new EmptyBorder(5,20,0,20));
        JPanel edit = new JPanel(new GridLayout(4,1,0,5));
        classChooserLabel = new JLabel("Class: ");
        classChooser = new JComboBox();
        classChooser.setToolTipText("Choose the class whose arrival rate will change");
        if (ARPA.isSingleClass()) {
            fromLabel = new JLabel("From (j/s):");
            from = new JTextField();
            from.setEnabled(false);
            from.setText(Double.toString(ARPA.getInitialValue()));
            toLabel = new JLabel("To (j/s): ");
            to = new JSpinner(new SpinnerNumberModel(ARPA.getFinalValue(),0.001,Double.MAX_VALUE,0.001));
            to.setToolTipText("Sets the final arrival rate in job/sec");
            stepsLabel = new JLabel("Steps (n. of exec.): ");
            steps = new JSpinner(new SpinnerNumberModel(ARPA.getNumberOfSteps(),2, ParametricAnalysis.MAX_STEP_NUMBER,1));
            steps.setToolTipText("Sets the number of steps to be performed");
            //get the vector containing the keys of the class that can be used to do this type of parametric analysis
            Vector validC = checker.checkForArrivalRatesParametricSimulationAvaibleClasses();
            String[] classNames = new String[validC.size()];
            for (int i=0; i<validC.size(); i++) classNames[i] = cd.getClassName(validC.get(i));
            //if there is only one class avaible or if the "all class" simulation is not avaible
            //disable the allClass radio button
            if ( (validC.size() < cd.getOpenClassKeys().size()) || (cd.getOpenClassKeys().size() == 1) ) {
                allClass.setEnabled(false);
            }
            classChooser.removeAllItems();
            for (int i=0;i<classNames.length;i++) classChooser.addItem(classNames[i]);
            classChooser.setEnabled(true);
            classChooser.setSelectedItem(cd.getClassName(ARPA.getReferenceClass()));
            singleClass.setSelected(true);
            allClass.setSelected(false);
        }
        else {
            fromLabel = new JLabel("From (%):");
            from = new JTextField();
            from.setEnabled(false);
            from.setText(Double.toString(ARPA.getInitialValue()));
            toLabel = new JLabel("To (%): ");
            to = new JSpinner(new SpinnerNumberModel(ARPA.getFinalValue(),0.1,Double.MAX_VALUE,0.1));
            to.setToolTipText("Sets the final proportion of arrival rate with respect to the initial");
            stepsLabel = new JLabel("Steps (n. of exec.): ");
            steps = new JSpinner(new SpinnerNumberModel(ARPA.getNumberOfSteps(),2,ParametricAnalysis.MAX_STEP_NUMBER,1));
            steps.setToolTipText("Sets the number of steps to be performed");
            classChooser.addItem("All open classes");
            classChooser.setEnabled(false);
            singleClass.setSelected(false);
            allClass.setSelected(true);
        }
        from.setBackground(Color.WHITE);
        edit.add(fromLabel);
        edit.add(from);
        edit.add(toLabel);
        edit.add(to);
        edit.add(stepsLabel);
        edit.add(steps);
        edit.add(classChooserLabel);
        edit.add(classChooser);
        edit.setPreferredSize(new Dimension(130,88));
        JPanel editLables = new JPanel (new GridLayout(4,1,0,5));
        editLables.add(fromLabel);
        editLables.add(toLabel);
        editLables.add(stepsLabel);
        editLables.add(classChooserLabel);
        editLables.setPreferredSize(new Dimension(100,88));
        JPanel editPanel = new JPanel();
        editPanel.add(editLables);

⌨️ 快捷键说明

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