Esempio n. 1
0
  public static void randomToolActions(int numStrokes, boolean brushOnly) {
    Composition comp = ImageComponents.getActiveComp().get();
    Random random = new Random();

    if (comp != null) {
      int canvasWidth = comp.getCanvasWidth();
      int canvasHeight = comp.getCanvasHeight();

      ProgressMonitor progressMonitor = Utils.createPercentageProgressMonitor("1001 Tool Actions");

      // So far we are on the EDT
      Runnable notEDTThreadTask =
          () -> {
            assert !SwingUtilities.isEventDispatchThread();
            for (int i = 0; i < numStrokes; i++) {
              int progressPercentage = (int) ((float) i * 100 / numStrokes);
              progressMonitor.setProgress(progressPercentage);
              progressMonitor.setNote(progressPercentage + "%");

              Runnable edtRunnable =
                  () -> testToolAction(comp, random, canvasWidth, canvasHeight, brushOnly);

              try {
                SwingUtilities.invokeAndWait(edtRunnable);
              } catch (InterruptedException | InvocationTargetException e) {
                e.printStackTrace();
              }

              comp.repaint();
            }
            progressMonitor.close();
          };
      new Thread(notEDTThreadTask).start();
    }
  }
Esempio n. 2
0
 private void testScreenCapture() {
   ImageComponent activeIC = ImageComponents.getActiveIC();
   testScreenCapture(true);
   testScreenCapture(false);
   try {
     SwingUtilities.invokeAndWait(
         () -> {
           ImageComponents.setActiveImageComponent(activeIC, true);
         });
   } catch (InterruptedException | InvocationTargetException e) {
     e.printStackTrace();
   }
 }