Example #1
0
 public void draw() {
   background(0);
   environment.run();
   environment.update(false);
   pheromones.fade(0.99f);
   pheromones.render(2, 50, 1, this);
   // canvas.drawTrails(environment.pop, 1, 255);
 }
Example #2
0
 public void addParticles() {
   for (int i = 0; i < 100; i++) {
     environment.addAgent(
         new VoxParticle(
             new Vec3D(random(numX * 2), random(numY * 2), random(numZ * 2)), false, pheromones));
   }
 }
Example #3
0
 private Properties getProperties() throws IOException {
   Properties p;
   File f;
   if ((f = Environment.getPropertiesFile(FManager.class)).exists()) {
     try (InputStream is = new FileInputStream(f)) {
       p = new Properties();
       p.load(is);
       is.close();
     }
   } else {
     throw new IOException("Cannot load properties.");
   }
   return p;
 }
Example #4
0
  public void saveSettings(Map<String, String> keyValMap, boolean autoLoad) throws IOException {
    Properties p;
    File f;
    if ((f = Environment.getPropertiesFile(FManager.class)).exists()) {
      this.activeFingerprintFileMap.clear();
      try (InputStream is = new FileInputStream(f)) {
        p = new Properties();
        // p.load(is);
        keyValMap
            .entrySet()
            .stream()
            .forEach(
                pair -> {
                  p.setProperty(pair.getKey(), pair.getValue());
                  this.activeFingerprintFileMap.put(
                      new File(pair.getKey()), Boolean.valueOf(pair.getValue()));
                });

        p.setProperty(AUTOLOAD, autoLoad + "");

        // is.close();
        FileOutputStream fos = new FileOutputStream(f);
        p.store(
            fos,
            "Updated "
                + DateFormatUtils.format(
                    System.currentTimeMillis(), ISO_EXTENDED_FORMAT_PATTERN, Locale.ENGLISH));
        try {
          fos.close();
        } catch (Exception ex) {
        }
      }
    } else {
      throw new IOException("Cannot store properties.");
    }
  }
Example #5
0
 public static void saveSetting(String key, String val) throws IOException {
   Properties p;
   File f;
   if ((f = Environment.getPropertiesFile(FManager.class)).exists()) {
     try (InputStream is = new FileInputStream(f)) {
       p = new Properties();
       p.load(is);
       p.setProperty(key, val);
       is.close();
       FileOutputStream fos = new FileOutputStream(f);
       p.store(
           fos,
           "Updated "
               + DateFormatUtils.format(
                   System.currentTimeMillis(), ISO_EXTENDED_FORMAT_PATTERN, Locale.ENGLISH));
       try {
         fos.close();
       } catch (Exception ex) {
       }
     }
   } else {
     throw new IOException("Cannot store properties.");
   }
 }