Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Public Attributes | Package Attributes | Static Private Attributes
VreemdeEend1 Class Reference
Inheritance diagram for VreemdeEend1:
Inheritance graph
[legend]
Collaboration diagram for VreemdeEend1:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init ()
void paint (Graphics canvas)
void start ()
void stop ()
void run ()
String ReadApplet ()

Static Public Member Functions

static int[] Shuffle (int[] S)

Public Attributes

long totaltime = 0
Image ok
Image nok

Package Attributes

Graphics canvas
String replystring = ""
int xsize = 160
int ysize = 160
int sx = 80
int xmax = 4*xsize
int ymax = ysize
int keuze [] = {0,1,2,3}
int kans [] = {0,1}
int polies [] = {0,1,2,3}
int kleuren [] = {0,1,2,3,4,5,6,7}
int xobject [][][]
int yobject [][][]
int colors [][] = {{250,0,0},{0,250,0},{0,0,250},{250,250,0},{250,0,250},{0,250,250},{0,0,0},{255,255,255}}
int fout = 0
int anders = 0
long begin
int klaar
int goedzo = 0
int dx
int dy
long start
int foutcounter = 1
double diff
int max = 20
String duration = ""
int counter = 1
int first_try = 1
long stop
Font defaultFont = new Font("Courier",0, 14)
String time = "time in seconds"
String freq = "attempts"
String teller = "number"
String ready_string = "DONE"
int show_result = 1
int do_paint = 1

Static Private Attributes

static final long serialVersionUID = 1L

Detailed Description

Definition at line 23 of file VreemdeEend1.java.


Member Function Documentation

void VreemdeEend1.init ( ) [inline]

Definition at line 52 of file VreemdeEend1.java.

                      {
       ok=getImage(getCodeBase(), "ok.gif");nok=getImage(getCodeBase(), "nok.gif"); 
       begin=System.currentTimeMillis();klaar=0;
       String c=getParameter("max");if(c!=null && c.length()>0){max = Integer.parseInt(c, 10); if(max>60){max=60;} if(max<2){max=5;}}
       String renew=getParameter("renew");if(renew!= null && renew.equals("no")){first_try=0;}
       String lang=getParameter("language");
       if(lang != null){
           if(lang.equals("nl")){time="tijd in seconden";freq="pogingen";teller="nummer";ready_string="KLAAR";}
           if(lang.equals("fr")){time="temps (sec.)";freq="tentatives";teller="numero";ready_string="FINI";}
       }          
       String show=getParameter("show_result");if(show != null){if(show.equals("no")){show_result=0;}}   
       addMouseListener(
           new MouseAdapter(){
              public void mousePressed(MouseEvent e){
                  dx = e.getX();
                  dy = e.getY();
                  if(klaar==0){
                     for(int p=0;p<4;p++){
                         if(dy>0 && dy<ymax){
                            if(dx>p*xsize && dx<(p+1)*xsize){
                                if(fout==p){
                                   stop=System.currentTimeMillis();
                                   diff=(double)(Math.round(1000*(stop-start)))/1000000;
                                   duration=duration+","+diff;
                                   replystring=replystring+"\n"+diff+" : "+foutcounter;
                                   foutcounter=1;
                                    counter++;goedzo=1;do_paint=1;
                                   if(counter> max){klaar=1;}
                                   start=System.currentTimeMillis();
                                }
                                else
                                {
                                   goedzo=0;
                                   foutcounter++;
                                   if(first_try==0){do_paint=0;}else{do_paint=1;}
                                }
                            }
                         }
                     }
                  repaint();
                  }
              }
           }
       );
    
}

Here is the call graph for this function:

void VreemdeEend1.paint ( Graphics  canvas) [inline]

Definition at line 114 of file VreemdeEend1.java.

                                     {
       Graphics2D g2 = (Graphics2D) canvas;
       g2.setStroke( new BasicStroke(4.0f) );
    if(klaar==0){
       g2.setColor(Color.black);
       g2.clearRect(xsize,ysize,2*xsize,ysize+10);
       g2.drawString(teller+" : "+counter,xsize,ysize+10);
       if(do_paint==1){
           int basis=0;int t;int p0;int p1;int p2;int p3;int geweest[]=new int[3];
           Polygon poly0;Polygon poly1;Polygon poly2;Polygon poly3;
           keuze=Shuffle(keuze);fout=keuze[0];kans=Shuffle(kans);anders=kans[0];
           kleuren=Shuffle(kleuren);int k0=kleuren[0];int k1=kleuren[1];int k2=kleuren[2];
           Color kleur1=new Color(colors[k0][0],colors[k0][1],colors[k0][2]); 
           Color kleur2=new Color(colors[k1][0],colors[k1][1],colors[k1][2]); 
           for(int p=0;p<4;p++){
               g2.setColor(kleur1);
              g2.fillRect(p*(xsize),1,(p+1)*(xsize),ymax-2);
               g2.setColor(kleur2);basis=p*xsize;
              polies=Shuffle(polies);p0=polies[0];p1=polies[1];p2=polies[2];p3=polies[3];
               //System.out.println("p0="+p0+" p1="+p1+" p2="+p2+" p3="+p3);
               poly0=new Polygon(xobject[p0][p],yobject[p0][p],xobject[p0][p].length);
               poly1=new Polygon(xobject[p1][p],yobject[p1][p],xobject[p1][p].length);
              poly2=new Polygon(xobject[p2][p],yobject[p2][p],xobject[p2][p].length);
               poly0.translate(basis,0);
               poly1.translate(basis+sx,0);
               poly2.translate(basis,sx);
              if(anders==0){g2.fillPolygon(poly0);g2.fillPolygon(poly1);g2.fillPolygon(poly2);}
              else{g2.drawPolygon(poly0);g2.drawPolygon(poly1);g2.drawPolygon(poly2);}
              
              if(fout!=p){
                  poly3=new Polygon(xobject[p3][p],yobject[p3][p],xobject[p3][p].length);
                  poly3.translate(basis+sx,sx);
                  if(anders==0){g2.fillPolygon(poly3);}else{g2.drawPolygon(poly3);}
              }else{
                  geweest[0]=p0;geweest[1]=p1;geweest[2]=p2;geweest=Shuffle(geweest);t=geweest[0];
                  poly3=new Polygon(xobject[t][p],yobject[t][p],xobject[t][p].length);
                  poly3.translate(basis+sx,sx);
                  if(anders==0){g2.fillPolygon(poly3);}else{g2.drawPolygon(poly3);}
              }
                             
              Color kleur3=new Color(colors[k2][0],colors[k2][1],colors[k2][2]); 
               g2.setColor(kleur3);
              g2.drawRect(p*(xsize),1,(p+1)*(xsize),ymax-2);
           }
              
           if(counter==1){ start=begin;}
           else{
              g2.clearRect(2*xsize,ysize,50,50);
              if(goedzo==1){g2.drawImage(ok,2*xsize,ysize, this);}else{g2.drawImage(nok,2*xsize,ysize, this);}
           }
        }
        else
        {
           g2.clearRect(2*xsize,ysize,50,50);
           g2.drawImage(nok,2*xsize,ysize, this);
        }
       }
       else
       {
           if(show_result == 1){
           // finished: show "table" with time:freq
              g2.clearRect(2*xsize,ysize,50,50);
               g2.setColor(Color.black);g2.fillRect(0,0,xmax,ymax);
              g2.setFont(defaultFont);
               StringTokenizer q = new StringTokenizer(replystring, "\n");
              int m=q.countTokens();
               String sub="";int X=10;int Y=10;
               g2.setColor(Color.white);
               g2.drawString("t : T",X,Y);
              for(int s=0;s<m;s++){
                  Y=Y+14;
                  sub=q.nextToken(); 
                  g2.drawString(sub,X,Y);
                  if(Y>(ymax-2*14)){
                     X=X+90;
                      Y=10;
                     g2.drawString("t : T",X,Y);
                  }
              }
              // legenda 
              g2.drawString("t= "+time+"   T= "+freq,xsize,ysize-2);      
           }
           else
           {
              g2.clearRect(0,0,xmax,ymax+50);
              g2.setColor(Color.white);
              g2.fillRect(0,0,xmax,ymax);
              g2.setColor(Color.black);
              g2.drawString(ready_string,2*xsize,ymax-100);
           }
       }
    }

Here is the call graph for this function:

String VreemdeEend1.ReadApplet ( ) [inline]

Definition at line 213 of file VreemdeEend1.java.

                             {
       if(counter<max){return "error : not finished";}
       else
       {
           double totaltime=(double) (stop-begin)/1000;
           return totaltime+":"+max+"\n"+replystring;
        }
    }

Here is the call graph for this function:

void VreemdeEend1.run ( ) [inline]

Definition at line 211 of file VreemdeEend1.java.

{}
static int [] VreemdeEend1.Shuffle ( int[]  S) [inline, static]

Definition at line 99 of file VreemdeEend1.java.

                                        {
           int ll= S.length;

           for (int i=0;i<ll;i++){
              int r = (int) (Math.random() * (i+1));
              int swap = S[r];
              S[r] = S[i];
              S[i] = swap;
           }
           for(int i=0;i<ll;i++){
            //System.out.println(S[i]);
           }
        return S;
    }

Here is the caller graph for this function:

void VreemdeEend1.start ( ) [inline]

Definition at line 207 of file VreemdeEend1.java.

{}

Here is the caller graph for this function:

void VreemdeEend1.stop ( ) [inline]

Definition at line 209 of file VreemdeEend1.java.

{}

Here is the caller graph for this function:


Member Data Documentation

int VreemdeEend1.anders = 0 [package]

Definition at line 45 of file VreemdeEend1.java.

long VreemdeEend1.begin [package]

Definition at line 45 of file VreemdeEend1.java.

Graphics VreemdeEend1.canvas [package]

Definition at line 25 of file VreemdeEend1.java.

int VreemdeEend1.colors[][] = {{250,0,0},{0,250,0},{0,0,250},{250,250,0},{250,0,250},{0,250,250},{0,0,0},{255,255,255}} [package]

Definition at line 43 of file VreemdeEend1.java.

int VreemdeEend1.counter = 1 [package]

Definition at line 47 of file VreemdeEend1.java.

Font VreemdeEend1.defaultFont = new Font("Courier",0, 14) [package]

Definition at line 48 of file VreemdeEend1.java.

double VreemdeEend1.diff [package]

Definition at line 46 of file VreemdeEend1.java.

int VreemdeEend1.do_paint = 1 [package]

Definition at line 50 of file VreemdeEend1.java.

String VreemdeEend1.duration = "" [package]

Definition at line 47 of file VreemdeEend1.java.

int VreemdeEend1.dx [package]

Definition at line 46 of file VreemdeEend1.java.

int VreemdeEend1.dy [package]

Definition at line 46 of file VreemdeEend1.java.

int VreemdeEend1.first_try = 1 [package]

Definition at line 47 of file VreemdeEend1.java.

int VreemdeEend1.fout = 0 [package]

Definition at line 45 of file VreemdeEend1.java.

int VreemdeEend1.foutcounter = 1 [package]

Definition at line 46 of file VreemdeEend1.java.

String VreemdeEend1.freq = "attempts" [package]

Definition at line 50 of file VreemdeEend1.java.

int VreemdeEend1.goedzo = 0 [package]

Definition at line 45 of file VreemdeEend1.java.

int VreemdeEend1.kans[] = {0,1} [package]

Definition at line 30 of file VreemdeEend1.java.

int VreemdeEend1.keuze[] = {0,1,2,3} [package]

Definition at line 30 of file VreemdeEend1.java.

int VreemdeEend1.klaar [package]

Definition at line 45 of file VreemdeEend1.java.

int VreemdeEend1.kleuren[] = {0,1,2,3,4,5,6,7} [package]

Definition at line 30 of file VreemdeEend1.java.

int VreemdeEend1.max = 20 [package]

Definition at line 47 of file VreemdeEend1.java.

Definition at line 49 of file VreemdeEend1.java.

Definition at line 49 of file VreemdeEend1.java.

int VreemdeEend1.polies[] = {0,1,2,3} [package]

Definition at line 30 of file VreemdeEend1.java.

String VreemdeEend1.ready_string = "DONE" [package]

Definition at line 50 of file VreemdeEend1.java.

String VreemdeEend1.replystring = "" [package]

Definition at line 26 of file VreemdeEend1.java.

final long VreemdeEend1.serialVersionUID = 1L [static, private]

Definition at line 24 of file VreemdeEend1.java.

int VreemdeEend1.show_result = 1 [package]

Definition at line 50 of file VreemdeEend1.java.

long VreemdeEend1.start [package]

Definition at line 46 of file VreemdeEend1.java.

long VreemdeEend1.stop [package]

Definition at line 48 of file VreemdeEend1.java.

int VreemdeEend1.sx = 80 [package]

Definition at line 27 of file VreemdeEend1.java.

String VreemdeEend1.teller = "number" [package]

Definition at line 50 of file VreemdeEend1.java.

String VreemdeEend1.time = "time in seconds" [package]

Definition at line 49 of file VreemdeEend1.java.

Definition at line 48 of file VreemdeEend1.java.

int VreemdeEend1.xmax = 4*xsize [package]

Definition at line 29 of file VreemdeEend1.java.

int VreemdeEend1.xobject[][][] [package]
Initial value:
{
    {{10,70,30,70,10,10},{10,70,70,10,50,10},{10,70,70,40,10,10},{10,40,70,70,10,10}},
    {{10,70,70,10,10},{10,70,70,10,10},{10,70,70,10,10},{10,70,70,10,10}},
    {{40,70,10,40},{10,70,40,10},{10,70,10,10},{70,10,70,70}},
    {{10,70,10,10},{10,70,70,10},{10,70,70,10},{10,70,10,10}}
    }

Definition at line 31 of file VreemdeEend1.java.

int VreemdeEend1.xsize = 160 [package]

Definition at line 27 of file VreemdeEend1.java.

int VreemdeEend1.ymax = ysize [package]

Definition at line 29 of file VreemdeEend1.java.

int VreemdeEend1.yobject[][][] [package]
Initial value:
{
    {{10,10,40,70,70,10},{10,10,70,70,40,10},{10,10,70,40,70,10},{10,40,10,70,70,10}},
    {{10,10,70,70,10},{10,10,70,70,10},{10,10,70,70,10},{10,10,70,70,10}},
    {{10,70,70,10},{10,10,70,10},{10,40,70,10},{10,40,70,10}},
    {{10,70,70,10},{70,10,70,70},{10,10,70,10},{10,10,70,10}}
    }

Definition at line 37 of file VreemdeEend1.java.

int VreemdeEend1.ysize = 160 [package]

Definition at line 27 of file VreemdeEend1.java.


The documentation for this class was generated from the following file: