📄 splitstatsdlg.java
字号:
// SplitStats.java// Copyright (c) 1998, Regents of the University of California// $Id: SplitStatsDlg.java,v 1.2 1999/06/27 00:17:35 marcel Exp $import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.lang.Math;/* * SplitStats: * Dialog box that displays amdb_splitstats */class SplitStatsDlg extends JDialog{SplitStats splitStats = new SplitStats(); // amdb_splitstats of current leaf (or avg)TreeView treeView; // what displays the statsint[] splitLeaves; // numbers of split leaves, displayed in dialogint splitLeavesIdx; // index into splitLeaves: currently selected leafButtonGroup selectorGroup;JRadioButton avgBtn;JRadioButton leafBtn;JTextField leafFld;JButton plusBtn;JButton minusBtn;JComboBox statsTypeBox;ButtonGroup absGroup, weightedGroup;JRadioButton absBtn, deltaBtn;JRadioButton fullBtn, weightedBtn;JLabel clusteringLbl, excCovLbl;JLabel preSplitLbl, optSplitLbl, actualSplitLbl;JLabel lossLbl, ohLbl, successLbl;JTextField preClustFld, preEcFld; // Ec: excess coverageJTextField optClustFld, optEcFld;JTextField actualClustFld, actualEcFld;JTextField excCovLossFld, clustLossFld;JTextField clustOhFld, excCovOhFld;JTextField clustSuccessFld, excCovSuccessFld;publicSplitStatsDlg(JFrame parent){ super(parent, "Split Statistics", false); Font defaultFont = new Font("Dialog", Font.PLAIN, 12); Insets defaultInsets = new Insets(0, 0, 0, 0); getContentPane().setLayout(null); // some positioning variables/constants int leftMargin = 15; int yPos = 10; // used for relative positioning // Totals/Query radio buttons avgBtn = new JRadioButton("Average"); avgBtn.setFont(defaultFont); avgBtn.setBounds(leftMargin - 5, yPos, 60, 20); avgBtn.setActionCommand("avg"); avgBtn.setSelected(true); avgBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { setLeaf(0); } }); getContentPane().add(avgBtn); leafBtn = new JRadioButton("Leaf:"); leafBtn.setFont(defaultFont); leafBtn.setBounds(75, yPos, 60, 20); leafBtn.setActionCommand("leaf"); leafBtn.setSelected(false); leafBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { // XXX look for that leaf number in array int leafNo = Integer.parseInt(leafFld.getText()); if (leafNo < 1) { leafNo = 1; } setLeaf(leafNo); } catch (NumberFormatException e) { setLeaf(1); // user fucked up -> reset to query 1 } } }); getContentPane().add(leafBtn); selectorGroup = new ButtonGroup(); selectorGroup.add(avgBtn); selectorGroup.add(leafBtn); plusBtn = new JButton("+"); plusBtn.setFont(defaultFont); plusBtn.setBounds(230, 5, 45, 15); plusBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent action) { if (!selectorGroup.getSelection().getActionCommand().equals("leaf")) { return; } if (splitLeaves[splitLeavesIdx+1] != 0) { // next entry in splitLeaves is valid splitLeavesIdx++; } setLeaf(splitLeaves[splitLeavesIdx]); } }); getContentPane().add(plusBtn); minusBtn = new JButton("-"); minusBtn.setFont(defaultFont); minusBtn.setBounds(230,20,45,15); //minusBtn.setAlignmentY(Component.BOTTOM_ALIGNMENT); minusBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent action) { if (!selectorGroup.getSelection().getActionCommand().equals("leaf")) { return; } if (splitLeavesIdx > 1) { // next entry in splitLeaves is valid splitLeavesIdx--; } setLeaf(splitLeaves[splitLeavesIdx]); } }); getContentPane().add(minusBtn); leafFld = new JTextField("1", 5); leafFld.setFont(defaultFont); leafFld.setBounds(140, yPos, 84, 20); leafFld.setHorizontalAlignment(JTextField.RIGHT); leafFld.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { /* try { int leafNo = Integer.parseInt(leafFld.getText()); if (leafNo < 1) { leafNo = 1; } setLeaf(leafNo); } catch (NumberFormatException e) { setLeaf(1); // user fucked up -> reset to query 1 } */ } }); getContentPane().add(leafFld); yPos += 45; // display option panel JLabel displayLbl = new JLabel("Display: "); displayLbl.setFont(defaultFont); displayLbl.setBounds(leftMargin, yPos, 60, 15); getContentPane().add(displayLbl); statsTypeBox = new JComboBox(); statsTypeBox.setFont(defaultFont); statsTypeBox.setBounds(75, yPos, 175, 20); statsTypeBox.addItem("Cluster Loss"); statsTypeBox.addItem("Exc. Cov. Loss"); statsTypeBox.addItem("Cluster Success"); statsTypeBox.addItem("Exc. Cov. Success"); statsTypeBox.addItem("Opt. Cluster Delta"); statsTypeBox.addItem("Actual Cluster Delta"); statsTypeBox.addItem("Exc. Cov. Delta"); statsTypeBox.setEditable(false); statsTypeBox.setSelectedIndex(0); statsTypeBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different type of stats: update display setLeaf(); } }); getContentPane().add(statsTypeBox); yPos += 35; JLabel valuesLbl = new JLabel("I/O Values:"); valuesLbl.setFont(defaultFont); valuesLbl.setBounds(leftMargin, yPos, 100, 20); getContentPane().add(valuesLbl); absBtn = new JRadioButton("Absolute"); absBtn.setFont(defaultFont); absBtn.setBounds(140, yPos, 150, 25); absBtn.setSelected(true); absBtn.setActionCommand("abs"); absBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setLeaf(); } }); getContentPane().add(absBtn); fullBtn = new JRadioButton("Full"); fullBtn.setFont(defaultFont); fullBtn.setBounds(230, yPos, 150, 25); fullBtn.setSelected(false); fullBtn.setActionCommand("full"); fullBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setLeaf(); } }); getContentPane().add(fullBtn); yPos += 20; deltaBtn = new JRadioButton("Deltas"); deltaBtn.setFont(defaultFont); deltaBtn.setBounds(140, yPos, 145, 25); deltaBtn.setSelected(false); deltaBtn.setActionCommand("delta"); deltaBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setLeaf(); } }); getContentPane().add(deltaBtn); weightedBtn = new JRadioButton("Weighted"); weightedBtn.setFont(defaultFont); weightedBtn.setBounds(230, yPos, 145, 25); weightedBtn.setSelected(true); weightedBtn.setActionCommand("weighted"); weightedBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setLeaf(); } }); getContentPane().add(weightedBtn); absGroup = new ButtonGroup(); absGroup.add(absBtn); absGroup.add(deltaBtn); weightedGroup = new ButtonGroup(); weightedGroup.add(fullBtn); weightedGroup.add(weightedBtn); yPos += 40; clusteringLbl = new JLabel(); clusteringLbl.setText("Clustering"); clusteringLbl.setBounds(160, yPos, 32, 20); getContentPane().add(clusteringLbl); excCovLbl = new JLabel(); excCovLbl.setText("Exc. Cov."); excCovLbl.setBounds(255, yPos, 60, 20); getContentPane().add(excCovLbl); yPos += 25; preSplitLbl = new JLabel(); preSplitLbl.setText("Pre-Split:"); preSplitLbl.setBounds(leftMargin, yPos, 100, 20); getContentPane().add(preSplitLbl); preClustFld = new JTextField(); preClustFld.setMargin(defaultInsets); preClustFld.setHorizontalAlignment(SwingConstants.RIGHT); preClustFld.setEditable(false); preClustFld.setBounds(120, yPos, 105, 20); preClustFld.setBackground(Color.white); preClustFld.setFont(defaultFont);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -