public StarField(final int aNumberOfStars, final CharGenerator aStarsGenerator) { final int intensitySteps = aStarsGenerator.charsPerRow * aStarsGenerator.charsPerColumn; // #if DEBUG Assert.isTrue("stars generator should have at least one frame", intensitySteps > 0); // #endif myStars = new CharData[intensitySteps]; for (int idx = 0; idx < myStars.length; idx++) { myStars[idx] = aStarsGenerator.getCharData(idx); } myNumberOfStars = aNumberOfStars; myStarsX = new float[myNumberOfStars]; myStarsY = new float[myNumberOfStars]; myStarsZ = new float[myNumberOfStars]; final Random random = new Random(); for (int idx = 0; idx < myNumberOfStars; idx++) { myStarsX[idx] = random.nextFloat(UNIVERSE_HALF); myStarsY[idx] = random.nextFloat(UNIVERSE_HALF); myStarsZ[idx] = random.nextFloat(UNIVERSE_HALF); } setAnimatedAxes(true, true, true); }
public void useSource(CharGenerator dsource) { // Set up the initial key String key = ""; for (int i = 0; i < ngram; i++) { if (!dsource.hasNextChar()) return; key = key + alphabet[dsource.nextChar()]; } while (true) { addKey(key); if (!dsource.hasNextChar()) break; key = key + alphabet[dsource.nextChar()]; key = key.substring(1); } }