Demos and Usage of java.util.Random.nextFloat()


   1: import org.ariane.net.NetHost;
   2: import java.util.Random;
   3: import org.omg.PortableServer.POA;
   4:         ...
   5: 
   6: private Random generator;
   7: static private POA poa = null;
   8:         ...
   9:       super();
  10:       generator = new Random();
  11:       this.poa = poa;
  12:         ...
  13:       nbr++;
  14:       return generator.nextFloat();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Random;
   3: 
   4:         ...
   5:         final PLayer layer = getLayer();
   6:         Random r = new Random();
   7:         for (int i = 0; i < 1000; i++) {
   8:         ...
   9:             final PNode n = PPath.createRectangle(0, 0, 100, 80);    
  10:             n.translate(10000 * r.nextFloat(), 10000 * r.nextFloat());
  11:         ...
  12:             n.setPaint(new Color(r.nextFloat(), r.nextFloat(),r.nextFloat()));

View Full Code Here
   1: 
   2: import java.util.Random;
   3: import net.i2p.I2PAppContext;
   4:         ...
   5:     private class DummyRandomSource extends RandomSource {
   6:         private Random _prng;
   7:         public DummyRandomSource(I2PAppContext context) {
   8:         ...
   9:             super(context);
  10:             _prng = new Random();
  11:         }
  12:         ...
  13:         public double nextDouble() { return _prng.nextDouble(); }
  14:         public float nextFloat() { return _prng.nextFloat(); }

View Full Code Here
   1: 
   2: import java.util.Random;
   3: 
   4:         ...
   5: public class RandomUtils {
   6:     public static final Random RANDOM = new Random( System.currentTimeMillis() );
   7:     
   8:         ...
   9:     {
  10:         return RANDOM.nextFloat();
  11:     }

View Full Code Here
   1:     
   2:     Random rnd;
   3:     Vector<float[]> points;
   4:         ...
   5:     public void init() {
   6:         rnd = new Random();
   7:         points = new Vector<float[]>();
   8:         ...
   9:         sum = new float[20];
  10:         camx = rnd.nextFloat() *  80f - 10f;
  11:         ...
  12:         camy = rnd.nextFloat() *  40f + 20f;

View Full Code Here
   1:     Vector newBeasts = new Vector();
   2:     Random generator = new Random();
   3:     double cubeRootOfBeastNumber = 
   4:         ...
   5:       int x = 
   6:         (int) (generator.nextFloat() * xExtent);
   7:       if(x > xExtent - Beast.GSIZE) 
   8:         ...
   9:       int y = 
  10:         (int) (generator.nextFloat() * yExtent);
  11:       if(y > yExtent - Beast.GSIZE) 
  12:         ...
  13:       float direction = (float)(
  14:         generator.nextFloat() * 2 * Math.PI);

View Full Code Here
   1:   }
   2:   private static Random r = new Random();
   3:   public static class RandBooleanGenerator 
   4:         ...
   5:   implements FloatGenerator {
   6:     public float next() { return r.nextFloat(); }
   7:   }
   8:   public static class RandDoubleGenerator 
   9:   implements DoubleGenerator {

View Full Code Here
   1:   }
   2:   private static Random r = new Random();
   3:   public static class RandBooleanGenerator 
   4:         ...
   5:   implements FloatGenerator {
   6:     public float next() { return r.nextFloat(); }
   7:   }
   8:   public static class RandDoubleGenerator 
   9:   implements DoubleGenerator {

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.Random;
   3: 
   4:         ...
   5:         
   6:         Random r = new Random();
   7:         for (int i = 0; i < NUMBER_NODES; i++) {
   8:         ...
   9:             nodes[i].translate(r.nextFloat() * 300, r.nextFloat() * 300);
  10:         }        
  11:         ...
  12:             nodes[i] = new PNode();
  13:             nodes[i].setBounds(1000 * r.nextFloat(), 1000 * r.nextFloat(), 100, 80);

View Full Code Here
   1:     private boolean secure = false;
   2:     private Random random = null;
   3:     private SecureRandom secrandom = null;
   4:         ...
   5:     private final float getFloat() {
   6:         if (random == null)
   7:         ...
   8:             return secrandom.nextFloat();
   9:         else
  10:         ...
  11:             return random.nextFloat();

View Full Code Here
   1: import java.util.LinkedList;
   2: import java.util.Random;
   3: import java.util.Set;
   4:         ...
   5: 
   6:     private static Random _rand;
   7: 
   8:         ...
   9:         _seed = System.currentTimeMillis();
  10:         _rand = new Random(_seed);
  11:     }
  12:         ...
  13:     public static float getRandom(float f) {
  14:         return _rand.nextFloat();

View Full Code Here
   1: import java.util.List;
   2: import java.util.Random;
   3: import java.security.MessageDigest;
   4:         ...
   5:     int    n = getNumberOfClusterCandidates();
   6:     Random r = new Random(System.currentTimeMillis());
   7: 
   8:         ...
   9: 
  10:     cluster.setRightAscension(360.0 * r.nextFloat());
  11:         ...
  12:     cluster.setDeclination(-90.0 + 180.0 * r.nextFloat());

View Full Code Here