📄 statspanel.java
字号:
public void onSetMatrixObservation() {
((JWatUnivariateStatsTableModel) variableTable.getModel()).setMatrixObs(model.getMatrix());
variableTable.tableChanged(new TableModelEvent(variableTable.getModel()));
variableTable.setRowSelectionInterval(0, 0);
((JWatBivariateStatsTableModel) tableBivariate.getModel()).setMatrixObs(model.getMatrix());
tableBivariate.tableChanged(new TableModelEvent(tableBivariate.getModel()));
panelBiv.setNames();
dispPanel.setModel(model);
qqMatrix.setModel(model);
varsList.setListData(model.getMatrix().getVariableNames());
varsList.setSelectedIndex(0);
samplingList.clearSelection();
samplingList.setSelectedIndex(0);
}
public void onResetMatrixObservation() {
((JWatUnivariateStatsTableModel) variableTable.getModel()).setMatrixObs(model.getMatrix());
variableTable.tableChanged(new TableModelEvent(variableTable.getModel()));
((JWatBivariateStatsTableModel) tableBivariate.getModel()).setMatrixObs(model.getMatrix());
tableBivariate.tableChanged(new TableModelEvent(tableBivariate.getModel()));
panelBiv.setNames();
dispPanel.setModel(model);
qqMatrix.setModel(model);
varsList.setListData(new String[0]);
samplingList.clearSelection();
samplingList.setSelectedIndex(0);
}
});
this.setLayout(new GridLayout(1, 1));
this.add(statisticsTabbed);
// Add single panel to tabbed pane
uniStatsPanel = new JPanel(new GridLayout(1, 1));
samplePanel = new JPanel(new BorderLayout());
bivStatsPanel = new JPanel(new GridLayout(1, 1));
scatterMatrixPanel = new JPanel(new GridLayout(1, 1));
/* UPD */ scatterQQPlot = new JPanel(new GridLayout(1, 1));
createUnivariate();
createSampling();
createBivariate();
createMatrix();
/* UPD */ createMatrixQQ();
statisticsTabbed.addTab("Univariate", uniStatsPanel);
statisticsTabbed.addTab("Sample Construction", samplePanel);
statisticsTabbed.addTab("Bivariate", bivStatsPanel);
statisticsTabbed.addTab("QQ-plot Matrix", scatterQQPlot);
statisticsTabbed.addTab("Scatter plot Matrix", scatterMatrixPanel);
}
private void createMatrixQQ(){
Box mainBox = Box.createVerticalBox();
Box descBox = Box.createHorizontalBox();
Box tableBox = Box.createHorizontalBox();
scatterQQPlot.add(mainBox);
mainBox.add(Box.createVerticalStrut(10));
mainBox.add(descBox);
mainBox.add(Box.createVerticalStrut(10));
mainBox.add(tableBox);
mainBox.add(Box.createVerticalStrut(10));
descBox.add(new JLabel(QQ_MATRIX_DESCRIPTION));
qqMatrix = new DispQQPlotMatrix();
tableBox.add(qqMatrix);
}
/**
* Sets up univariate statistics panel
*/
private void createUnivariate() {
Box mainBox = Box.createVerticalBox();
Box centralBox = Box.createHorizontalBox();
mainBox.add(Box.createVerticalStrut(10));
mainBox.add(centralBox);
mainBox.add(Box.createVerticalStrut(10));
uniStatsPanel.add(mainBox);
// Pannello dei componenti univariate statistics panel
JPanel componentsPanel = new JPanel(new BorderLayout(0, 5));
// Aggiuna label descrizione
componentsPanel.add(new JLabel(UNIV_DESCRITPION), BorderLayout.NORTH);
componentsPanel.add(transfGraphCreate(), BorderLayout.SOUTH);
componentsPanel.add(getScrollPaneTable(), BorderLayout.CENTER);
// Aggiuna pannello dei componenti al tabbed pane univariate
centralBox.add(componentsPanel);
}
/**
* Sets up bivariate statistics panel
*/
private void createBivariate() {
Box mainBox = Box.createVerticalBox();
Box centralBox = Box.createVerticalBox();
mainBox.add(Box.createVerticalStrut(10));
mainBox.add(centralBox);
mainBox.add(Box.createVerticalStrut(10));
bivStatsPanel.add(mainBox);
JPanel mainPanel = new JPanel(new BorderLayout(0, 20));
centralBox.add(mainPanel);
mainPanel.add(new JLabel(BIVARIATE_DESCRIPTION), BorderLayout.NORTH);
tableBivariate = new JWatBivariateStatsTable();
modelBivariate = new JWatBivariateStatsTableModel(model.getMatrix());
tableBivariate.setModel(modelBivariate);
panelBiv = new ScrollBivariatePanel(tableBivariate);
mainPanel.add(panelBiv, BorderLayout.CENTER);
}
//UPDATE DB 20/10/2006
protected AbstractAction EXECUTE_SAMPLING = new AbstractAction("Do Sampling"){
public void actionPerformed(ActionEvent e) {
if(model.getListOfClustering().size() > 0){
if(JOptionPane.showConfirmDialog(StatsPanel.this,"If you apply this sampling all clustering will be deleted. Do you want to continue?","Warning",JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
model.removeAllClustering();
}else{
return ;
}
}
int varSel = varsList.getSelectedIndex();
int sampSel = samplingList.getSelectedIndex();
switch(sampSel){
/** TRIMMING **/
case 0:
isSampled = true;
int percentile = ((Integer)quantile.getValue()).intValue();
if(!between.isSelected()){
model.doSamplingOnVariable(varSel,new TrimmingFilter(model.getMatrix().getVariables()[varSel].getUniStats().getQuantili()[percentile-1],up.isSelected()));
}else{
model.doSamplingOnVariable(varSel,new TrimmingBetweenFilter(
model.getMatrix().getVariables()[varSel].getUniStats().getQuantili()[percentile-1],
model.getMatrix().getVariables()[varSel].getUniStats().getQuantili()[((Integer)quantileB.getValue()).intValue()-1]));
}
undoSam.setEnabled(true);
break;
case 1:
isSampled = true;
int nObs = ((Integer)random.getValue()).intValue();
model.doSamplingOnVariable(0,new RandomFilter(model.getMatrix().getVariables()[0].Size(),nObs));
undoSam.setEnabled(true);
break;
case 2:
isSampled = true;
int min = ((Integer)fromO.getValue()).intValue();
int max = ((Integer)toO.getValue()).intValue();
model.doSamplingOnVariable(0,new IntervalFilter(min,max));
undoSam.setEnabled(true);
break;
case 3:
isSampled = true;
switch(model.getMatrix().getVariables()[varsList.getSelectedIndex()].getType()){
case STRING:
model.doSamplingOnVariable(varsList.getSelectedIndex(),
new FilterOnString(varsList.getSelectedIndex(),
((VariableString)model.getMatrix().getVariables()[varsList.getSelectedIndex()]).getListOfMatching(subs.getText())
));
undoSam.setEnabled(true);
break;
case NUMERIC:
model.doSamplingOnVariable(varsList.getSelectedIndex(),new FilterOnNumeric(((Double)minN.getValue()).doubleValue(),((Double)maxN.getValue()).doubleValue(),varsList.getSelectedIndex()));
undoSam.setEnabled(true);
break;
case DATE:
model.doSamplingOnVariable(varsList.getSelectedIndex(),new FilterOnData(((Date)fromD.getValue()),((Date)toD.getValue()),varsList.getSelectedIndex()));
undoSam.setEnabled(true);
break;
}
break;
}
}
};
protected AbstractAction UNDO_SAMPLING = new AbstractAction("Undo Sampling"){
public void actionPerformed(ActionEvent e) {
if(model.getListOfClustering().size() >= 0){
if(JOptionPane.showConfirmDialog(StatsPanel.this.getParentWizard(),
"This operation will reset all clusterings done. Continue ?",
"WARNING",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
model.undoSamplingOnVariable(varsList.getSelectedIndex());
model.removeAllClustering();
undoSam.setEnabled(false);
isSampled = false;
}else{
return;
}
}
}
};
private JList varsList = null;
private JList samplingList = null;
private JPanel varInfo = new JPanel(new FlowLayout(FlowLayout.LEFT));
private JLabel varLabel = new JLabel();
private JPanel optpanel = new JPanel(new BorderLayout());
private JPanel options = new JPanel();
private String[] samplingNames = new String[] { "Trimming", "Random","Observ. # interval", "Interval" };
private JButton executeSam = new JButton(EXECUTE_SAMPLING);
private JButton undoSam = new JButton(UNDO_SAMPLING);
private JPanel south;
private JList getVariableList(){
if(varsList == null){
varsList = new JList();
varsList.setSelectionBackground(new Color(181,189,214));
varsList.setSelectionForeground(Color.BLACK);
varsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Font f = varsList.getFont();
varsList.setPreferredSize(new Dimension(160, 400));
varsList.setMaximumSize(new Dimension(160, 400));
varsList.setFont(new Font(f.getFontName(), f.getStyle(), f
.getSize() + 2));
varsList.setBorder(BorderFactory.createLoweredBevelBorder());
varsList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if(!e.getValueIsAdjusting() && model.getMatrix() != null){
int select = varsList.getSelectedIndex();
if(select >= 0){
switch(model.getMatrix().getVariables()[select].getType()){
case STRING:
varLabel.setText(HTML_START + HTML_FONT_NORM +
"This is a String variable and it has been transformed has " + model.getMatrix().getVariables()[select].getTrasfStr()
+ HTML_FONT_NOR_END + HTML_END);
varInfo.setBorder(new TitledBorder(new TitledBorder(
new EtchedBorder(EtchedBorder.LOWERED),model.getMatrix().getVariableNames()[select] +" information")));
break;
case NUMERIC:
varLabel.setText(HTML_START + HTML_FONT_NORM +
"This is a Numeric variable and it has been transformed has " + model.getMatrix().getVariables()[select].getTrasfStr()
+ HTML_FONT_NOR_END + HTML_END);
varInfo.setBorder(new TitledBorder(new TitledBorder(
new EtchedBorder(EtchedBorder.LOWERED),model.getMatrix().getVariableNames()[select] +" information")));
break;
case DATE:
varLabel.setText(HTML_START + HTML_FONT_NORM +
"This is a Date variable and it has been transformed has " + model.getMatrix().getVariables()[select].getTrasfStr()
+ HTML_FONT_NOR_END + HTML_END);
varInfo.setBorder(new TitledBorder(new TitledBorder(
new EtchedBorder(EtchedBorder.LOWERED), model.getMatrix().getVariableNames()[select] +" information")));
break;
default:
}
//Abilitazione pulsanti di sampling e undo
executeSam.setEnabled(true);
//if(model.getMatrix().getVariables()[select].isSampled())
if(isSampled)
undoSam.setEnabled(true);
else
undoSam.setEnabled(false);
//Controllo su sampling selezionato
if(samplingList.getSelectedIndex() == 3){
samplingList.clearSelection();
samplingList.setSelectedIndex(3);
}
}else{
varsList.setSelectedIndex(0);
/*varLabel.setText(HTML_START + HTML_FONT_NORM +
"No variable selected"
+ HTML_FONT_NOR_END + HTML_END);
varInfo.setBorder(new TitledBorder(new TitledBorder(
new EtchedBorder(EtchedBorder.LOWERED), "No variable selected")));
//DisAbilitazione pulsanti di sampling e undo
executeSam.setEnabled(false);
undoSam.setEnabled(false);
//Controllo su sampling selezionato
if(samplingList.getSelectedIndex() == 3){
samplingList.clearSelection();
samplingList.setSelectedIndex(3);
}*/
}
}
}
});
}
return varsList;
}
private JList getSamplingList(){
if(samplingList == null){
samplingList = new JList(samplingNames);
samplingList.setSelectionBackground(new Color(181,189,214));
samplingList.setSelectionForeground(Color.BLACK);
samplingList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
samplingList.setPreferredSize(new Dimension(160, 400));
Font f = samplingList.getFont();
samplingList.setFont(new Font(f.getFontName(), f.getStyle(), f
.getSize() + 2));
samplingList.setBorder(BorderFactory.createLoweredBevelBorder());
samplingList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if(!e.getValueIsAdjusting() && model.getMatrix() != null){
int index = ((JList) e.getSource()).getSelectedIndex();
switch (index) {
case 0:
sampleDescr.setText(SAMPLING_TRIMMING_DESCRITPION);
optpanel.remove(options);
south.setVisible(true);
options = getTrimmingPanel();
optpanel.add(options,BorderLayout.CENTER);
optpanel.revalidate();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -