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

📄 framedisplay.java

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.border.Border;/*  This class supervises all display operations and printing for the given  Jumpshot data.     It shows a frame consisting of buttons (Options), (Print), (Refresh),   (Close), (In), (Out), etc. and textFields including time cursor and  elapsed time. It also contains the canvas showing the different states    Once a slog frame is read by FrameReader, the data structures are passed  onto this class which then produces the display.*/public class FrameDisplay extends JFrame implements AdjustmentListener, ActionListener {  public Mainwin             init_win;  public ViewFrameChooser    frame_chooser;          // SLOG Data Structures         RecDefGroup         stateDefs;  // List of state definitions         StateGroupListPair  all_states;         RecDefGroup         arrowDefs;  // List of arrow definitions         ArrowList           all_arrows;         Vector              mtns;         String              view_indexes_label;    Properties printPrefs;      //stores the default settings from printing     //Dialogs and frames  //  PrintDlg printDlg;      // dialog containing print options   RecDefButtons def_btns;     // frame containing various records def'n buttons  CanOptions optionsDlg;      // dialog containing options  StateGroupDialog procDlg;            // dialog containing process options  //canvas's  ProgramCanvas canvas;       // canvas where states are drawn  VertScaleCanvas vcanvas1, vcanvas2; //canvas's where process numbers are drawn    // object that controls view into the much larger JComponent  JViewport vport;  JScrollBar hbar;            //scrollbar that controls horizontal scrolling  private MyTextField timeField, elTimeField;    Font frameFont, printFont;  Color frameBColor, frameFColor, printBColor, printFColor;  Color printImgBColor, normImgBColor, rulerColor;  boolean setupComplete     = false;  boolean IsRunningStateOff;  int dtype = CONST.TIMELINES, vertRulerGap;    /**   * constructor   */  public FrameDisplay( Mainwin            in_init_win,                       ViewFrameChooser   in_frame_chooser,                       PlotData           slog_plotdata,                       double             starttime,                       double             endtime,                       String             title_str )   {      super();          init_win           = in_init_win;      frame_chooser      = in_frame_chooser;      dtype              = init_win.dtype;      setTitle( CONST.DISPLAY_TYPES[ dtype ] + " : " + title_str );            IsRunningStateOff  = title_str.indexOf( "MPI-Process view" ) >= 0;           stateDefs          = slog_plotdata.stateDefs;      all_states         = slog_plotdata.all_states;      arrowDefs          = slog_plotdata.arrowDefs;      all_arrows         = slog_plotdata.all_arrows;      mtns               = slog_plotdata.mtns;      view_indexes_label = slog_plotdata.view_indexes_label;      setup( starttime, endtime );  }    // Setup methods--------------------------------------------------------------  private void setup( double starttime, double endtime )  {      adjustFrameStuff ();      setupCanvas ();      setupPanels ();      setupDlgs ();      setupPrintPrefs ();      setSize( init_win.dimPG );      setVisible (true);          // Before we draw the states on to the image, which is on the canvas the      // frame needs to be made visible so that we get a graphics context to      // draw upon. If the frame was not made visible a null graphics context      // was returned      waitCursor ();        drawData( starttime, endtime );      setupEventHandlers ();      setupComplete = true;      normalCursor ();      init_win.normalCursor ();  }    private void adjustFrameStuff()  {    frameBColor = init_win.frameBColor;    frameFColor = init_win.frameFColor;    frameFont = init_win.frameFont;    rulerColor = getBackground ();    printBColor = new Color (35, 129, 174);            //A lighter shade of blue    printFColor = Color.white;     printImgBColor = Color.lightGray;    normImgBColor = Color.black;    printFont = new Font ("Serif", Font.BOLD, 14);  }    /**   * Initialize canvas's. canvas has to be non-null to be placed in a    * panel   */  private void setupCanvas()  {      canvas = new ProgramCanvas();      vcanvas1 = new VertScaleCanvas( this, view_indexes_label );      vcanvas2 = new VertScaleCanvas( this, view_indexes_label );  }    private void setupPanels()  {    getContentPane().setLayout (new BorderLayout ());        JPanel mainPanel = new JPanel (new BorderLayout ());        GridBagConstraints con = new GridBagConstraints ();     con.anchor = GridBagConstraints.SOUTHWEST;    con.weightx = 1; con.fill = GridBagConstraints.HORIZONTAL;        Border border1;     Border border2 = BorderFactory.createLoweredBevelBorder ();        JPanel northP = new JPanel (new GridBagLayout ());            // ** The TextField in North West corner of the Main Display        JPanel textFieldP = new JPanel (new GridBagLayout ());        border1 = BorderFactory.createEmptyBorder (4, 4, 2, 2);        textFieldP.setBorder(BorderFactory.createCompoundBorder(border1,                                                                border2));            con.gridy = 0; con.gridx = 0;         textFieldP.add (new JLabel ("Pointer "), con);            con.gridx = 1;         textFieldP.add (timeField = new MyTextField ("", 10, false), con);         timeField.setToolTipText ("Cursor Position (in second) in display");            con.gridy = 1; con.gridx = 0;        textFieldP.add (new JLabel ("Elapsed Time "), con);            con.gridx = 1;        textFieldP.add (elTimeField = new MyTextField ("", 10, false), con);        elTimeField.setToolTipText( "Cursor Position (in second) in display "                                  + "w.r.t. Elapsed Time line");        // **        con.gridy = 0; con.gridx = 0;    northP.add (textFieldP, con);            // ** The North Central 3 buttons controlling the zoom operations        JPanel zoomP = new JPanel (new GridLayout (1, 3));        // border1 = BorderFactory.createEmptyBorder (4, 2, 2, 2);        border1 = BorderFactory.createTitledBorder( new EtchedBorder(),                                                    "Zoom Operations" );        zoomP.setBorder( BorderFactory.createCompoundBorder(border1, border2) );            zoomP.add( new MyButton( "In", "Zoom In Horizontally", this ) );        zoomP.add( new MyButton( "Out", "Zoom Out Horizontally", this ) );        zoomP.add( new MyButton( "Reset", "Redraws entire data in viewport",                                 this ) );        // **        con.gridy = 0; con.gridx = 1;    northP.add (zoomP, con);            // ** The North East 3 buttons controlling misc. operations        JPanel oP = new JPanel (new GridLayout (1, 3));        // border1 = BorderFactory.createEmptyBorder (4, 2, 2, 4);        border1 = BorderFactory.createTitledBorder( new EtchedBorder(),                                                   "Miscellaneous Operations" );        oP.setBorder( BorderFactory.createCompoundBorder(border1, border2) );            oP.add( new MyButton( "Options",                              "Display options for arrows, zoom lock line, "                            + "elapsed time line and nesting", this));        MyButton button = new MyButton( "Print",                                        "Print display to file or printer",                                        this);            // if ( init_win.getIsApplet() ) button.setEnabled (false);        oP.add (button);        oP.add (new MyButton ("Close", "Close window", this));        // **        con.gridy = 0; con.gridx = 2;    northP.add (oP, con);        mainPanel.add (northP, BorderLayout.NORTH);        // The Main Central panel  which hold the drawing canvas, srollbar...    JPanel canPanel = new JPanel (new BorderLayout ());    border1 = BorderFactory.createEmptyBorder (2, 4, 4, 4);    canPanel.setBorder (BorderFactory.createCompoundBorder (border1, border2));            // ** The Viewport that holds the drawing canvas        vport = new JViewport();        vport.setView( canvas );        vport.addComponentListener( canvas );            // Bug: JViewport does not support setBorder         // so we put JViewport in a Panel with a border        JPanel vpp = new JPanel( new BorderLayout() );         vpp.setBorder( BorderFactory.createCompoundBorder(                          BorderFactory.createRaisedBevelBorder (),                          BorderFactory.createLoweredBevelBorder ())                     );        vpp.add (vport, BorderLayout.CENTER);        // **            // ** The ScrollBar panel        JPanel p = new JPanel (new BorderLayout ());        p.add (vpp, BorderLayout.CENTER);        p.add (hbar = new JScrollBar (JScrollBar.HORIZONTAL),               BorderLayout.SOUTH);        // **    canPanel.add (p, BorderLayout.CENTER);            vertRulerGap = (vpp.getInsets()).top + (p.getInsets()).top;        vcanvas1.setVerticalGap( vertRulerGap );         vcanvas2.setVerticalGap( vertRulerGap );        canPanel.add(vcanvas1, BorderLayout.EAST);    canPanel.add(vcanvas2, BorderLayout.WEST);    mainPanel.add(canPanel, BorderLayout.CENTER);        getContentPane().add(mainPanel, BorderLayout.CENTER);  }    private void setupEventHandlers()    {        hbar.addAdjustmentListener (this);            addWindowListener( new WindowAdapter()                           {                               public void windowClosing( WindowEvent e )                               { kill(); }                            }                         );     }

⌨️ 快捷键说明

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