📄 wkldstatsdlg.java
字号:
// WkldStatsDlg.java// Copyright (c) 1998, Regents of the University of California// $Id: WkldStatsDlg.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;/* * WkldStatsDlg: * Dialog box that displays amdb_wkldprofile and amdb_wkldstats data. */class WkldStatsDlg extends JDialog{QueryStats queryStats; // amdb_profile::QueryStats of current queryAnalysisInfo analysisInfo; // global parameters and state of analysisTreeView treeView; // what displays the statsButtonGroup selectorGroup;JRadioButton avgBtn;JRadioButton queryBtn;JTextField queryFld;JButton plusBtn;JButton minusBtn;JScrollPane queryPane;JTextArea queryArea;JComboBox statsTypeBox;ButtonGroup baseGroup;JRadioButton minBtn;JRadioButton optBtn;// Parameters tabJTextField numQueriesFld;JTextField dataCovFld;JTextField runsFld;JRadioButton retrOnlyBtn;JRadioButton allDataBtn;JTextField utilFld;// Leaves tabJPanel leafPanel;JLabel iosLbl, ohLbl;JLabel minLbl, leafTotalLbl, optClustLbl, randClustLbl;JLabel leafClLbl, leafUlLbl, leafElLbl;JTextField minIoFld, minOhFld;JTextField optClustIoFld, optClustOhFld;JTextField randClustIoFld, randClustOhFld;JTextField leafClOhFld, leafClIoFld;JTextField leafUlIoFld, leafUlOhFld;JTextField leafElIoFld, leafElOhFld;JTextField leafTotalIoFld, leafTotalOhFld;JLabel leafUtilLbl;JTextField leafUtilFld;JLabel itemsRetrLbl;JTextField itemsRetrFld;// internal/totals tabJPanel internalPanel;JLabel intLbl, totalsLbl;JLabel clustLossLbl, utilLossLbl, excCovLossLbl, totalLbl;JTextField intClFld, totalClFld;JTextField intUlFld, totalUlFld;JTextField intElFld, totalElFld;JTextField intTotalFld, totalTotalFld;publicWkldStatsDlg(JFrame parent){ super(parent, "Workload Statistics", false); queryStats = new QueryStats(); analysisInfo = new AnalysisInfo(); Font defaultFont = new Font("Dialog", Font.PLAIN, 12); Insets defaultInsets = new Insets(0, 0, 0, 0); getContentPane().setLayout(null); // Totals/Query radio buttons avgBtn = new JRadioButton("Average:"); avgBtn.setFont(defaultFont); avgBtn.setBounds(10, 10, 60, 20); avgBtn.setActionCommand("avg"); avgBtn.setSelected(true); avgBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { setQuery(0); } }); getContentPane().add(avgBtn); queryBtn = new JRadioButton("Query:"); queryBtn.setFont(defaultFont); queryBtn.setBounds(75, 10, 60, 20); queryBtn.setActionCommand("query"); queryBtn.setSelected(false); queryBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { int queryNo = Integer.parseInt(queryFld.getText()); if (!(queryNo >= 1 && queryNo <= analysisInfo.numQueries)) { queryNo = 1; } setQuery(queryNo); } catch (NumberFormatException e) { setQuery(1); // user fucked up -> reset to query 1 } } }); getContentPane().add(queryBtn); selectorGroup = new ButtonGroup(); selectorGroup.add(avgBtn); selectorGroup.add(queryBtn); plusBtn = new JButton("+"); plusBtn.setFont(defaultFont); plusBtn.setBounds(230, 5, 45, 15); //plusBtn.setAlignmentY(Component.BOTTOM_ALIGNMENT); plusBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent action) { try { int queryNo = Integer.parseInt(queryFld.getText()); if (queryNo < analysisInfo.numQueries) { setQuery(queryNo+1); } } catch (NumberFormatException e) { // something went wrong, ignore this } } }); //selectorBox.add(plusBtn); 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) { try { int queryNo = Integer.parseInt(queryFld.getText()); if (queryNo > 1) { setQuery(queryNo-1); } } catch (NumberFormatException e) { // something went wrong, ignore this } } }); //selectorBox.add(minusBtn); getContentPane().add(minusBtn); queryFld = new JTextField("1", 5); queryFld.setFont(defaultFont); queryFld.setBounds(140,10,84,20); //queryFld.setAlignmentY(Component.BOTTOM_ALIGNMENT); queryFld.setHorizontalAlignment(JTextField.RIGHT); queryFld.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { int queryNo = Integer.parseInt(queryFld.getText()); if (!(queryNo >= 1 && queryNo <= analysisInfo.numQueries)) { queryNo = 1; } setQuery(queryNo); } catch (NumberFormatException e) { setQuery(1); // user fucked up -> reset to query 1 } } }); //selectorBox.add(queryFld); //selectorBox.add(Box.createHorizontalGlue()); getContentPane().add(queryFld); queryPane = new JScrollPane(); queryPane.setOpaque(true); queryPane.setBounds(140,40,200,70); queryPane.setFont(defaultFont); getContentPane().add(queryPane); queryArea = new JTextArea(); queryArea.setMargin(defaultInsets); queryArea.setBounds(0,0,200,70); queryArea.setFont(defaultFont); queryPane.getViewport().add(queryArea); //selectorBox.add(Box.createHorizontalGlue()); //box.add(selectorBox); // display option panel //Box displayBox = new Box(BoxLayout.X_AXIS); //displayBox.setAlignmentX(Component.LEFT_ALIGNMENT); JLabel displayLbl = new JLabel("Display: "); displayLbl.setFont(defaultFont); displayLbl.setBounds(15, 125, 60, 15); getContentPane().add(displayLbl); statsTypeBox = new JComboBox(); statsTypeBox.setFont(defaultFont); statsTypeBox.setBounds(75,125,175,20); //statsTypeBox.setAlignmentY(Component.BOTTOM_ALIGNMENT); statsTypeBox.addItem("Traversals"); statsTypeBox.addItem("Retrievals"); statsTypeBox.addItem("Empty Subtrees"); statsTypeBox.addItem("Cluster Loss"); statsTypeBox.addItem("Cluster O/H"); statsTypeBox.addItem("Utilization Loss"); statsTypeBox.addItem("Utilization O/H"); statsTypeBox.addItem("Excess Coverage Loss"); statsTypeBox.addItem("Excess Coverage O/H"); statsTypeBox.addItem("Pruned Exc. Cov. Loss"); statsTypeBox.addItem("Pruned Exc. Cov. O/H"); statsTypeBox.setEditable(false); statsTypeBox.setSelectedIndex(0); statsTypeBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different type of stats: update display setQuery(); } }); //displayBox.add(statsTypeBox); getContentPane().add(statsTypeBox); JLabel baseLbl = new JLabel("Base of Metrics:"); baseLbl.setFont(defaultFont); baseLbl.setBounds(15,160,100,20); //baseLbl.setAlignmentY(Component.BOTTOM_ALIGNMENT); //displayBox.add(baseLbl); getContentPane().add(baseLbl); minBtn = new JRadioButton("Theoretical Minimum"); minBtn.setFont(defaultFont); minBtn.setBounds(140,160,150,25); minBtn.setSelected(false); minBtn.setActionCommand("min"); //minBtn.setAlignmentY(Component.BOTTOM_ALIGNMENT); minBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setQuery(); } }); getContentPane().add(minBtn); optBtn = new JRadioButton("Optimal Clustering"); optBtn.setFont(defaultFont); optBtn.setBounds(140,180,145,25); optBtn.setSelected(true); optBtn.setActionCommand("opt"); //optBtn.setAlignmentY(Component.BOTTOM_ALIGNMENT); optBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // switched to different base of stats: update display setQuery(); } }); getContentPane().add(optBtn); baseGroup = new ButtonGroup(); baseGroup.add(minBtn); baseGroup.add(optBtn); //displayBox.add(minBtn); //displayBox.add(optBtn); //displayBox.add(Box.createHorizontalGlue()); //box.add(Box.createVerticalStrut(2)); //box.add(displayBox); // tabbed display pane JTabbedPane tp = new JTabbedPane(); tp.setFont(defaultFont); //tp.setBounds(15, 180, 325, 200); tp.setBounds(15, 215, 365, 310); getContentPane().add(tp); ////////////////////////////////////////////////////////////// // parameters panel ////////////////////////////////////////////////////////////// JPanel parametersPanel = new JPanel(null); // set up some position constants final int lblX = 15; final int lblHeight = 15; final int fldX = 145; final int fldWidth = 135; final int fldHeight = 20; JLabel numQueriesLbl = new JLabel("Number of Queries:"); numQueriesLbl.setFont(defaultFont); numQueriesLbl.setBounds(lblX, 15, 110, lblHeight); parametersPanel.add(numQueriesLbl); numQueriesFld = new JTextField(5); numQueriesFld.setFont(defaultFont); numQueriesFld.setEditable(false); numQueriesFld.setMargin(defaultInsets); numQueriesFld.setBounds(fldX, 10, fldWidth, fldHeight); numQueriesFld.setHorizontalAlignment(SwingConstants.RIGHT); numQueriesFld.setBackground(Color.white); parametersPanel.add(numQueriesFld); JLabel dataCovLbl = new JLabel("Data Coverage:"); dataCovLbl.setFont(defaultFont); dataCovLbl.setBounds(lblX, 45, 95, lblHeight); parametersPanel.add(dataCovLbl); dataCovFld = new JTextField(5); dataCovFld.setFont(defaultFont); dataCovFld.setEditable(false); dataCovFld.setMargin(defaultInsets); dataCovFld.setBounds(fldX, 40, fldWidth, fldHeight); dataCovFld.setHorizontalAlignment(SwingConstants.RIGHT); dataCovFld.setBackground(Color.white); parametersPanel.add(dataCovFld); JLabel runsLbl = new JLabel("Random Runs:"); runsLbl.setFont(defaultFont); runsLbl.setBounds(lblX, 75, 85, lblHeight); parametersPanel.add(runsLbl); runsFld = new JTextField(5); runsFld.setFont(defaultFont); runsFld.setEditable(false); runsFld.setMargin(defaultInsets); runsFld.setBounds(fldX, 70, fldWidth, fldHeight); runsFld.setHorizontalAlignment(SwingConstants.RIGHT); runsFld.setBackground(Color.white); parametersPanel.add(runsFld); JLabel randDataLbl = new JLabel("Random Data:"); randDataLbl.setFont(defaultFont); randDataLbl.setBounds(lblX, 110, 85, lblHeight); parametersPanel.add(randDataLbl); retrOnlyBtn = new JRadioButton("Retrieved"); retrOnlyBtn.setFont(defaultFont); retrOnlyBtn.setBounds(fldX, 105, 80, 20); retrOnlyBtn.setActionCommand("retrieved"); parametersPanel.add(retrOnlyBtn); allDataBtn = new JRadioButton("All"); allDataBtn.setFont(defaultFont); allDataBtn.setBounds(fldX, 125, 80, 20); allDataBtn.setActionCommand("all"); parametersPanel.add(allDataBtn); ButtonGroup randDataGroup = new ButtonGroup(); randDataGroup.add(retrOnlyBtn); randDataGroup.add(allDataBtn); JLabel utilLbl = new JLabel("Target Utilization:"); utilLbl.setFont(defaultFont); utilLbl.setBounds(lblX, 160, 120, lblHeight); parametersPanel.add(utilLbl); utilFld = new JTextField(5); utilFld.setFont(defaultFont); utilFld.setEditable(false); utilFld.setMargin(defaultInsets); utilFld.setBounds(fldX, 155, fldWidth, fldHeight); utilFld.setHorizontalAlignment(SwingConstants.RIGHT); utilFld.setBackground(Color.white); parametersPanel.add(utilFld); tp.addTab("Parameters", parametersPanel); ////////////////////////////////////////////////////////////// // leaf-level panel ////////////////////////////////////////////////////////////// leafPanel = new JPanel(null); leafPanel.setFont(defaultFont); getContentPane().add(leafPanel); iosLbl = new JLabel(); iosLbl.setText("I/Os"); iosLbl.setBounds(160,75,32,20); leafPanel.add(iosLbl); ohLbl = new JLabel(); ohLbl.setText("Overhead"); ohLbl.setBounds(255,75,60,20); leafPanel.add(ohLbl); minIoFld = new JTextField(); minIoFld.setMargin(defaultInsets); minIoFld.setHorizontalAlignment(SwingConstants.RIGHT); minIoFld.setEditable(false); minIoFld.setBounds(120,100,105,20); minIoFld.setBackground(Color.white); minIoFld.setFont(defaultFont); leafPanel.add(minIoFld); minOhFld = new JTextField(); minOhFld.setMargin(defaultInsets); minOhFld.setHorizontalAlignment(SwingConstants.RIGHT); minOhFld.setEditable(false); minOhFld.setBounds(235,100,105,20); minOhFld.setBackground(Color.white); minOhFld.setFont(defaultFont); leafPanel.add(minOhFld); optClustOhFld = new JTextField(); optClustOhFld.setMargin(defaultInsets); optClustOhFld.setHorizontalAlignment(SwingConstants.RIGHT); optClustOhFld.setEditable(false); optClustOhFld.setBounds(235,125,105,20); optClustOhFld.setBackground(Color.white); optClustOhFld.setFont(defaultFont); leafPanel.add(optClustOhFld); optClustIoFld = new JTextField(); optClustIoFld.setMargin(defaultInsets); optClustIoFld.setHorizontalAlignment(SwingConstants.RIGHT); optClustIoFld.setEditable(false); optClustIoFld.setBounds(120,125,105,20); optClustIoFld.setBackground(Color.white); optClustIoFld.setFont(defaultFont); leafPanel.add(optClustIoFld); randClustIoFld = new JTextField(); randClustIoFld.setMargin(defaultInsets); randClustIoFld.setHorizontalAlignment(SwingConstants.RIGHT); randClustIoFld.setEditable(false); randClustIoFld.setBounds(120,150,105,20); randClustIoFld.setBackground(Color.white); randClustIoFld.setFont(defaultFont); leafPanel.add(randClustIoFld); randClustOhFld = new JTextField();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -