Exemple #1
0
  /**
   * Runs a sample test procedure
   *
   * @param robot the robot attached to the screen device
   */
  public static void runTest(Robot robot) {
    // simulate a space bar press
    robot.keyPress(' ');
    robot.keyRelease(' ');

    // simulate a tab key followed by a space
    robot.delay(2000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.keyRelease(KeyEvent.VK_TAB);
    robot.keyPress(' ');
    robot.keyRelease(' ');

    // simulate a mouse click over the rightmost button
    robot.delay(2000);
    robot.mouseMove(200, 50);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    // capture the screen and show the resulting image
    robot.delay(2000);
    BufferedImage image = robot.createScreenCapture(new Rectangle(0, 0, 400, 300));

    ImageFrame frame = new ImageFrame(image);
    frame.setVisible(true);
  }
  public void render(File file) {
    w = new World<RGBColor>();
    builder = new WorldBuilder<RGBColor>(w);
    builder.build(file);
    w.initialize();

    vp = w.getViewPlane();
    imf = new ImageFrame(vp.resolution, false, null);

    if (w.isDynamic()) {

      //            w.render(imf);
      //            imf.repaint();
      //            imf.finish();

      w.set();
      while (w.hasNext()) {
        w.render(imf);
        imf.repaint();
        w.step();
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {}
            });
      }
      imf.finish();
    } else {
      w.render(imf);

      String fileName2 = GuiUtilities.getOutputPngFileName(file.getName());
      PngFilm png = new PngFilm(fileName2, imf.getFilm());
      png.finish();

      imf.repaint();
      imf.finish();
    }
  }