📄 statspanel.java
字号:
break;
}
mainTransf.revalidate();
mainTransf.repaint();
}else{
if(model.getMatrix() != null)variableTable.setRowSelectionInterval(0,0);
}
}
});
}
return variableTable;
}
private JWatUnivariateStatsTableModel getModel() {
if (variableModel == null) {
variableModel = new JWatUnivariateStatsTableModel(model.getMatrix());
}
return variableModel;
}
/** ************Pannelli per univariate FINE***************************** */
public String getName() {
return "Statistics";
}
public void gotFocus() {
((JWatWizard)getParentWizard()).setEnableButton("Solve",false);
}
private SmallPlotDistGraph plo;
private DispMatrix dispPanel;
// Update 19-20/10/2006
private JPanel TrimmingPanelOption = null;
private JPanel RandomPanelOption = null;
private JPanel IntervalPanelOption = null;
private JPanel FilteringPanelOption = null;
private JSpinner quantile = null;
private JSpinner quantileB = null;
private JSpinner random = null;
private JSpinner fromO = null;
private JSpinner toO = null;
private JRadioButton up = null;
private JRadioButton down = null;
private JRadioButton between = null;
private JPanel getTrimmingPanel(){
if(TrimmingPanelOption == null){
TrimmingPanelOption = new JPanel(new BorderLayout());
JPanel center = new JPanel(new BorderLayout());
JPanel centerP = new JPanel(new BorderLayout());
JPanel centerCenter = new JPanel(new FlowLayout(FlowLayout.LEFT));
centerCenter.add(new JLabel(" Percentile: "));
quantile = new JSpinner(new SpinnerNumberModel(5,1,99,1)){
public void setValue(Object o){
super.setValue(o);
if(((Integer)quantile.getValue()).intValue() >= ((Integer)quantileB.getValue()).intValue()){
quantileB.setValue(new Integer(((Integer)quantile.getValue()).intValue()+1));
}
}
};
quantile.setPreferredSize(new Dimension(60,20));
centerCenter.add(quantile);
//UPDATE 10/11/06
between = new JRadioButton("Perc.< x < Perc.");
between.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent arg0) {
if(between.isSelected())
quantileB.setEnabled(true);
else
quantileB.setEnabled(false);
}
});
JPanel c = new JPanel(new FlowLayout(FlowLayout.LEFT));
quantileB = new JSpinner(new SpinnerNumberModel(5,2,99,1)){
public void setValue(Object o){
super.setValue(o);
if(((Integer)quantileB.getValue()).intValue() <= ((Integer)quantile.getValue()).intValue()){
quantile.setValue(new Integer(((Integer)quantileB.getValue()).intValue()-1));
}
}
};
quantileB.setPreferredSize(new Dimension(60,20));
c.add(new JLabel(" Percentile: "));
c.add(quantileB);
quantileB.setEnabled(false);
JPanel p = new JPanel(new GridLayout(2,1));
p.add(centerCenter);
p.add(c);
centerP.add(p,BorderLayout.CENTER);
//UPDATE 10/11/06
//centerP.add(centerCenter,BorderLayout.CENTER);
ButtonGroup opt = new ButtonGroup();
up = new JRadioButton(" x > Percentile");
down = new JRadioButton(" x < Percentile");
down.setSelected(true);
opt.add(down);
opt.add(up);
opt.add(between);
JPanel optionP = new JPanel(new GridLayout(3,1));
optionP.add(down);
optionP.add(up);
optionP.add(between);
centerP.add(optionP,BorderLayout.SOUTH);
center.add(centerP,BorderLayout.NORTH);
TrimmingPanelOption.add(center,BorderLayout.CENTER);
}
if(varsList.getSelectedIndex() == -1){
executeSam.setEnabled(false);
undoSam.setEnabled(false);
}
return TrimmingPanelOption;
}
private JPanel getRandomPanelOption(){
if(RandomPanelOption == null){
RandomPanelOption = new JPanel(new BorderLayout());
JPanel center = new JPanel(new BorderLayout());
JPanel centerCenter = new JPanel(new FlowLayout(FlowLayout.LEFT));
centerCenter.add(new JLabel("Number of random obs.: "));
random = new JSpinner(new SpinnerNumberModel(1,1,model.getMatrix().getVariables()[0].Size(),1));
random.setPreferredSize(new Dimension(60,25));
centerCenter.add(random);
center.add(centerCenter,BorderLayout.CENTER);
RandomPanelOption.add(center,BorderLayout.CENTER);
}
if(varsList.getSelectedIndex() == -1){
executeSam.setEnabled(false);
undoSam.setEnabled(false);
}
return RandomPanelOption;
}
private JPanel getIntervalPanelOption(){
if(IntervalPanelOption == null){
IntervalPanelOption = new JPanel(new BorderLayout());
JPanel center = new JPanel(new BorderLayout());
JPanel centerP = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel lbl = new JLabel("From obs. number: ");
lbl.setPreferredSize(new Dimension(100,25));
centerP.add(lbl);
fromO = new JSpinner(new SpinnerNumberModel(1,1,model.getMatrix().getVariables()[0].Size() - 1,1)){
public void setValue(Object o){
super.setValue(o);
if(((Integer)fromO.getValue()).intValue() >= ((Integer)toO.getValue()).intValue()){
toO.setValue(new Integer(((Integer)fromO.getValue()).intValue()+1));
}
}
};
fromO.setPreferredSize(new Dimension(70,25));
centerP.add(fromO);
JLabel lbl2 = new JLabel("To obs. number: ");
lbl2.setPreferredSize(new Dimension(100,25));
centerP.add(lbl2);
toO = new JSpinner(new SpinnerNumberModel(2,2,model.getMatrix().getVariables()[0].Size(),1)){
public void setValue(Object o){
super.setValue(o);
if(((Integer)toO.getValue()).intValue() <= ((Integer)fromO.getValue()).intValue()){
fromO.setValue(new Integer(((Integer)toO.getValue()).intValue()-1));
}
}
};
toO.setPreferredSize(new Dimension(70,25));
centerP.add(toO);
center.add(centerP);
IntervalPanelOption.add(center,BorderLayout.CENTER);
}
if(varsList.getSelectedIndex() == -1){
executeSam.setEnabled(false);
undoSam.setEnabled(false);
}
return IntervalPanelOption;
}
private JPanel filterS,filterD,filterN;
private JTextField subs;
private JSpinner minN,maxN;
//private CalendarComboBox fromD,toD;
private JFormattedTextField fromD,toD;
private JPanel getFilteringPanelOption(){
if(FilteringPanelOption == null){
FilteringPanelOption = new JPanel(new BorderLayout());
//Pannello filtering on String
filterS = new JPanel(new FlowLayout());
JLabel l = new JLabel("Substring to be matched");
subs = new JTextField();
subs.setPreferredSize(new Dimension(120,25));
filterS.add(l);
filterS.add(subs);
//Pannello filtering on Data
filterD = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel lfrom = new JLabel("From date: ");
lfrom.setPreferredSize(new Dimension(60,25));
fromD = new JFormattedTextField(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"));
JLabel lto = new JLabel("To date: ");
lto.setPreferredSize(new Dimension(60,25));
toD = new JFormattedTextField(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"));
filterD.add(lfrom);
filterD.add(fromD);
filterD.add(lto);
filterD.add(toD);
//Pannello di filtering on Numeric
filterN = new JPanel(new FlowLayout(FlowLayout.LEFT));
minN = new JSpinner(new SpinnerNumberModel(0.0,0.0,0.0,1)){
public void setValue(Object o){
super.setValue(o);
if(((Double)minN.getValue()).doubleValue() >= ((Double)maxN.getValue()).doubleValue()){
maxN.setValue(new Double(((Double)minN.getValue()).doubleValue()+1));
}
}
};
maxN = new JSpinner(new SpinnerNumberModel(0.0,0.0,0.0,1)){
public void setValue(Object o){
super.setValue(o);
if(((Double)maxN.getValue()).doubleValue() <= ((Double)minN.getValue()).doubleValue()){
minN.setValue(new Double(((Double)maxN.getValue()).doubleValue()-1));
}
}
};
JLabel min = new JLabel("Minimum value: ");
min.setPreferredSize(new Dimension(90,25));
minN.setMaximumSize(new Dimension(600,25));
filterN.add(min);
filterN.add(minN);
JLabel max = new JLabel("Maximum value: ");
max.setPreferredSize(new Dimension(90,25));
maxN.setMaximumSize(new Dimension(600,25));
filterN.add(max);
filterN.add(maxN);
}
//In base al tipo di variabile visualizzo il pannello
if(varsList.getSelectedIndex() == -1){
executeSam.setEnabled(false);
undoSam.setEnabled(false);
FilteringPanelOption.removeAll();
FilteringPanelOption.revalidate();
FilteringPanelOption.repaint();
}else{
FilteringPanelOption.removeAll();
switch(model.getMatrix().getVariables()[varsList.getSelectedIndex()].getType()){
case STRING: FilteringPanelOption.add(filterS,BorderLayout.CENTER);
break;
case DATE: FilteringPanelOption.add(filterD,BorderLayout.CENTER);
fromD.setValue(new Date((long)model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMinValue()));
toD.setValue(new Date((long)model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMaxValue()));
break;
case NUMERIC: FilteringPanelOption.add(filterN,BorderLayout.CENTER);
minN.setModel(new SpinnerNumberModel(
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMinValue(),
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMinValue(),
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMaxValue(),
1));
maxN.setModel(new SpinnerNumberModel(
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMaxValue(),
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMinValue(),
model.getMatrix().getVariables()[varsList.getSelectedIndex()].getUniStats().getMaxValue(),
1));
break;
}
FilteringPanelOption.revalidate();
FilteringPanelOption.repaint();
}
return FilteringPanelOption;
}
private static final String helpText =
"<HTML>" +
" This panel shows univariate and bivariate statistics, allow numeric variable transformations and<p>sampling operations.<br>" +
"<UL><LI>In Univariate panel select a variable in table, apply transformations and see QQ-Plot or<p>frequencies graphs.</LI>" +
"<LI>In Sampling panel select a sampling method and apply it (interval, trimming and random).</LI>" +
"<LI>Bivariate panel shows correlation coefficient.</LI>" +
"<LI>QQ-plot and scatter matrix panels shows every variable vs. variable graphs and can be<p>enlarged with double click.</LI></html>";
public void help() {
JOptionPane.showMessageDialog(this, helpText, "Help", JOptionPane.INFORMATION_MESSAGE);
}
public void lostFocus(){
parent.setLastPanel(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -