示例#1
0
文件: SineWave.java 项目: haomen/refs
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   int maxWidth = getWidth();
   double hstep = (double) maxWidth / (double) points;
   int maxHeight = getHeight();
   for (int i = 0; i < points; i++)
     pts[i] = (int) (sines[i] * maxHeight / 2 * .95 + maxHeight / 2);
   g.setColor(Color.red);
   for (int i = 1; i < points; i++) {
     int x1 = (int) ((i - 1) * hstep);
     int x2 = (int) (i * hstep);
     int y1 = pts[i - 1];
     int y2 = pts[i];
     g.drawLine(x1, y1, x2, y2);
   }
 }
示例#2
0
文件: Applet3.java 项目: haomen/refs
 public void paint(Graphics g) {
   s = "inits: " + inits + ", starts: " + starts + ", stops: " + stops;
   g.drawString(s, 10, 10);
 }