📄 statspanel.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.engine.jwat.workloadAnalysis.panels;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import jmt.engine.jwat.VariableNumber;
import jmt.engine.jwat.VariableString;
import jmt.engine.jwat.filters.FilterOnData;
import jmt.engine.jwat.filters.FilterOnNumeric;
import jmt.engine.jwat.filters.FilterOnString;
import jmt.engine.jwat.filters.IntervalFilter;
import jmt.engine.jwat.filters.RandomFilter;
import jmt.engine.jwat.filters.TrimmingBetweenFilter;
import jmt.engine.jwat.filters.TrimmingFilter;
import jmt.engine.jwat.workloadAnalysis.chart.DispMatrix;
import jmt.engine.jwat.workloadAnalysis.chart.DispQQPlotMatrix;
import jmt.engine.jwat.workloadAnalysis.chart.QQPlotPreviewPanel;
import jmt.engine.jwat.workloadAnalysis.chart.SmallPlotDistGraph;
import jmt.engine.jwat.workloadAnalysis.exceptions.TrasformException;
import jmt.engine.jwat.workloadAnalysis.tables.JWatBivariateStatsTable;
import jmt.engine.jwat.workloadAnalysis.tables.JWatBivariateStatsTableModel;
import jmt.engine.jwat.workloadAnalysis.tables.JWatUnivariateStatsTable;
import jmt.engine.jwat.workloadAnalysis.tables.JWatUnivariateStatsTableModel;
import jmt.engine.jwat.workloadAnalysis.utils.ChangeVariableListener;
import jmt.engine.jwat.workloadAnalysis.utils.ModelWorkloadAnalysis;
import jmt.engine.jwat.workloadAnalysis.utils.SetMatrixListener;
import jmt.engine.jwat.workloadAnalysis.wizard.WorkloadAnalysisWizard;
import jmt.gui.common.CommonConstants;
import jmt.gui.help.HoverHelp;
import jmt.gui.jwat.JWATConstants;
import jmt.gui.jwat.JWatWizard;
import jmt.gui.wizard.WizardPanel;
public class StatsPanel extends WizardPanel implements CommonConstants,JWATConstants {
//UPDATE 15/11/2006
private boolean isSampled = false;
// Tabbed pane statistics panel, univariate, bivariate, sampling operation and matrix
private JTabbedPane statisticsTabbed = new JTabbedPane();
// Univariate statistics panel
private JPanel uniStatsPanel = null;
// Bivariate statistics panel
private JPanel bivStatsPanel = null;
// Scroll pane statistics bivariate
private ScrollBivariatePanel panelBiv = null;
private JPanel samplePanel = null;
private JLabel sampleDescr = null;
private JPanel scatterMatrixPanel = null;
private JPanel optionSampling = null;
/* UPD */ private JPanel scatterQQPlot = null;
private DispQQPlotMatrix qqMatrix = null;
//Help Strings
private static String STATS_TABLE = "Click to select variable and see graphs and transofmrations applyable";
private static String TRANSF_PANEL = "Select transformation to apply or undo a previously transformation";
private static String TRANSF_COMBO = "Select transformation to apply";
// Descrizione del pannello unviariaet stats
public final static String UNIV_DESCRITPION = HTML_START + HTML_FONT_TITLE
+ "Univariate statistics" + HTML_FONT_TIT_END + HTML_FONT_NORM
+ "This panel shows univariate statistics and graphs"
+ HTML_FONT_NOR_END + HTML_END;
// Descrizione del pannello bivariate stats
public final static String BIVARIATE_DESCRIPTION = HTML_START
+ HTML_FONT_TITLE + "Bivariate statistics" + HTML_FONT_TIT_END
+ HTML_FONT_NORM + "This panel shows the correlation coefficient"
+ HTML_FONT_NOR_END + HTML_END;
// Descrizione del pannello di sampling e descrizioni dei sampling
public final static String SAMPLING_DESCRITPION = HTML_START
+ HTML_FONT_TITLE
+ "Sample construction (<I>Optional</I>)"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "Allows the construction of a sample extracted from observations"
+ HTML_FONT_NOR_END + HTML_END;
// Descrizione del pannello degli scatterplot
public final static String MATRIX_DESCRIPTION = HTML_START
+ HTML_FONT_TITLE
+ "Scatter plot matrix"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "This panel show scatter plot matrix of all variables. Double click on a scatter plot to open it in a new panel "
+ HTML_FONT_NOR_END + HTML_END;
// Descrizione del pannello degli scatterplot QQ
public final static String QQ_MATRIX_DESCRIPTION = HTML_START
+ HTML_FONT_TITLE
+ "QQ-plot matrix"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "This panel show QQ-plot matrix of all variables. Double click on a QQ-plot to open it in a new panel "
+ HTML_FONT_NOR_END + HTML_END;
public final static String SAMPLING_TRIMMING_DESCRITPION = HTML_START
+ HTML_FONT_TITLE
+ "Trimming Sampling<p>description"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "This operation allows to remove<p>undesired data from source<p>observations"
+ " specifying<p>percentiles."/*from<p>which or to remove<p>observations"*/
+ HTML_FONT_NOR_END + HTML_END;
public final static String SAMPLING_RANDOM_DESCRITPION = HTML_START
+ HTML_FONT_TITLE
+ "Random Sampling<p>description"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "Specify the number of<p>" +
"observations to be<p>" +
"considered."
+ HTML_FONT_NOR_END + HTML_END;
public final static String SAMPLING_INTERVAL_DESCRITPION = HTML_START
+ HTML_FONT_TITLE
+ "Observ. # interval<p>description"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "Specify the start ID and<p>" +
"end ID of observations<p>" +
"to be considered."
+ HTML_FONT_NOR_END + HTML_END;
public final static String SAMPLING_FILTERING_DESCRITPION = HTML_START
+ HTML_FONT_TITLE
+ "Interval Sampling<p>description"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "Specify observations to be<p>" +
"considered specifying interval<p>" +
"values (date and number type) or<p>" +
"substring (string type)."
+ HTML_FONT_NOR_END + HTML_END;
public final static String SAMPLING_TRIMMING_PANEL_DESC = HTML_START
+ HTML_FONT_TITLE
+ "WARNING"
+ HTML_FONT_TIT_END
+ HTML_FONT_NORM
+ "At this time you can apply any number of sampling operations and transformations to data with the constraint that you can't apply any transformation after a sampling;"
+ "if you undo a transformation, applied before a sampling, this completely resets the sample; "
+ "if you undo a sampling it completely resets the sample."
+ HTML_FONT_NOR_END + HTML_END;
public final static String TRANSF_BORDER_TEXT = "Apply to: ";
public final static String TRANSF_LABEL_APPLIED = "Transformations applied to variable ";
public final static String SAMPLING_LABEL_PANEL = "Option of the sampling operation";
// Table bivariate statistics and model
private JWatBivariateStatsTable tableBivariate;
private JWatBivariateStatsTableModel modelBivariate;
private ModelWorkloadAnalysis model = null;
// Add apply transformatio Action
protected AbstractAction applyTranformation = new AbstractAction("Apply transformation") {
{
putValue(Action.SHORT_DESCRIPTION,"Apply transformation to current selected variable");
}
// Removes all rows from inputTable and update varchooser comboBox and option panel
public void actionPerformed(ActionEvent arg0) {
// Check if selection is correctly made
if (variableTable.getSelectedRow() >= 0) {
if(!isSampled){
int curr = variableTable.getSelectedRow();
if (((String) transfs.getSelectedItem()).equals("Logarithmic")) {
try {
model.doTransformationOnVariable(variableTable
.getSelectedRow(),VariableNumber.LOGARITHMIC);
} catch (TrasformException e) {
JOptionPane
.showMessageDialog(
null,
"It's impossible to apply logaritmic transformation due to the presence of 0 or negative values",
"Erroe",
JOptionPane.INFORMATION_MESSAGE);
}
}
if (((String) transfs.getSelectedItem()).equals("Mix - Max")) {
try {
model.doTransformationOnVariable(variableTable
.getSelectedRow(),VariableNumber.MINMAX);
} catch (TrasformException e) {
JOptionPane
.showMessageDialog(
null,
e.getMsg(),
"Erroe",
JOptionPane.INFORMATION_MESSAGE);
}
}
if (((String) transfs.getSelectedItem())
.equals("Standard Deviation")) {
try {
model.doTransformationOnVariable(variableTable
.getSelectedRow(),VariableNumber.STDEV);
} catch (TrasformException e) {
JOptionPane
.showMessageDialog(
null,
e.getMsg(),
"Erroe",
JOptionPane.INFORMATION_MESSAGE);
}
}
variableTable.setRowSelectionInterval(curr,curr);
}else{
JOptionPane.showMessageDialog(StatsPanel.this,"At least one sampling has been applied, undo it and proceed.","Warinig",JOptionPane.WARNING_MESSAGE);
}
}
}
};
// Add undo transformation Action
protected AbstractAction undoTranformation = new AbstractAction("Undo transformation") {
{
putValue(Action.SHORT_DESCRIPTION,
"Undo previous transformation (if one) to current selected variable");
}
// Removes all rows from inputTable and update varchooser comboBox and option panel
public void actionPerformed(ActionEvent arg0) {
// Check if selection is correctly made
if (variableTable.getSelectedRow() >= 0) {
int curr = variableTable.getSelectedRow();
if(model.undoTransformationOnVariable(variableTable.getSelectedRow())){
undoSam.setEnabled(false);
isSampled = false;
}
variableTable.setRowSelectionInterval(curr,curr);
}
}
};
private HoverHelp help = null;
private WorkloadAnalysisWizard parent;
/**
* Constructor, creates statistics panel and adds four panel of statistics
* information
*
* @param parent
* model of workload analysis
*/
public StatsPanel(WorkloadAnalysisWizard parent) {
this.parent = parent;
model = parent.getModel();
help = parent.getHelp();
model.addOnSetMatrixObservationListener(new SetMatrixListener(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -