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

📄 programcanvas.java

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      int prevId = getPrev (currImg.imgIdH);      if (img [prevId].endT != currImg.begT ||          img [prevId].begT != (currImg.begT - t))renderPrevH (1);      debug.println( "\t" + "prevImg.begT = " + img[prevId].begT + ",  "                          + "prevImg.endT = " + img[prevId].endT );    }  }    /**   * Draw the image data for the nth image before the current one   */  private void renderPrevH (int n) {    int prevId = getPrev  (currImg.imgIdH);    double tL = getTime (_xPix);    debug.println( "renderPrevH(" + n + ") : " );    debug.println( "\t" + "img["+prevId+"].drawRegion("                 + (currImg.begT - n * tL) + ", "                 + (currImg.begT - (n - 1) * tL) + " )" );    img [prevId].drawRegion (currImg.begT - n * tL, currImg.begT - (n - 1) * tL);  }    /**   * Draw the image data for the nth image after the current one   */  private void renderNextH (int n) {    int nextId = getNext (currImg.imgIdH);    double tL = getTime (_xPix);    debug.println( "renderNextH(" + n + ") : " );    debug.println( "\t" + "img["+nextId+"].drawRegion("                 + (currImg.endT + (n - 1) * tL) + ", "                 + (currImg.endT + n * tL) + " )" );    img [nextId].drawRegion (currImg.endT + (n - 1) * tL, currImg.endT + n * tL);  }   /**   * Return the image # where the given scrollbar position points to   */  private int getCurrGridH (int x) {return x / _xPix;}  //--------------------------------------------------------------------------  //Methods describing horizontal and vertical position------------------------    private void calcYDensity()    {        int groups_size = all_states.visible.size();        yDensity = eachDispIHt / (groups_size + ((groups_size + 1) / 5.0));    }    public void UpdateYDensity()    {        calcYDensity();    }      double GetStateGroupYCord( int seq_idx )    {        return ( hBWt + ((2 * seq_idx + 1) * yDensity / 2.0)               + ( (seq_idx + 1) * yDensity / 5.0 ) );    }      //This method calculates the y co-ordinate of the given event w.r.t the    //y co-ordinate of the time line for the related processor    //yDensity contains pixels / eventHeight    double getEvtYCord( int seq_idx )    {        return GetStateGroupYCord( seq_idx ) - yDensity  / 2.0;    }  /**   * This method calculates the x co-ordinate of the givent event from its   * starting time   */  int getEvtXCord (double t) {    return (int)(Math.rint (t * xDensity));  }  double getTime (int pos) {    double time = (1.0 / xDensity) * pos;    return time;  }    /**   * This method gets the length for the given event based on its starting and   * ending timestamps   */  int getW (double begT, double endT) {    return  ((int)Math.rint (endT * xDensity) - (int)Math.rint (begT * xDensity));  }    void updateH () {    maxH = getW (0, maxT);  }  //---------------------------------------------------------------------------    /**   * Return index of the process where the given y position is placed   */  int findIndex (int y) {    int index = -1;    // for (int i = 0; i < proct; i++) {    int groups_size = all_states.visible.size();    for (int i = 0; i < groups_size; i++) {      int a = (int)Math.rint (getEvtYCord (i));      int b = a + (int)Math.rint (yDensity);      if (y >= a && y <= b) {index = i; break;}    }    return index;  }    /**   * Return the state upon which the given x and y coordinates are placed   */  private StateInterval findState (int x, int y) {    int dIndex = y / eachDispHt;        if (((Integer)dtypeV.elementAt (dIndex)).intValue () != CONST.TIMELINES)        return null;        int index = findIndex (y % eachDispHt);        y = y % eachDispHt;        if (index != -1) {      StateGroup currProc = (StateGroup)(all_states.visible.elementAt (index));      if (currProc.dispStatus) {        Enumeration e = currProc.elements();        while ( e.hasMoreElements() ) {          StateInterval currState = (StateInterval) e.nextElement();          //Determining using position (less accurate)          if ( currState.info.stateDef.checkbox.isSelected () &&              (getEvtXCord (currState.info.begT - currImg.begT) <= cursorPos) &&              (cursorPos <= getEvtXCord (currState.info.endT - currImg.begT)) &&              checkLevel (currState, y))            return currState;        }      }    }    return null;  }  /**   * Method checks whether the given y coordinate is valid above the   * given state     */    // This check is not very efficient as for small nestFactors    // differentiating between nested states may not yield correct     // results. Here we give preference to the boundry of the inner    // state over the outer state --> y => currState.pt.y && y <= (curr.......    // A choice had to be made and we chose this.  private boolean checkLevel (StateInterval currState, int y) {    if (y >= currState.y && y <= (currState.y + currState.h))      return true;    return false;  }    /**   * Return the ArrowInfo object upon which the given x and y coordinates   * are placed   */  private ArrowInfo findMsg( int x, int y )  {      RecDef        arrowdef;      Enumeration   arrows;      ArrowInfo     arrow;      int           x1;      int           y1;      int dIndex = y / eachDispHt;      if (    ( (Integer) dtypeV.elementAt(dIndex) ).intValue()           != CONST.TIMELINES )          return null;            int index = findIndex( y % eachDispHt );            y = y % eachDispHt;            if ( index != -1 ) {          StateGroup states = (StateGroup) all_states.visible.elementAt(index);          y1 = states.y;          Enumeration arrowdefs = parent.arrowDefs.elements();          while ( arrowdefs.hasMoreElements() ) {              arrowdef = ( RecDef ) arrowdefs.nextElement();              if (    arrowdef.stateVector.size() > 0                   && arrowdef.checkbox.isSelected() ) {                  arrows = arrowdef.stateVector.elements();                  while ( arrows.hasMoreElements() ) {                      arrow = ( ArrowInfo ) arrows.nextElement();                      if ( arrow.begGroupID.IsEqualTo( states.groupID ) ) {                          x1 = getEvtXCord( arrow.begT - currImg.begT );                          if (    ( (x1 - img[0].brad) <= (x - _xPix) )                               && ( (x - _xPix) <= (x1 + img[0].brad) )                               && ( (y1 - img[0].brad) <= y )                               && ( y <= (y1 + img[0].brad) )                             )                              return arrow;                      }                  }              }          }      }      return null;  }  //Event Handler methods-------------------------------------------------------  //  Events may be generated when the mouse is pressed, released or moved   //  and also if keyboard keys 'Z' or 'T' are pressed  private void setupEventHandlers () {    this.enableEvents  (AWTEvent.MOUSE_MOTION_EVENT_MASK |                         AWTEvent.MOUSE_EVENT_MASK |                        AWTEvent.KEY_EVENT_MASK);  }  /**   * Handles the event when the mouse is moved   */  public void processMouseMotionEvent (MouseEvent e) {    if (e.getID () == MouseEvent.MOUSE_MOVED) {      adjustTimeField (e.getX ());      adjustElTimeField ();    }    else super.processMouseMotionEvent (e);  }    /**   * Handles the event when the mouse is pressed or released   */  public void processMouseEvent (MouseEvent e) {    if (e.getID () == MouseEvent.MOUSE_PRESSED && parent.dtype == CONST.TIMELINES) {      message = handleMsgDlg (e);      if (!message) handleEventDlg (e);    }    else super.processMouseEvent (e);  }    /**   * Check if a state dialog is to be displayed??   */  private void handleEventDlg( MouseEvent e ) {    int x = e.getX(), y = e.getY();    if (y >= allDispHt) return;    StateInterval cur_state = findState( x, y );    if (cur_state != null) {      RecordDialog sd = new RecordDialog( parent, cur_state );            Point p = getLocationOnScreen();      int tx = x, ty = y;      tx += p.x; ty += p.y;      sd.setLocation(tx, ty);             sd.setVisible (true);    }  }    /**   * Check if a message dialog is to be displayed??   */  private boolean handleMsgDlg (MouseEvent e) {    int x = e.getX (), y = e.getY ();    if (y >= allDispHt) return false;    ArrowInfo arrow = findMsg (x, y);    if (arrow != null) {      RecordDialog md = new RecordDialog( parent, arrow );            Point p = getLocationOnScreen ();      int tx = x, ty = y;      tx += p.x; ty += p.y;      md.setLocation (tx, ty);            md.setVisible (true);            return true;    }    return false;  }    /**   * Handles the event when the key is pressed   */  public void processKeyEvent (KeyEvent e) {    int keyCode = e.getKeyCode ();        if (e.getID () == KeyEvent.KEY_PRESSED) {      if (keyCode == KeyEvent.VK_Z) lockZoom ();      else if (keyCode == KeyEvent.VK_T)         fixElTimePointer (currTime);    }    else super.processKeyEvent (e);  }  //---------------------------------------------------------------------------------------    /**   * lock zoom at the current cursor position   */  private void lockZoom () {    if (zoomLkLineDispStatus) {      zXTime = currTime;      debug.println( "lockZoom() : zXTime = " + zXTime );      repaint ();    }  }    /**   * fix the elapsed time line to the given time   */  void fixElTimePointer (double time) {    if (elTLineDispStatus) {      elapsedPoint = time;      //Refresh ();      // currImg.reDrawElTimeLine (); //Not yet implemented      repaint ();    }  }  //Methods controlling zooming of data--------------------------------------------------  /**   * zoom in horizontally   */  void zoomInH () {waitCursor (); zoomH (zF); normalCursor ();}    /**   * zoom in Vertically   */  void zoomOutH () {waitCursor (); zoomH (1 / zF); normalCursor ();}       /**   * reset view so that all the data fits in a viewport   */  void resetView () {    waitCursor ();        changeConst (1 / zoomH);        if (maxH != widthCan) {      maxT = tMaxT;      xDensity = widthCan / maxT;      maxT += (endGap / xDensity);      xDensity = widthCan / maxT;            updateH ();    }    adjustZoomImg (0);    normalCursor ();  }    /**   * method called whenever a horizontal zoom is performed   */  void zoomH (double z) {    //Calculations required whenever a horizontal zoom is needed.    int tmaxH = maxH;    // zDist = getW (getTime (tbegH), zXTime);    // zDist = getW (currImg.begT + getTime (tbegH), zXTime);    zDist = getW( getTime(tbegH), zXTime - FrameBegTime );    debug.println( "zoomH(" + z + ") : currImg.begT = " + currImg.begT                 + ",  begTime = " + begTime + ",  tbegH = " + tbegH );    debug.println( "\t" + "zXTime = " + zXTime + ",  zDist = " + zDist );        changeConst (z);        //Get the scrollbar Position in the zoomed Image    // int xcord = getEvtXCord (zXTime);    // int xcord = getEvtXCord( zXTime - currImg.begT );    int xcord = getEvtXCord( zXTime - FrameBegTime );    sbPos = ( (tmaxH > widthCan || maxH > widthCan) && xcord > zDist ) ?              xcord - zDist : 0;         debug.println( "zoomH(" + z + ") : tmaxH, maxH, widthCan, xcord = "                 + tmaxH + ", " + maxH + ", " + widthCan + ", " + xcord );    debug.println( "zoomH(" + z + ") : A) sbPos = " + sbPos );    if ( sbPos + parent.hbar.getVisibleAmount() >= maxH )         sbPos =  maxH - parent.hbar.getVisibleAmount();    if ( sbPos < 0 )         sbPos = 0;    debug.println( "zoomH(" + z + ") : B) sbPos = " + sbPos );        //Get the appropriate image    adjustZoomImg (sbPos);  }    private void changeConst (double z) {    zoomH *= z; xDensity *= z;    updateH ();  }    //  public void update (Graphics g) {paint (g);}  private void adjustZoomImg (int pos) {    int extra = 0, rem = 0;    getImgH (getCurrGridH (pos));     bflagH = false; fflagH = false;     tbegH = pos;    if (pos > 0) {        extra = getW(currImg.begT, zXTime) - zDist;        // rem = getW (currImg.begT, maxT) - widthCan;        // rem = getW(0, maxT) - widthCan;

⌨️ 快捷键说明

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