Back to index

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

List of all members.

Public Member Functions

 dessin (int bars, int delay, int n)
void update (Graphics g)
void paint (Graphics g)

Package Attributes

int bars
int n
int delay
int boucle
int L
int H
int Ls2
int Hs4
int Hb
int Hb1
Random rnd
int[] classes
controles C
gtab gt
Image img
Graphics g

Private Member Functions

void ent (Graphics g)

Detailed Description

Definition at line 69 of file ballenbak.java.


Constructor & Destructor Documentation

ballenbak.dessin.dessin ( int  bars,
int  delay,
int  n 
) [inline]

Definition at line 80 of file ballenbak.java.

  { this.bars = bars ;
    this.delay = delay ;
    this.n = n ;
    classes = new int [bars + 1] ;
    gt = new gtab () ;
    gt.maj (classes.length, classes) ;
    rnd = new Random () ;
  }

Here is the call graph for this function:


Member Function Documentation

void ballenbak.dessin.ent ( Graphics  g) [inline, private]

Definition at line 92 of file ballenbak.java.

  { g.setColor (Color.white) ;
    g.fillRect (1, 1, L, Hs4 - 10) ;
    g.setColor (Color.black) ;
    g.drawLine (Ls2 - Hs4, 1, Ls2 - 10, Hs4 - 10) ;
    g.drawLine (Ls2 + 10, Hs4 - 10,  Ls2 + Hs4, 1) ;
    g.setColor (Color.blue) ;
    for (int i = 0 ; i < n ; i ++)
    { int x = (int)(rnd.nextDouble () * (Math.max (0, Hs4 - 15))) ;
      int y = (int)(rnd.nextDouble () * (Math.max (0, Hs4 - x - 15))) ;
      x *= (int)(rnd.nextDouble () * 2) * 2 - 1 ;
      g.fillOval (Ls2 + x, y, 7, 7) ;
    }
    g.setColor (Color.black) ;
    g.drawLine (0, 0, L, 0) ;
  }

Here is the caller graph for this function:

void ballenbak.dessin.paint ( Graphics  g) [inline]

Definition at line 112 of file ballenbak.java.

  { // if (img == null)
    Font f = new Font ("Arial", Font.BOLD, 16) ;
  g.setFont (f) ;
    { L = getSize().width ;
      H = getSize().height ;
//      img = createImage (L, H) ;
//      g = img.getGraphics () ;
      L -= 2 ; H -= 2 ;
      Ls2 = L / 2 ;
      Hs4 = H / 4 ;
      Hb = H - 50 ;
    }
    g.setColor (Color.black) ;
    g.drawRect (0, 0, L + 1, H + 1) ;
    g.setColor (Color.white) ;
    g.fillRect (1, 1, L, H) ;
// dessin de l'entonnoir
    ent (g) ;
// dessin des clous
    g.setColor (Color.green) ;
    int pas = (Hb - Hs4) / bars ;
    int dec = 0 ;
    int x = Ls2 - 2 ;
    int x1 = x ;
    int y = Hs4 - 2 ;
    for (int i = 0 ; i < bars ; i ++)
    { while (x1 - 3 - dec > 0)
      { g.fillOval (x, y, 5, 5) ;
        g.fillOval (x1, y, 5, 5) ;
        x += pas ;
        x1 -= pas ;
      }
      y += pas ;
      if (dec == 0) dec = pas / 2 ; else dec = 0 ;
      x = Ls2 - 2 + dec ;
      x1 = x ;
    }
// dessin des bacs
    Hb1 = y ;
    g.setColor (Color.black) ;
    g.drawLine (1, H, L, H) ;
    int dec1 = 0 ;
    if (dec == 0) dec1 = pas / 2 ;
    x = Ls2 + dec1 ;
    x1 = x ;
    int ind = bars / 2 ;
    int ind1 = ind ;
    while (x1 + pas > 0)
    { g.setColor (Color.black) ;
      g.drawLine (x, H, x, Hb1) ;
      g.drawLine (x1, H, x1, Hb1) ;
      g.setColor (Color.blue) ;
      if ((ind >= 0) && (ind < classes.length))
      { int ci = classes [ind] ;
        if (ci > 0) g.fillRect (x - pas, H - ci, pas, ci) ;
      }
      if ((ind1 >= 0) && (ind1 < classes.length))
      { int ci = classes [ind1] ;
        if (ci > 0) g.fillRect (x1 - pas, H - ci, pas, ci) ;
      }
      result=classes;
      x += pas ;
      x1 -= pas ;
      ind ++ ;
      ind1 -- ;
    }
//   g1.drawImage (img, 0, 0, this) ;
// dessin de la bille qui tombe
    while (boucle > 0)
    { boucle -- ;
      n -- ;
      ent (g) ;
      C.tn.setText (Integer.toString (n)) ;
      dec = 0 ;
      int xp = 10000 ;
      int yp = 10000 ;
      x = Ls2 - 3 ;
      y = Hs4 - pas / 2 - 3 ;
      ind = 0 ;
      for (int i = 0 ; i < bars ; i ++)
      { boolean brnd = (rnd.nextDouble () >= 0.5) ;
        if (brnd) x += pas / 2 ; else x -= pas / 2 ;
        if (brnd) ind ++ ;
        for (int k = 0 ; k < pas ; k ++)
        { g.setColor (Color.white) ;
          g.fillOval (xp, yp, 7, 7) ;
          g.setColor (Color.blue) ;
          g.fillOval (x, y, 7, 7) ;
//          g1.drawImage (img, 0, 0, this) ;
          xp = x ; yp = y ++ ;
          if (delay > 0)
          { try { Thread.sleep (delay); }
            catch (InterruptedException e) {}
          }
        }
        if (i == 0)
        { g.setColor (Color.black) ;
          g.drawLine (Ls2 - Hs4, 1, Ls2 - 10, Hs4 - 10) ;
          g.drawLine (Ls2 + 10, Hs4 - 10,  Ls2 + Hs4, 1) ;
//          g1.drawImage (img, 0, 0, this) ;
        }
      }
      g.setColor (Color.white) ;
      g.fillOval (xp, yp, 7, 7) ;
      if ((ind >= 0) && (ind < classes.length)) classes [ind] ++ ;
    x = Ls2 + dec1 ;
    x1 = x ;
    ind = bars / 2 ;
    ind1 = ind ;
    while (x1 + pas > 0)
    { g.setColor (Color.black) ;
      g.drawLine (x, H, x, Hb1) ;
      g.drawLine (x1, H, x1, Hb1) ;
      g.setColor (Color.blue) ;
      if ((ind >= 0) && (ind < classes.length))
      { int ci = classes [ind] ;
        if (ci > 0) g.fillRect (x - pas, H - ci, pas, ci) ;
      }
      if ((ind1 >= 0) && (ind1 < classes.length))
      { int ci = classes [ind1] ;
        if (ci > 0) g.fillRect (x1 - pas, H - ci, pas, ci) ;
      }
       x += pas ;
      x1 -= pas ;
      ind ++ ;
      ind1 -- ;
    }
    
    int cnt=0;
    g.setColor (Color.black) ;
    for(int p=0;p<pas;p++){
       g.drawString(" "+cnt+" ",p*pas-pas/2,H);
       cnt++;
    }
//    g1.drawImage (img, 0, 0, this) ;
// 
    gt.maj (bars + 1, classes) ;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void ballenbak.dessin.update ( Graphics  g) [inline]

Definition at line 109 of file ballenbak.java.

  { paint (g) ; }

Here is the call graph for this function:


Member Data Documentation

int ballenbak.dessin.bars [package]

Definition at line 71 of file ballenbak.java.

int ballenbak.dessin.boucle [package]

Definition at line 71 of file ballenbak.java.

Definition at line 75 of file ballenbak.java.

int [] ballenbak.dessin.classes [package]

Definition at line 74 of file ballenbak.java.

int ballenbak.dessin.delay [package]

Definition at line 71 of file ballenbak.java.

Graphics ballenbak.dessin.g [package]

Definition at line 78 of file ballenbak.java.

Definition at line 76 of file ballenbak.java.

int ballenbak.dessin.H [package]

Definition at line 72 of file ballenbak.java.

int ballenbak.dessin.Hb [package]

Definition at line 72 of file ballenbak.java.

int ballenbak.dessin.Hb1 [package]

Definition at line 72 of file ballenbak.java.

int ballenbak.dessin.Hs4 [package]

Definition at line 72 of file ballenbak.java.

Image ballenbak.dessin.img [package]

Definition at line 77 of file ballenbak.java.

int ballenbak.dessin.L [package]

Definition at line 72 of file ballenbak.java.

int ballenbak.dessin.Ls2 [package]

Definition at line 72 of file ballenbak.java.

int ballenbak.dessin.n [package]

Definition at line 71 of file ballenbak.java.

Random ballenbak.dessin.rnd [package]

Definition at line 73 of file ballenbak.java.


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