Ejemplo n.º 1
0
  /** Produce a new image. */
  protected synchronized void outputNewImage() {
    switch (layoutPolicy) {
      case ComputedAtNewImage:
        if (layout != null) layout.compute();
        break;
    }

    if (resolution.getWidth() != image.getWidth() || resolution.getHeight() != image.getHeight())
      initImage();

    if (gg.getNodeCount() > 0) {
      gg.computeBounds();

      Point3 lo = gg.getMinPos();
      Point3 hi = gg.getMaxPos();

      renderer.setBounds(lo.x, lo.y, lo.z, hi.x, hi.y, hi.z);
      renderer.render(g2d, resolution.getWidth(), resolution.getHeight());
    }

    for (PostRenderer action : postRenderers) action.render(g2d);

    image.flush();

    try {
      File out = new File(String.format("%s%06d.png", filePrefix, counter++));

      if (!out.getParentFile().exists()) out.getParentFile().mkdirs();

      ImageIO.write(image, outputType.name(), out);

      printProgress();
    } catch (IOException e) {
      // ?
    }
  }