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

📄 plotpanel.java

📁 A Java virtual machine instruction consists of an opcode specifying the operation to be performed, f
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.util.*;

//swing classes
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
//--------------------------------------------
public class PlotPanel extends JPanel
{
   float xfactor, yfactor;
   int xpmin, ypmin, xpmax, ypmax;
   float minX, maxX, minY, maxY;
   float x[], y[];
   Color color;
//--------------------------------------------
 public void setBounds(float minx, float miny, float maxx, float maxy)
  {
     minX=minx;
     maxX= maxx;
     minY=miny;
     maxY = maxy;
  }                                           
//--------------------------------------------
 public void plot(float[] xp, float[] yp, Color c)
 {
  x = xp;      //copy in the arrays
  y = yp;
  color = c;   //and color
  
  //compute bounds and sclaing factors
  int w = getWidth() - getInsets().left - getInsets().right;
  int h = getHeight() - getInsets().top - getInsets().bottom;
    
  xfactor = (0.9f * w) / (maxX - minX);
  yfactor = (0.9f * h)/ (maxY - minY);

  xpmin = (int)(0.05f * w);
  ypmin = (int)(0.05f * h);
  xpmax = w - xpmin;
  ypmax = h - ypmin;
  repaint();      //this causes the actual plot
 }
//--------------------------------------
protected int calcx(float xp)
{
   return (int)((xp-minX) * xfactor + xpmin);
}
//--------------------------------------
protected int calcy(float yp)
{
   int ypnt = (int)((yp-minY) * yfactor);
   return ypmax - ypnt;
}

}

⌨️ 快捷键说明

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