Ejemplo n.º 1
0
  private void calculateCelestialBodyDescriptors() {
    List<CelestialBodyType> celestialBodies = skyDescriptor.getCelestialBodies();
    // Find the most suitable sun and moon. This is typically the largest sun in the list of
    // celestial bodies.
    int sunidx = -1;
    int bestsun = 0;
    int moonidx = -1;
    int bestmoon = 0;
    for (int i = 0; i < celestialBodies.size(); i++) {
      CelestialBodyType type = celestialBodies.get(i);
      if (type.getGoodSunFactor() > bestsun) {
        bestsun = type.getGoodSunFactor();
        sunidx = i;
      }
      if (type.getGoodMoonFactor() > bestmoon) {
        bestmoon = type.getGoodMoonFactor();
        moonidx = i;
      }
    }

    // Always the same random series.
    Random random = new Random(123);
    random.nextFloat();
    celestialBodyDescriptors = new ArrayList<CelestialBodyDescriptor>();
    for (int i = 0; i < celestialBodies.size(); i++) {
      CelestialBodyType type = celestialBodies.get(i);
      celestialBodyDescriptors.add(new CelestialBodyDescriptor(type, i == sunidx || i == moonidx));
    }
  }