CTC++ Coverage Report - Execution Profile    #1/1

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Index | No Index


File: AbstractSpace.java
Instrumentation mode: function-decision-multicondition
TER: 88 % ( 28/ 32)

Start/ End/    
True False - Line Source

  1 // Abstract space 
  2 // Copyright (C) 2002 Charles Foster 
  3 // Please visit www.cfoster.net 
  4  
  5 import java.awt.*; 
  6 import java.applet.*; 
  7  
  8 public class AbstractSpace extends Applet implements Runnable 
  9 
  10    double[][] stars; 
  11    double centerx, centery; 
  12  
  13    Thread myThread = null; 
  14    Image myImage = null; 
  15    Graphics g2; 
  16  
  17    boolean clicked = false; 
  18    boolean credits = true; 
  19  
  20    double speedx = 0.02, speedy = 0.02, angrot = 0.05; 
  21    double oldx = 0, oldy = 0; 
  22    int stramt, j; 
  23  
 
108   24    public void init() 
  25    { 
  26       centerx = (int)size().width/2; 
  27       centery = (int)size().height/2; 
  28       getParameters(); 
18690 108   29       for(int i=0;i<stars.length;i++) 
  30       { 
  31          buildStar(i); 
  32       } 
  33       myImage = createImage(size().width,size().height); 
  34       g2 = myImage.getGraphics(); 
  35    } 
 
108   36    public void getParameters() 
  37    { 
  38       speedx = (double)(Integer.parseInt(getParameter("speedx")))/100; 
  39       speedy = (double)(Integer.parseInt(getParameter("speedy")))/100; 
  40       angrot = (double)(Integer.parseInt(getParameter("angrot")))/100; 
  41       stramt = Integer.parseInt(getParameter("stramt")); 
  42       stars = new double[stramt][6]; 
  43    } 
 
481868   44    public void buildStar(int s) 
  45    { 
  46       stars[s][0] = 0; 
  47       stars[s][1] = 0; 
  48  
  49       stars[s][2] = 0; 
  50       stars[s][3] = 0; 
  51  
  52       stars[s][4] = Math.random()*360; // angle to start 
  53       stars[s][5] = Math.random()*size().width*2; // life expectancy 
  54    } 
 
108   55    public void start() 
  56    { 
108 - 57       if(myThread == null) 
  58       { 
  59          myThread = new Thread(this); 
  60          myThread.start(); 
  61       } 
  62    } 
 
108   63    public void stop() 
  64    { 
108 - 65       if(myThread != null) 
  66       { 
  67          myThread.stop(); 
  68          myThread = null; 
  69       } 
  70    } 
 
108   71    public void run() 
  72    { 
768483 - 73       while(true) 
  74       { 
  75          g2.setColor(Color.black); 
  76          g2.fillRect(0,0,size().width,size().height); 
33353 735126   77          if(credits) 
  78          { 
  79             g2.setColor(Color.green); 
  80             g2.drawString("Abstract Space, Copyright (C) Charles Foster 2002",20,20); 
  81             g2.drawString("www.cfoster.net",20,35); 
69 33283   82             if(++j > 400) { credits = false; } 
  83          } 
  84          g2.setColor(Color.white); 
1406E5 768477   85          for(int i=0;i<stars.length;i++) 
  86          { 
1395E5 1137E3   87             if(!clicked) 
  88             { 
463178 1390E5   89                if(stars[i][0] > stars[i][5]) { buildStar(i); } 
  90                stars[i][0] = Math.cos(oldx+stars[i][4])*stars[i][2]*180/Math.PI+centerx; 
  91                stars[i][1] = Math.sin(oldy+stars[i][4])*stars[i][3]*180/Math.PI+centery; 
  92                stars[i][2] += speedx; 
  93                stars[i][3] += speedy; 
  94                stars[i][4] += angrot; 
  95             } 
    96             else 
  97             { 
  98                stars[i][0] = Math.cos(oldx+stars[i][4])*stars[i][2]*180/Math.PI+centerx; 
  99                stars[i][1] = Math.sin(oldy+stars[i][4])*stars[i][3]*180/Math.PI+centery; 
  100             } 
  101             g2.fillRect((int)stars[i][0],(int)stars[i][1],2,2); 
  102          } 
  103          repaint(); 
768476   104          try { myThread.sleep(25); } catch(InterruptedException e) {} 
 - 104   catch (InterruptedException e)
  105       } 
  106    } 
 
9910   107    public boolean mouseDrag(Event evt,int x,int y) 
  108    { 
  109       clicked = true; 
  110       oldy = (double)(y-oldy)/180*Math.PI; 
  111       oldx = (double)(oldx-x)/180*Math.PI; 
9910    112       return true; 
  113    } 
 
320   114    public boolean mouseUp(Event e, int x, int y) 
  115    { 
  116       clicked = false; 
320    117       return true; 
  118    } 
 
760757   119    public void paint(Graphics g){} 
 
759714   120    public void update(Graphics g) 
  121    { 
  122       paint(g2); 
  123       g.drawImage(myImage, 0, 0, this); 
  124    } 
  125 }
***TER 88% (28/32) of SOURCE FILE AbstractSpace.java

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Top | Index | No Index