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

📄 viewframechooser.java

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                view_btns[ 1 ].setEnabled( false );                view_btns[ 2 ].setEnabled( false );        }        switch ( view_idx ) {            case 0:                connect_btns[ 0 ].setEnabled( true );                connect_btns[ 1 ].setEnabled( true );                break;            case 1:                connect_btns[ 0 ].setEnabled( true );                connect_btns[ 1 ].setEnabled( true );                break;            case 2:                connect_btns[ 0 ].setEnabled( true );                connect_btns[ 1 ].setEnabled( false );                break;            default:                connect_btns[ 0 ].setEnabled( false );                connect_btns[ 1 ].setEnabled( false );        }    }    public void actionPerformed( ActionEvent event )    {        for ( int ii = 0; ii < Nconnect; ii++ )            if ( event.getSource() == connect_btns[ ii ] ) {                connect_idx = ii;                EnableFrameButtonsIdxFld();                EnableViewConnectivitySwitches();                return;            }        for ( int jj = 0; jj < Nview; jj++ )            if ( event.getSource() == view_btns[ jj ] ) {                view_idx = jj;                EnableFrameButtonsIdxFld();                EnableViewConnectivitySwitches();                return;            }        if ( event.getSource() == display_btn ) {            debug.println( "Frame Index = " + frame_idx + ",  "                         + "View Action Index = " + view_idx + ",  "                         + "Connect Action Index = " + connect_idx );            UpdateGraphTimeMarker();            ReadLogFrame();            // DisplayFrame();            return;        }        if ( event.getSource() == prev_btn ) {            frame_idx--;            frame_idx_fld.setText( Integer.toString( frame_idx ) );            UpdateGraphTimeMarker();            return;        }        if ( event.getSource() == next_btn ) {            frame_idx++;            frame_idx_fld.setText( Integer.toString( frame_idx ) );            UpdateGraphTimeMarker();            return;        }/*        if ( event.getSource() == close_btn ) {            init_win.enableRead();            init_win.slog.Close();            init_win.slog = null;            init_win.frame_chooser = null;            free();            setVisible( false );            dispose();            // else            //    new ErrorDialog( this, "The child Frame Display still exists" );        }*/    }/*    public void ReadLogFrame()    {        SLOG_DirEntry    dir_entry = null;        if ( frame_idx >= 0 ) {            display_btn.setEnabled( false );            SLOG_DirEntry dir_entry = slog.GetDir().EntryAt( frame_idx );            try { slog_frame = slog.GetFrame( dir_entry.fptr2framehdr ); }            catch ( IOException ioerr )                { System.err.println( "ReadLogFrame() has IO error" ); }            debug.println( "slog_dir_entry = " + dir_entry );            slog_plotdata = new PlotData( slog, slog_frame,                                          connect_idx, view_idx );            display_btn.setEnabled( true );        }    }*/    private void ReadLogFrame()    {        final ViewFrameChooser frame_chooser = this;        if ( frame_idx >= 0 ) {            task = new FrameReadingTask( this,                                         slog, frame_idx,                                         connect_idx, view_idx );            timer = new Timer( 100, new RefreshTimerListener() );            // timer.setRepeats( true );            timer.setInitialDelay( 0 );            timer.setCoalesce( true );            // progress_mntr = new ProgressMonitor( this,            progress_mntr =  new ProgressDialog( this,                                                 "Reading from the logfile",                                                 "Reading Frame ",                                                 task.GetMinProgIdx(),                                                 task.GetMaxProgIdx() );            progress_mntr.setMillisToDecideToPopup( 0 );            progress_mntr.setMillisToPopup( 0 );            progress_mntr.setNote( task.GetMessage() );            progress_mntr.setProgress( task.GetMinProgIdx() );            waitCursor();            display_btn.setEnabled( false );            task.Start();            timer.start();            /*            if ( timer.isRunning() )                System.out.println( "Timer is running" );            else                System.out.println( "Timer is NOT running" );            */        }        else            new ErrorDialog( this, "ViewFrameChooser.ReadLogFrame(): "                                 + "Invalid Frame Index = " + frame_idx + "\n"                                 + "Select another frame index"  );    }    class RefreshTimerListener implements ActionListener    {        private int   itick              = 0;        private int   min_prog_idx       = task.GetMinProgIdx();        private int   max_prog_idx       = task.GetMaxProgIdx();        private int   duration_prog      = max_prog_idx - min_prog_idx;        private int   ten_percent_prog   = duration_prog / 10;        private int   cur_prog_idx       = min_prog_idx;        private int   task_prog_idx      = min_prog_idx;        private long  ten_percent_msec   = 0;        private long  unit_msec          = 0;        private long  start_msec         = ( new Date() ).getTime();        private long  elapsed_msec;        public void actionPerformed( ActionEvent evt )        {            itick++;            if ( progress_mntr.isCanceled() || task.Finished() ) {                progress_mntr.close();                task.Stop();                Toolkit.getDefaultToolkit().beep();                timer.stop();                display_btn.setEnabled( true );            }            else {                progress_mntr.setNote( task.GetMessage() );                //  A complication algorithm to estimate the progress                //  Assume 1 itick corresponds to 10% progress,                //  Then use this to set a 10% real time progress benchmark.                //  Or when the task.GetCurProgIdx() return non-zero value                //  which will be used to benchmark the progress.                elapsed_msec = ( new Date() ).getTime() - start_msec;                task_prog_idx = task.GetCurProgIdx();                if ( itick > 0 ) {                    if ( task_prog_idx == min_prog_idx ) {                        if ( ten_percent_msec == 0 )                            ten_percent_msec = elapsed_msec / itick;                        cur_prog_idx = (int) ( elapsed_msec                                               / ten_percent_msec )                                               * ten_percent_prog;                    }                    else {                        if ( unit_msec == 0 )                            unit_msec = elapsed_msec / task_prog_idx ;                        cur_prog_idx = (int) ( elapsed_msec / unit_msec );                    }                }                else                     cur_prog_idx = task_prog_idx;                progress_mntr.setProgress( cur_prog_idx % duration_prog );            }            progress_mntr.setNote( "elapsed_time = " + elapsed_msec + " msec" );            /*            System.out.println( "RefreshTimerListener: "                              + "task.GetCurProgIdx() = "                              + itick + ", " + task_prog_idx + ", "                              + cur_prog_idx + ", " + elapsed_msec );            */        }    }    public void DisplayFrame()    {        slog_plotdata = task.GetPlotData();        if ( slog_plotdata != null ) {            display_btn.setEnabled( false );            waitCursor();            StringBuffer title_str = new StringBuffer();                title_str.append( connect_names[ connect_idx ] + " in " );                title_str.append( view_names[ view_idx ] + " view " );                title_str.append( "at frame index = " + frame_idx );            SLOG_DirEntry slog_dir_entry = slog.GetDir().EntryAt( frame_idx );            frame_display = new FrameDisplay( init_win, this, slog_plotdata,                                              slog_dir_entry.starttime,                                              slog_dir_entry.endtime,                                              title_str.toString() );            normalCursor();            /*            frame_display.addWindowListener( new WindowAdapter()                {                    public void windowClosing( WindowEvent e )                    {                         display_btn.setEnabled( true );                        SetFrameButtonsEnabled( frame_idx_fld.getText() );                    };                }                                           );            */        }        else {            new ErrorDialog( this, "ViewFrameChooser.DisplayFrame(): "                                 + "task.GetPlotData() returns NULL.\n"                                 + "Select other connectivity and view "                                 + "options to see if other combination "                                 + "is viewable." );            normalCursor();        }    }    private void free()    {        for ( int ii = 0; ii < Nconnect; ii++ )            connect_btns[ ii ] = null;        for ( int ii = 0; ii < Nview; ii++ ) {            view_btns[ ii ] = null;            view_names[ ii ] = null;        }        frame_idx_tag  = null;        frame_idx_fld  = null;        prev_btn       = null;        display_btn    = null;        next_btn       = null;        slog           = null;        slog_frame     = null;        slog_plotdata  = null;        frame_display  = null;    }    public void SetInitWindow( Mainwin in_initwin )    {        init_win = in_initwin;    }    public void SetLogFileHdr( SLOG_ProxyInputStream in_slog )    {        slog = in_slog;    }    public int GetFrameIdx()    {        return frame_idx;    }    public int GetViewActionIdx()    {        return view_idx;    }    public int GetConnectActionIdx()    {        return connect_idx;    }    //  To implemet the required TimeInterface needed    public void showTime( double time )    {        SLOG_DirEntry   dir_entry;        SLOG_Dir  slog_dir = slog.GetDir();        for ( int idx = 0; idx < Nframe; idx++ ) {            dir_entry = slog_dir.EntryAt( idx );            if ( time >= dir_entry.starttime && time < dir_entry.endtime ) {                frame_idx = idx;                frame_idx_fld.setText( Integer.toString( frame_idx ) );                // display_btn.doClick();                break;            }        }    }    public void closePreview()    {        init_win.enableRead();        if ( init_win.slog != null ) {            try {                init_win.slog.Close();            }            catch( java.rmi.RemoteException err ) {                System.err.println( "ViewFrameChooser.closePreview(): "                                  + err.getMessage() );            }            catch( IOException err ) {                System.err.println( "ViewFrameChooser.closePreview(): "                                  + err.getMessage() );            }        }        init_win.slog = null;        init_win.frame_chooser = null;        free();        super.setVisible( false );        dispose();    }    private void UpdateGraphTimeMarker()    {        if ( frame_idx < Nframe ) {            SLOG_DirEntry dir_entry = slog.GetDir().EntryAt( frame_idx );            double frame_time_marker = ( dir_entry.starttime                                       + dir_entry.endtime ) / 2.0;            stat_preview.moveMarkerTo( frame_time_marker );        }    }    /**     * sets the current cursor to DEFAULT_CURSOR     */    void normalCursor()    {        ROUTINES.makeCursor( this, new Cursor( Cursor.DEFAULT_CURSOR ) );    }    /**     * sets the current cursor to WAIT_CURSOR     */    void waitCursor()    {        ROUTINES.makeCursor( this, new Cursor( Cursor.WAIT_CURSOR ) );    }    private URL getURL(String filename)    {        URL url = null;        /*        if ( isApplet ) {            URL codeBase = ( (JApplet) init_win.parent ).getCodeBase();            try {                url = new URL( codeBase, filename );            } catch ( java.net.MalformedURLException e ) {                System.out.println("badly specified URL");                return null;            }        }        else           url = ClassLoader.getSystemResource( filename );        */        url = getClass().getResource( filename );        return url;    }}

⌨️ 快捷键说明

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