⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cattellapplet.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// $Id: CattellApplet.java,v 1.2 2003/04/11 14:47:39 per_nyfelt Exp $import java.awt.*;import java.awt.event.*;import java.applet.*;import java.io.*;import org.ozoneDB.tools.ChartCanvas;/** */public class CattellApplet extends Applet implements ActionListener, ItemListener {    /** */    class BenchmarkThread extends Thread {        private boolean chartOnly = true;        private String[] args = null;        /** */        public BenchmarkThread( boolean co, String[] a ) {            chartOnly = co;            args = a;        }        /** */        public void run() {        }    }    /** */    public class AppletWriter extends Writer {        /** */        public AppletWriter() {        }        /** */        public void write( char[] cbuf, int off, int len ) throws IOException {            String text = new String( cbuf, off, len );            if (outText != null) {                outText.append( text );            }            if (chart != null) {                int tpos = text.indexOf( "time: " );                if (tpos > -1) {                    tpos += 6;                    int mpos = text.indexOf( "ms", tpos );                    if (mpos > -1) {                        chart.appendTime( new Integer( text.substring( tpos, mpos ).trim() ).intValue() );                    }                }            }        }        /** */        public void flush() throws IOException {        }        /** */        public void close() throws IOException {        }    }    /** */    protected Button startButton;    protected Choice testChoice;    protected TextField sizeText;    protected TextField nameText;    protected TextField serverText;    protected TextArea outText;    protected Label statusLabel;    protected ChartCanvas chart;    /** */    public void init() {        init( false );    }    /** */    public void init( boolean chartOnly ) {        setLayout( new BorderLayout() );        if (!chartOnly) {            Panel panel = new Panel();            panel.setLayout( new FlowLayout( FlowLayout.LEFT ) );            startButton = new Button( " Start " );            startButton.setFont( new Font( "Monospaced", Font.BOLD, 14 ) );            startButton.addActionListener( this );            panel.add( startButton );            testChoice = new Choice();            testChoice.add( "Help" );            testChoice.add( "1 Create" );            testChoice.add( "2 Lookup" );            testChoice.add( "3 Traversal" );            testChoice.add( "4 Ins & del" );            testChoice.add( "5 Insert" );            testChoice.add( "6 Ins*1000" );            testChoice.add( "7 Traversal" );            testChoice.add( "8 Insert" );            testChoice.addItemListener( this );            panel.add( testChoice );            sizeText = new TextField( "1000", 5 );            sizeText.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) );            sizeText.addActionListener( this );            //panel.add (new QuickLabel ("Size: "));            panel.add( sizeText );            nameText = new TextField( "cattell", 9 );            nameText.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) );            nameText.addActionListener( this );            //panel.add (new QuickLabel ("Name: "));            panel.add( nameText );            serverText = new TextField( "localhost", 9 );            serverText.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) );            serverText.addActionListener( this );            //panel.add (new QuickLabel ("Server: "));            panel.add( serverText );            add( "North", panel );            panel = new Panel();            panel.setLayout( new BorderLayout() );            outText = new TextArea();            panel.add( outText, "North" );            chart = new ChartCanvas();            panel.add( chart, "Center" );            add( "Center", panel );            statusLabel = new Label( "Test:Build - Size:1000 - Name:cattell " );            add( "South", statusLabel );        } else {            chart = new ChartCanvas();            add( "Center", chart );        }    }    /** */    public void itemStateChanged( ItemEvent e ) {        String[] defaults = {"0", "1000", "100", "7", "100", "100", "10", "10", "10"};        if (testChoice.getSelectedIndex() > -1) {            sizeText.setText( defaults[testChoice.getSelectedIndex()] );        }    }    /** */    public void actionPerformed( ActionEvent e ) {        int test = testChoice.getSelectedIndex();        int size = Integer.valueOf( sizeText.getText() ).intValue();        String name = nameText.getText();        String server = serverText.getText();        statusLabel.setText( "Test:" + test + " Size:" + size + " Name:" + name );        String[] args = {"" + test, "" + size, "" + name, "" + server};        runBenchmark( args );    }    /** */    public void runBenchmark( String[] args ) {        CattellImpl.main( args );    }    /** */    static class MyAdapter extends WindowAdapter {        public void windowClosing( WindowEvent e ) {            System.exit( 0 );        }    }    /** */    public static void main( String[] args ) {        boolean chartOnly = false;        String[] cattellArgs = new String[0];        int argCount = 0;        if (args.length > 0) {            for (int i = 0; i < args.length; i++) {                if (args[i].equals( "-chart" )) {                    chartOnly = true;                    argCount++;                }            }        }        Frame f = new Frame( "Cattell Benchmark" );        CattellApplet applet = new CattellApplet();        applet.init( chartOnly );        applet.start();        f.add( "Center", applet );        f.pack();        f.setSize( chartOnly ? 300 : 500, chartOnly ? 120 : 400 );        f.show();        f.addWindowListener( new MyAdapter() );        cattellArgs = new String[args.length - argCount];        System.arraycopy( args, argCount, cattellArgs, 0, cattellArgs.length );        cattellArgs = applet.chart.filterAndApplyArgs( cattellArgs );        if (chartOnly) {            applet.runBenchmark( cattellArgs );        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -