📄 servicetimespanel.java
字号:
/**
* 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.ServiceTimesParametricAnalysis;
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: ServiceTimesPanel</p>
* <p>Description: this is the panel for he parametric analysis where
* the service time inside a station is modified.</p>
*
* @author Francesco D'Aquino
* Date: 9-mar-2006
* Time: 16.19.35
*/
public class ServiceTimesPanel 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 JLabel stationChooserLabel;
private JComboBox stationChooser;
private JScrollPane scroll;
private JTextArea description;
private JScrollPane descrPane;
private TitledBorder descriptionTitle;
private ParametricAnalysisChecker checker;
private String DESCRIPTION_SINGLE;
private ServiceTimesParametricAnalysis STPA;
public ServiceTimesPanel(ServiceTimesParametricAnalysis stpa,ClassDefinition classDef, StationDefinition stationDef, SimulationDefinition simDef) {
super();
STPA = stpa;
super.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
super.setDividerSize(3);
DESCRIPTION = "Repeat the simulation with different service times of a station for" +
" the jobs of all the classes.\n\n" +
"The 'To' value represents the proportion of the final service time with" +
" respect to the initial value.\n\n" +
"The 'all class proportionally' option" +
" will not be enabled for those stations where at least one of the two following conditions is true:\n" +
" - there is at least one class with a service time distribution with infinite or null mean value;\n" +
" - there is at least one load dependent class";
DESCRIPTION_SINGLE = "Repeat the simulation changing the service time of a station for" +
" one class only.\n\n" +
"The 'To' value represents the final mean value of service time distribution.";
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 service time of all classes");
allClass.setToolTipText("Change service time of all classes");
singleClass = new JRadioButton("Change service time of one class");
singleClass.setToolTipText("Change only the service time of one class");
ButtonGroup group = new ButtonGroup();
group.add(allClass);
group.add(singleClass);
allClass.setSelected(true);
radioButtonsPanel.add(allClass);
radioButtonsPanel.add(singleClass);
radioButtonsPanel.setBorder(new EmptyBorder(5,20,0,20));
JPanel edit = new JPanel(new GridLayout(5,1,0,5));
ParametricAnalysisChecker checker = new ParametricAnalysisChecker(cd,sd,simd);
Vector avaibleS = checker.checkForServiceTimesParametricAnalysisAvaibleStations();
String[] stationNames = new String[avaibleS.size()];
for (int i=0;i<avaibleS.size();i++) stationNames[i] = sd.getStationName(avaibleS.get(i));
classChooserLabel = new JLabel("Class:");
classChooser = new JComboBox();
classChooser.setToolTipText("Choose the class whose service time mean value inside the selected station will change");
stationChooser = new JComboBox(stationNames);
stationChooser.setToolTipText("Choose the station whose service time mean value will be change");
description = new JTextArea();
description.setOpaque(false);
description.setEditable(false);
description.setLineWrap(true);
description.setWrapStyleWord(true);
descrPane = new JScrollPane(description);
descriptionTitle = new TitledBorder(new EtchedBorder(), "Description");
descrPane.setBorder(descriptionTitle);
descrPane.setMinimumSize(new Dimension(80,0));
//if the reference station of the STPA is still avaible
if (avaibleS.contains(STPA.getReferenceStation())) {
stationChooser.setSelectedItem(sd.getStationName(STPA.getReferenceStation()));
}
//else select another one
else {
STPA.setReferenceStation(avaibleS.get(0));
stationChooser.setSelectedIndex(0);
}
if (STPA.isSingleClass()) {
fromLabel = new JLabel("From (s):");
from = new JTextField();
from.setEnabled(false);
from.setText(Double.toString(STPA.getInitialValue()));
toLabel = new JLabel("To (s):");
to = new JSpinner(new SpinnerNumberModel(STPA.getFinalValue(),0.001,Double.MAX_VALUE,0.001));
to.setToolTipText("Sets the final service time mean value expressed in seconds");
stepsLabel = new JLabel("Steps (n. of exec.): ");
steps = new JSpinner(new SpinnerNumberModel(STPA.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.checkForServiceTimesParametricSimulationAvaibleClasses(STPA.getReferenceStation());
String[] classeNames = new String[validC.size()];
for (int i=0;i<validC.size();i++) {
classeNames[i] = cd.getClassName(validC.get(i));
}
classChooser.removeAllItems();
for (int i=0;i<classeNames.length;i++) classChooser.addItem(classeNames[i]);
classChooser.setEnabled(true);
classChooser.setSelectedItem(cd.getClassName(STPA.getReferenceClass()));
singleClass.setSelected(true);
if ( (validC.size() < cd.getClassKeys().size()) || (cd.getClosedClassKeys().size() == 1) ) {
allClass.setEnabled(false);
}
allClass.setSelected(false);
description.setText(DESCRIPTION_SINGLE);
}
else {
fromLabel = new JLabel("From (%):");
from = new JTextField();
from.setEnabled(false);
from.setText(Double.toString(STPA.getInitialValue()));
toLabel = new JLabel("To (%):");
to = new JSpinner(new SpinnerNumberModel(STPA.getFinalValue(),0.1,Double.MAX_VALUE,0.1));
to.setToolTipText("Sets the final proportion of service time with respect to the initial");
stepsLabel = new JLabel("Steps (n. of exec.): ");
steps = new JSpinner(new SpinnerNumberModel(STPA.getNumberOfSteps(),2,ParametricAnalysis.MAX_STEP_NUMBER,1));
steps.setToolTipText("Sets the number of steps to be performed");
classChooser.setEnabled(false);
singleClass.setSelected(false);
allClass.setSelected(true);
description.setText(DESCRIPTION);
classChooser.addItem("All classes");
}
from.setBackground(Color.WHITE);
stationChooserLabel = new JLabel("Station:");
edit.add(fromLabel);
edit.add(from);
edit.add(toLabel);
edit.add(to);
edit.add(stepsLabel);
edit.add(steps);
edit.add(classChooserLabel);
edit.add(stationChooser);
edit.add(classChooser);
edit.setPreferredSize(new Dimension(130,108));
JPanel editLables = new JPanel (new GridLayout(5,1,0,5));
editLables.add(fromLabel);
editLables.add(toLabel);
editLables.add(stepsLabel);
editLables.add(stationChooserLabel);
editLables.add(classChooserLabel);
editLables.setPreferredSize(new Dimension(100,108));
JPanel editPanel = new JPanel();
editPanel.add(editLables);
editPanel.add(edit);
editPanel.setBorder(new EmptyBorder(10,20,0,20));
JPanel cont = new JPanel(new BorderLayout());
cont.add(radioButtonsPanel,BorderLayout.NORTH);
cont.add(editPanel,BorderLayout.CENTER);
scroll = new JScrollPane(cont);
title = new TitledBorder("Type of service time growth");
scroll.setBorder(title);
//description = new JTextArea(DESCRIPTION);
scroll.setMinimumSize(new Dimension(360,0));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -