Back to index

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

List of all members.

Public Member Functions

void init ()
String ReadApplet ()
void showFrame ()
void stop ()
void run ()
void toggleStart ()
void actionPerformed (ActionEvent ae)
void stateChanged (ChangeEvent ce)
void windowActivated (WindowEvent we)
void windowClosed (WindowEvent we)
void windowClosing (WindowEvent we)
void windowDeactivated (WindowEvent we)
void windowDeiconified (WindowEvent we)
void windowIconified (WindowEvent we)
void windowOpened (WindowEvent we)
String getAppletInfo ()

Package Attributes

JLabel count
JLabel mean
JLabel variance
JLabel current_bin
JLabel current_bin_count
JLabel current_bin_prob
JLabel confidence
JButton start
JButton clear
JButton close
PlinkoBoard plinkoboard
Thread thread
boolean active = false
int countdown = 0
JFrame frame
SplashPanel splash
boolean wims_exercise = false
int bins_num = 11
int speed = 1
int total_balls = 100000
double chance = 0.5
int frame_x = 600
int frame_y = 600
int font_size = 14
String title = "Binomial Distribution"
String click_text = "CLICK ANYWHERE TO BEGIN"
String start_text = "START"
String stop_text = "STOP"
String clear_text = "CLEAR"
String close_text = "CLOSE"
String label_count = "Count: "
String label_mean = "Mean: "
String label_variance = "Variance: "
String label_bin = "Bin: "
String label_bins = "Bins: "
String label_speed = "Speed: "
String label_probability = "Probability: "
String label_bin_count = "Bin Count: "
String label_bin_probability = "Bin Probability: "
String label_confidence = "Confidence Interval: "
String some_text = " % of the balls landed in bin "
String through = " through "
String label_controls = " Controls "
String label_statistics = "Statistics"

Static Package Attributes

static JSpinner bins
static JSpinner rate
static JSpinner prob
static AudioClip click
static AudioClip ping

Detailed Description

Definition at line 10 of file Plinko.java.


Member Function Documentation

void Plinko.actionPerformed ( ActionEvent  ae) [inline]

Definition at line 278 of file Plinko.java.

                                                    {
           Object obj = ae.getSource();
           if (obj == start){toggleStart();plinkoboard.requestFocus();}
           if( obj == clear ){
              if ( plinkoboard.FIRST_BALL == null ){plinkoboard.newHist();} 
              else 
              {
                  plinkoboard.FIRST_BALL = null;
                  //plinkoboard.BALL_COUNT = 0;
                  if ( !active ){bins.setEnabled( true );}
              }
                  plinkoboard.repaint();plinkoboard.requestFocus();
           }
           if(obj == close){stop();}
       }

Here is the call graph for this function:

String Plinko.getAppletInfo ( ) [inline]

Definition at line 331 of file Plinko.java.

                                    { 
           return "Written by Dr. P. Little \n http://www.math.psu.edu/dlittle/java/probability/plinko/index.html" ; 
       }  
void Plinko.init ( ) [inline]

Definition at line 62 of file Plinko.java.

                      {
       // jm.evers: introducing a few Applet params , used for tailoring the exercise.
       String s=getParameter("wims_exercise");
       if(s!=null){
           if(s.equalsIgnoreCase("yes") || s.equals("1")){
              wims_exercise = true;
              s=getParameter("balls");
              if(s!=null && s.length()>0){total_balls = Integer.parseInt(s, 10);}
              s=getParameter("chance");
              if(s!=null && s.length()>0){chance = Double.parseDouble(s);}
              s=getParameter("bins");
              if(s!=null && s.length()>0){bins_num = Integer.parseInt(s, 10);}
              s=getParameter("speed");
              if(s!=null && s.length()>0){speed = Integer.parseInt(s, 10);}
              s=getParameter("xsize");
              if(s!=null && s.length()>0){frame_x = Integer.parseInt(s, 10);}
              s=getParameter("ysize");
              if(s!=null && s.length()>0){frame_y = Integer.parseInt(s, 10);}
              s=getParameter("title");
              if(s!=null && s.length()>0){title=s;}
              s=getParameter("font_size");
              if(s!=null && s.length()>0){font_size = Integer.parseInt(s, 10);}

           }
       }
       s=getParameter("language");
       if(s!=null && s.length()>0){
           if(s.equalsIgnoreCase("nl")){
              click_text="KLIK HIER OM TE BEGINNEN";
              start_text="START";
              stop_text="STOP";
              clear_text="WISSEN";
              close_text="SLUITEN";
              label_count="Aantal: ";
              label_mean="Gemiddeld: ";
              label_variance="Variantie: ";
              label_bin="Bakje: ";
              label_bins="Bakjes: ";
              label_speed="Snelheid: ";
              label_bin_count="Ballen/bakje: ";
              label_probability="Kans: ";    
              label_bin_probability="Kans per bakje: ";
              label_confidence="Betrouwbaarheids interval: ";
              some_text=" % van de ballen in bakje: ";
              through=" t/m ";
              String label_controls=" Menu ";
              String label_statistics="Statistiek";
           }
           if(s.equalsIgnoreCase("fr")){
              click_text="CLIQUEZ ICI";
              start_text="COMMENCER";
              stop_text="PAUSE";
              clear_text="EFFACER";
              close_text="FERMER";
              label_count="Quantit\u00E9 : ";
              label_mean="Moyenne : ";
              label_variance="Variance: ";
              label_bin="Panier : ";
              label_bins="Paniers : ";
              label_speed="Vitesse : ";
              label_bin_count="Balles dans ce panier : ";
              label_bin_probability="% de balles dans ce panier : ";
              label_probability="Probabilit\u00E9 : ";    
              label_confidence="Intervalle de confiance : ";
              some_text=" % de balles dans le panier ";
              through=" through ";
              label_controls="Menu";
              label_statistics="Statistiques";
           }
           if(s.equalsIgnoreCase("de")){
              click_text="Klicken Sie hier um zu starten";
              start_text="START";
              stop_text="STOP";
              clear_text="CLEAR";
              close_text="CLOSE";
              label_count="Zahl: ";
              label_mean="Mean: ";
              label_variance="Variance: ";
              label_bin="Behälter: ";
              label_bins="Behälter: ";
              label_speed="Geschwindigkeit : ";
              label_bin_count="Zahl/Behälter: ";
              label_bin_probability="Wahrscheinlichkeit in Behälter: ";
              label_probability="Wahrscheinlichkeit: ";    
              label_confidence="Wahrscheinlichkeits Intervall: ";
              some_text=" % der Kugeln fällt in Behälter ";
              through=" bis ";
              String label_controls=" Menu ";
              String label_statistics="Statistik";
           }
       }
       setBackground(Color.white);
       frame = new JFrame();
       frame.setVisible(false);
       frame.setSize(frame_x, frame_y);
       frame.setLocation(0,0);
       frame.setTitle( title );
       Font font = new Font( "Helvetica", Font.BOLD, font_size );
       GridBagLayout gridbaglayout = new GridBagLayout();
       GridBagConstraints constraints = new GridBagConstraints();
       constraints.ipadx = 5;
       constraints.ipady = 5;
       constraints.insets = new Insets( 1,1,1,1 );
       constraints.anchor = GridBagConstraints.CENTER;
       constraints.fill = GridBagConstraints.NONE;
       constraints.weightx = 1.0;
       JPanel controls_west = new JPanel(  );
       JLabel label = new JLabel( label_bins,JLabel.LEFT );
       controls_west.add( label );
       bins = new JSpinner( new SpinnerNumberModel(bins_num,2,101,1) );
       controls_west.add( bins );
       label = new JLabel( label_probability,JLabel.LEFT );
  controls_west.add( label );
       prob = new JSpinner( new SpinnerNumberModel(0.50,0.00,100,0.01) );
       SpinnerNumberModel model = (SpinnerNumberModel)prob.getModel();
       model.setMaximum( new Double(1.00) );
       controls_west.add( prob );
       label = new JLabel( label_speed,JLabel.LEFT );
       controls_west.add( label );
       rate = new JSpinner( new SpinnerNumberModel(1,1,10,1) );
       controls_west.add( rate );
       JPanel controls_east = new JPanel();
       controls_east.add( start = new JButton( start_text ) );
       start.setDefaultCapable( true );
       frame.getRootPane().setDefaultButton( start );
       controls_east.add( clear = new JButton( clear_text ) );
       controls_east.add( close = new JButton( close_text ) );
       close.setDefaultCapable( false );  
       JPanel controls = new JPanel( new BorderLayout() );
       controls.add( "East", controls_east );
       JPanel statistics_center = new JPanel( new GridLayout(2,3) );
       statistics_center.add( count = new JLabel( label_count ) );
       statistics_center.add( mean = new JLabel( label_mean ) );
       statistics_center.add( variance = new JLabel( label_variance ) );
       statistics_center.add( current_bin = new JLabel( label_bin ) );
       statistics_center.add( current_bin_count = new JLabel(label_bin_count ) );
       statistics_center.add( current_bin_prob = new JLabel( label_bin_probability ) );
       JPanel statistics_south = new JPanel( new GridLayout(1,1) );
       statistics_south.add( confidence = new JLabel( label_confidence ) );
       JPanel statistics = new JPanel( new BorderLayout() );
       if(wims_exercise == false){
           // hmmm...these controls are handed over to applet params...if applet is part of an interactive exercise.
           controls.add( "West", controls_west );
           controls.setBorder( BorderFactory.createTitledBorder( controls.getBorder(), label_controls, TitledBorder.LEFT, TitledBorder.TOP, new Font( "Helvetica", Font.BOLD, font_size) ) );
       }
       statistics.add( "Center", statistics_center );
       statistics.add( "South", statistics_south );
       statistics.setBorder( BorderFactory.createTitledBorder( statistics.getBorder(), label_statistics, TitledBorder.LEFT, TitledBorder.TOP, new Font( "Helvetica", Font.BOLD, font_size) ) );

       JPanel south = new JPanel( new BorderLayout() );
       south.add( "Center", statistics );
       JLabel statusbar = new JLabel("");
       statusbar.setPreferredSize( new Dimension(15,15) );
       south.add( "South", statusbar );
       Container contentpane = frame.getContentPane();
       contentpane.setLayout(new BorderLayout(10,10));
       contentpane.add( "Center", plinkoboard = new PlinkoBoard(this) ); 
       contentpane.add( "North", controls );
       contentpane.add( "South", south );
       start.addActionListener( this );
       clear.addActionListener( this );
       close.addActionListener( this );
       bins.addChangeListener( this );
       rate.addChangeListener( this );
       prob.addChangeListener( this );

       plinkoboard.requestFocus();
       frame.addWindowListener( this );
       getContentPane().add( splash = new SplashPanel( this ) );
       click = getAudioClip( getCodeBase(), "sounds/click.au" );
       ping = getAudioClip( getCodeBase(), "sounds/ping.au" );
    }
String Plinko.ReadApplet ( ) [inline]

Definition at line 237 of file Plinko.java.

                                 {
           String s=plinkoboard.ReadData();
           return s;                                                                                                                      
        }                                                                                                                                  

Here is the call graph for this function:

void Plinko.run ( ) [inline]

Definition at line 251 of file Plinko.java.

                        {          
           //while ( active  || countdown > 0 ){
           while ( active ){
              plinkoboard.dropBall( false );
              //if ( countdown > 0 ) countdown--;
              try {
              //if ( countdown < 1)
                  Thread.sleep(105 - 10*((Integer)rate.getValue()).intValue());
              } catch (InterruptedException e){}
           }
       }

Here is the call graph for this function:

void Plinko.showFrame ( ) [inline]

Definition at line 242 of file Plinko.java.

                              {
              frame.setVisible( true );
       }

Here is the caller graph for this function:

void Plinko.stateChanged ( ChangeEvent  ce) [inline]

Definition at line 294 of file Plinko.java.

                                                 {
           Object obj = ce.getSource();
           if ( obj == bins ){
              count.setText( "0" );
              plinkoboard.setup( );
              plinkoboard.newHist( );
              plinkoboard.drawBackground();
           } else if ( obj == rate ){
           } else if ( obj == prob ){
              plinkoboard.updatePercent();
              plinkoboard.repaint();
           }
       }

Here is the call graph for this function:

void Plinko.stop ( ) [inline]

Definition at line 246 of file Plinko.java.

                         {
              frame.setVisible( false );
              splash.start();
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void Plinko.toggleStart ( ) [inline]

Definition at line 263 of file Plinko.java.

                                {
           if ( active ){
              active = false;
              start.setText(start_text);
           } 
           else 
           {
              active = true;
              bins.setEnabled( false );
              thread = new Thread(this);
              thread.start();
              start.setText(stop_text);
           }
       }

Here is the caller graph for this function:

void Plinko.windowActivated ( WindowEvent  we) [inline]

Definition at line 308 of file Plinko.java.

                                                    {
           //splash.start();
       }
void Plinko.windowClosed ( WindowEvent  we) [inline]

Definition at line 313 of file Plinko.java.

                                                 {
              //splash.start();
       }
void Plinko.windowClosing ( WindowEvent  we) [inline]

Definition at line 317 of file Plinko.java.

                                                  {
              //splash.start();
       }
void Plinko.windowDeactivated ( WindowEvent  we) [inline]

Definition at line 321 of file Plinko.java.

                                                      {
              //splash.start();
       }
void Plinko.windowDeiconified ( WindowEvent  we) [inline]

Definition at line 325 of file Plinko.java.

{}
void Plinko.windowIconified ( WindowEvent  we) [inline]

Definition at line 327 of file Plinko.java.

{}
void Plinko.windowOpened ( WindowEvent  we) [inline]

Definition at line 329 of file Plinko.java.

{}

Member Data Documentation

Definition at line 26 of file Plinko.java.

JSpinner Plinko.bins [static, package]

Definition at line 11 of file Plinko.java.

int Plinko.bins_num = 11 [package]

Definition at line 34 of file Plinko.java.

double Plinko.chance = 0.5 [package]

Definition at line 37 of file Plinko.java.

JButton Plinko.clear [package]

Definition at line 22 of file Plinko.java.

String Plinko.clear_text = "CLEAR" [package]

Definition at line 45 of file Plinko.java.

AudioClip Plinko.click [static, package]

Definition at line 30 of file Plinko.java.

String Plinko.click_text = "CLICK ANYWHERE TO BEGIN" [package]

Definition at line 42 of file Plinko.java.

JButton Plinko.close [package]

Definition at line 23 of file Plinko.java.

String Plinko.close_text = "CLOSE" [package]

Definition at line 46 of file Plinko.java.

JLabel Plinko.confidence [package]

Definition at line 20 of file Plinko.java.

JLabel Plinko.count [package]

Definition at line 14 of file Plinko.java.

int Plinko.countdown = 0 [package]

Definition at line 27 of file Plinko.java.

JLabel Plinko.current_bin [package]

Definition at line 17 of file Plinko.java.

JLabel Plinko.current_bin_count [package]

Definition at line 18 of file Plinko.java.

JLabel Plinko.current_bin_prob [package]

Definition at line 19 of file Plinko.java.

int Plinko.font_size = 14 [package]

Definition at line 40 of file Plinko.java.

JFrame Plinko.frame [package]

Definition at line 28 of file Plinko.java.

int Plinko.frame_x = 600 [package]

Definition at line 38 of file Plinko.java.

int Plinko.frame_y = 600 [package]

Definition at line 39 of file Plinko.java.

String Plinko.label_bin = "Bin: " [package]

Definition at line 50 of file Plinko.java.

String Plinko.label_bin_count = "Bin Count: " [package]

Definition at line 54 of file Plinko.java.

String Plinko.label_bin_probability = "Bin Probability: " [package]

Definition at line 55 of file Plinko.java.

String Plinko.label_bins = "Bins: " [package]

Definition at line 51 of file Plinko.java.

String Plinko.label_confidence = "Confidence Interval: " [package]

Definition at line 56 of file Plinko.java.

String Plinko.label_controls = " Controls " [package]

Definition at line 59 of file Plinko.java.

String Plinko.label_count = "Count: " [package]

Definition at line 47 of file Plinko.java.

String Plinko.label_mean = "Mean: " [package]

Definition at line 48 of file Plinko.java.

String Plinko.label_probability = "Probability: " [package]

Definition at line 53 of file Plinko.java.

String Plinko.label_speed = "Speed: " [package]

Definition at line 52 of file Plinko.java.

String Plinko.label_statistics = "Statistics" [package]

Definition at line 60 of file Plinko.java.

String Plinko.label_variance = "Variance: " [package]

Definition at line 49 of file Plinko.java.

JLabel Plinko.mean [package]

Definition at line 15 of file Plinko.java.

AudioClip Plinko.ping [static, package]

Definition at line 31 of file Plinko.java.

Definition at line 24 of file Plinko.java.

JSpinner Plinko.prob [static, package]

Definition at line 13 of file Plinko.java.

JSpinner Plinko.rate [static, package]

Definition at line 12 of file Plinko.java.

String Plinko.some_text = " % of the balls landed in bin " [package]

Definition at line 57 of file Plinko.java.

int Plinko.speed = 1 [package]

Definition at line 35 of file Plinko.java.

Definition at line 29 of file Plinko.java.

JButton Plinko.start [package]

Definition at line 21 of file Plinko.java.

String Plinko.start_text = "START" [package]

Definition at line 43 of file Plinko.java.

String Plinko.stop_text = "STOP" [package]

Definition at line 44 of file Plinko.java.

Thread Plinko.thread [package]

Definition at line 25 of file Plinko.java.

String Plinko.through = " through " [package]

Definition at line 58 of file Plinko.java.

String Plinko.title = "Binomial Distribution" [package]

Definition at line 41 of file Plinko.java.

int Plinko.total_balls = 100000 [package]

Definition at line 36 of file Plinko.java.

JLabel Plinko.variance [package]

Definition at line 16 of file Plinko.java.

Definition at line 33 of file Plinko.java.


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