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

📄 myimage.java

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import java.awt.*;import java.util.Vector;import java.util.Enumeration;import java.awt.event.*;import java.lang.Math;import com.sun.java.swing.*;import java.awt.image.ImageObserver;/** * this is the class that contains the offscreen images on which the jumpshot data * is drawn. 2 offscreen images are used, one for states and arrows (img) and the * other for time line (timeImg). Functions for drawing rectangles and arrows are * present here.  */class MyImage {  ProgramCanvas parent;  int imgIdH;     //id of this object   double begT;    //staring time of this object  double endT;    //ending time of this object  int _xPix;      //width of the entire image in pixels  int _yPix;      //height of the entire image in pixels    Image rulerImg;  //offscreen image for displaying the time ruler    int tx;         //Used to prevent drawing thin states repeatedly over one another.    //Configuration variables for the arrows.  public Color printLineColor, normLineColor;  public Color circleColor;             //Color of the circle of arrow  public Color hiColor = Color.red;     //Arrow ring Color  public Color normColor = Color.white; //Arrow Color  public int lrad = 1;                  //Radius of the little cirle  public int brad = 3;                  //Radius of the bigger circle  public int angle = 40;                //central angle of the arrow head  public int ht = 20;                   //height of the arrow head    public int max = 8; //The maximum size of the time string in time ruler    private int numDisp;  private Display [] dispA;  private Vector dtypeV;    public MyImage (int idH, int x, int y, Vector d, ProgramCanvas p) {    imgIdH = idH;    _xPix = x; _yPix = y;    parent = p;    dtypeV = d;    normLineColor = normColor; circleColor = hiColor; printLineColor = Color.black;    setupDisps ();   }    public MyImage (int x, int y, Vector d, ProgramCanvas p) {    _xPix = x; _yPix = y;    parent = p;    dtypeV = d; numDisp = d.size ();    normLineColor = normColor; circleColor = hiColor; printLineColor = Color.black;  }    void paintStuff1 (int x, Graphics g, ImageObserver io) {    g.drawImage (rulerImg, x, parent.allDispHt, io);        for (int i = 0; i < numDisp; i++) g.drawImage (dispA [i].img1, x, i * parent.eachDispHt, io);  }    void paintStuff2 (int x, Graphics g, ImageObserver io) {    g.drawImage (rulerImg, x, parent.allDispHt, io);        for (int i = 0; i < numDisp; i++) {      if (dispA [i].dtype == CONST.TIMELINES) 	g.drawImage (dispA [i].img2, x, i * parent.eachDispHt, io);      else 	g.drawImage (dispA [i].img1, x, i * parent.eachDispHt, io);    }  }    private void setupDisps () {    numDisp = dtypeV.size ();        //Get offscreen images from parent    rulerImg = parent.getOffScreenImage (_xPix, parent.rulerHt);        dispA = new Display [numDisp];        for (int i = 0; i < numDisp; i++) {      int dtype = ((Integer)dtypeV.elementAt (i)).intValue ();            Image im1 = parent.getOffScreenImage (_xPix, parent.eachDispHt), im2;            if (dtype == CONST.TIMELINES) im2 = parent.getOffScreenImage (_xPix, parent.eachDispHt);      else im2 = null;            dispA [i] = new Display (dtype, im1, im2);    }  }  /**   * set time values and draw stuff   */  void drawRegion (double b, double e) {    begT = b; endT = e;    drawStuff ();  }    /**   * set starting and ending time values   */  void setTimes (double b, double e) {begT = b; endT = e;}    /**   * draw all things in the offscreen images   */  void drawStuff () {    for (int i = 0; i < numDisp; i++)       if (dispA [i].dtype == CONST.TIMELINES) drawTimeLines (dispA [i]);      else drawMtnRanges (dispA [i]);        Graphics g = rulerImg.getGraphics (); drawTimeRuler (g); g.dispose ();  }    void printStuff (Graphics g) {    for (int i = 0; i < numDisp; i++) {      if (((Integer)dtypeV.elementAt (i)).intValue () == CONST.TIMELINES) drawTimeLines (g);      else drawMtnRanges (g);      g.translate (0, parent.eachDispHt);    }        drawTimeRuler (g);  }    private void drawTimeLines (Display d) {    Graphics g1 = d.img1.getGraphics (), g2 = d.img2.getGraphics ();        //Image Background    g1.setColor (parent.parent.normImgBColor); g2.setColor (parent.parent.normImgBColor);    g1.fillRect (0, 0, _xPix, parent.eachDispHt); g2.fillRect (0, 0, _xPix, parent.eachDispHt);        //Top and bottom borders    g1.setColor (parent.parent.rulerColor); g2.setColor (parent.parent.rulerColor);    g1.fill3DRect (0, 0, _xPix, parent.hBWt, true); g2.fill3DRect (0, 0, _xPix, parent.hBWt, true);    g1.fill3DRect (0, parent.eachDispHt - parent.hBWt, _xPix, parent.hBWt, true);    g2.fill3DRect (0, parent.eachDispHt - parent.hBWt, _xPix, parent.hBWt, true);    drawStates (g1, g2);    drawArrows (g1, g2);      g1.dispose (); g2.dispose ();  }    private void drawTimeLines (Graphics g) {    //Image background    g.setColor (parent.parent.printImgBColor);    g.fillRect (0, 0, _xPix, parent.eachDispHt);        //Top and bottom borders    g.setColor (parent.parent.rulerColor);    g.fill3DRect (0, 0, _xPix, parent.hBWt, true);    g.fill3DRect (0, parent.eachDispHt - parent.hBWt, _xPix, parent.hBWt, true);    drawStates (g, null);    drawArrows (g, null);  }    private void drawMtnRanges (Display d) {    Graphics g = d.img1.getGraphics ();    drawMtnRanges (g);    g.dispose ();  }    private void drawMtnRanges (Graphics g) {    //Image background    if (g instanceof PrintGraphics) g.setColor (parent.parent.printImgBColor);    else g.setColor (parent.parent.normImgBColor);    g.fillRect (0, 0, _xPix, parent.eachDispHt);        //Top and bottom borders    g.setColor (parent.parent.rulerColor);    g.fill3DRect (0, 0, _xPix, parent.hBWt, true);    g.fill3DRect (0, parent.eachDispHt - parent.hBWt, _xPix, parent.hBWt, true);        drawMtns (g);  }    /**   * draw all states   */  private void drawStates (Graphics g1, Graphics g2) {    Vector procVector = parent.procVector;    Enumeration enum = procVector.elements ();    double py;        while (enum.hasMoreElements ()) {      JProcess currProc = (JProcess)enum.nextElement ();            if (currProc.dispStatus) {	py = parent.getProcYCord (parent.getIndex (parent.procVector, currProc.procId));	draw (currProc, py, g1, g2); 	        Vector a = currProc.procStateVector;	tx = -1;	for (int i = a.size () - 1; i >= 0; i--) {          ProcessState currEvt = (ProcessState)(a.elementAt (i));          if (currEvt.info.stateDef.checkbox.isSelected ())	    if (!(currEvt.info.endT < begT || currEvt.info.begT > endT)) {	      if (currEvt.info.blink) parent.blink = true;	      draw (currEvt, py, g1, g2);	    }	}      }     }  }  /**   * draw mountain ranges   */  private void drawMtns (Graphics g) {    Vector mtns = parent.parent.mtns;    Enumeration enum = mtns.elements ();    tx = -1;        while (enum.hasMoreElements ()) {      MtnInfo currMtn = (MtnInfo)enum.nextElement ();            if (!(currMtn.endT < begT || currMtn.begT > endT)) {	double lenT = endT - begT;	double timeDiff = currMtn.begT - begT;	double effT = (timeDiff > 0)? timeDiff : 0.0;		double t;	if ((currMtn.endT - begT) > lenT) t = lenT;	else t = (currMtn.endT - begT);		int width = parent.getW (effT, t);		int x = parent.getEvtXCord (effT);	int l = parent.totalProc;		//	if (!(x == tx && (width == 0 || width == 1))) {	for (int i = 0; i < currMtn.s.length; i++) {	  CLOG_STATE state = ((CLOG_STATE)parent.parent.stateDefs.elementAt (i));	  if (currMtn.s [i] > 0 && state.checkbox.isSelected ()) {	    if ((l - currMtn.s [i]) < 0) break;	      	    double ycord = parent.hBWt + ((parent.eachDispIHt / (double)parent.totalProc) * 					  (l - currMtn.s [i]));	    double limit = parent.hBWt + ((parent.eachDispIHt / (double)parent.totalProc) * l) - 1;	    	    double height = limit - ycord + 1;	    if (height == 0) height = 1;	      

⌨️ 快捷键说明

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