Ejemplo n.º 1
0
  public void run() {

    long lastTime = System.nanoTime();
    long timer = System.currentTimeMillis();
    final double ns = 1000000000.0 / 60.0;
    double delta = 0;
    int frames = 0;
    int updates = 0;
    //		setFocusable(true);
    requestFocus();

    while (running) {
      long now = System.nanoTime();
      delta += (now - lastTime) / ns;
      lastTime = now;
      while (delta >= 1) {
        update();
        updates++;
        delta--;
      }
      // Renderiza tudo na tela
      render();
      // Calcula FPS
      frames++;

      if ((System.currentTimeMillis() - timer) > 1000) {
        timer += 1000;
        // T�tulo do jogo
        frame.setTitle(title + "  |  " + updates + " ups / " + frames + " fps ");
        updates = 0;
        frames = 0;
      }
    }
    stop();
  }
Ejemplo n.º 2
0
  private void tryToInitialize(int counter) {
    boolean existsCompatibleBrowser = getComponent() != null && isCompatible();
    synchronized (this) {
      initialized = existsCompatibleBrowser;
    }
    log.info(System.currentTimeMillis() + " initialized map: " + initialized);

    if (isInitialized()) {
      log.fine(System.currentTimeMillis() + " compatible, further initializing map");
      initializeAfterLoading();
      initializeBrowserInteraction();
      initializeCallbackListener();
      checkLocalhostResolution();
      checkCallback();
    } else {
      if (counter++ < 50) {
        log.info(System.currentTimeMillis() + " WAITING " + counter * 100 + " milliseconds");
        try {
          Thread.sleep(counter * 100);
        } catch (InterruptedException e) {
          // intentionally left empty
        }

        tryToInitialize(counter);
      }
    }
  }
Ejemplo n.º 3
0
 public void paintComponent(Graphics g) {
   long start = System.currentTimeMillis();
   for (int r = 0; r < game.getRows(); r++) {
     for (int c = 0; c < game.getCols(); c++) {
       if (game.getTileAt(r, c).getResource() == Resource.FOOD) {
         g.setColor(new Color(186, 57, 57));
       } else if (game.getTileAt(r, c).getResource() == Resource.GOLD) {
         g.setColor(new Color(240, 188, 16));
       } else if (game.getTileAt(r, c).getResource() == Resource.STONE) {
         g.setColor(new Color(129, 133, 146));
       } else if (game.getTileAt(r, c).getResource() == Resource.WOOD) {
         g.setColor(new Color(55, 91, 67));
       } else // Resource is none or does not change color.
       {
         if (game.getTileAt(r, c).getTerrainType() == Terrain.SAND)
           g.setColor(new Color(255, 241, 212));
         else if (game.getTileAt(r, c).getTerrainType() == Terrain.WATER)
           g.setColor(new Color(51, 126, 255));
         else if (game.getTileAt(r, c).getTerrainType() == Terrain.FOREST)
           g.setColor(new Color(139, 131, 120));
         else if (game.getTileAt(r, c).getTerrainType() == Terrain.MOUNTAIN)
           g.setColor(new Color(238, 238, 224));
         else if (game.getTileAt(r, c).getTerrainType() == Terrain.SNOW)
           g.setColor(new Color(255, 255, 255));
         else g.setColor(new Color(118, 208, 108));
       }
       g.fillRect(r * 1, c * 1, 1, 1);
     }
   }
   long end = System.currentTimeMillis();
   System.out.println("JPanel Setup Time: " + (end - start));
 }
Ejemplo n.º 4
0
    public synchronized void paint(Graphics g) {
      if (needToStartThread) {
        totalDrawTime = 0;
        counter = 0;
        needToStartThread = false;
        startThread(beginAngle, endAngle);
        if (firstImage == null) {
          firstImage = createImageFromComponent(component1);
        }
        if (secondImage == null) {
          secondImage = createImageFromComponent(component2);
        }
      }
      if (firstImage == null || secondImage == null) return;
      Graphics2D g2d = (Graphics2D) g;
      int ww = firstImage.getWidth();
      int hh = firstImage.getHeight();
      {
        BufferedImage currImage = null;
        int[] currPixels = null;
        int w = firstImage.getWidth();
        int offset = (int) (w * angle / 180);
        if (offset < 0) offset = 0;
        if (offset > w) offset = w;

        long beforeDraw = System.currentTimeMillis();
        g2d.drawImage(firstImage, null, 0, 0);
        g2d.drawImage(secondImage, null, w - offset, 0);
        totalDrawTime += (System.currentTimeMillis() - beforeDraw);
        counter++;
      }
    }
  public void displayAllClassesNames(List<String> classNames) {
    long start = System.currentTimeMillis();

    displayDataState = DisplayDataState.CLASSES_LIST;
    StyleConstants.setFontSize(style, 18);
    StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);

    clearText();

    BatchDocument blank = new BatchDocument();
    jTextPane.setDocument(blank);

    for (String className : classNames) {
      blank.appendBatchStringNoLineFeed(className, style);
      blank.appendBatchLineFeed(style);
    }

    try {
      blank.processBatchUpdates(0);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }

    jTextPane.setDocument(blank);

    System.out.println("UI update " + (System.currentTimeMillis() - start) + " ms");
  }
Ejemplo n.º 6
0
  public Notification(
      @NotNull String groupDisplayId,
      @NotNull Icon icon,
      @Nullable String title,
      @Nullable String subtitle,
      @Nullable String content,
      @NotNull NotificationType type,
      @Nullable NotificationListener listener) {
    myGroupId = groupDisplayId;
    myTitle = StringUtil.notNullize(title);
    myContent = StringUtil.notNullize(content);
    myType = type;
    myListener = listener;
    myTimestamp = System.currentTimeMillis();

    myIcon = icon;
    mySubtitle = subtitle;

    LOG.assertTrue(
        isTitle() || isContent(),
        "Notification should have title: "
            + title
            + " and/or subtitle and/or content groupId: "
            + myGroupId);

    id =
        String.valueOf(System.currentTimeMillis())
            + "."
            + String.valueOf(System.identityHashCode(this));
  }
    protected void preCache(List<Position> grid, Position centerPosition)
        throws InterruptedException {
      // Pre-cache the tiles that will be needed for the intersection calculations.
      double n = 0;
      final long start = System.currentTimeMillis();
      for (Position gridPos : grid) // for each grid point.
      {
        final double progress = 100 * (n++ / grid.size());
        terrain.cacheIntersectingTiles(centerPosition, gridPos);

        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                progressBar.setValue((int) progress);
                progressBar.setString(null);
              }
            });
      }

      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              progressBar.setValue(100);
            }
          });

      long end = System.currentTimeMillis();
      System.out.printf(
          "Pre-caching time %d milliseconds, cache usage %f, tiles %d\n",
          end - start, terrain.getCacheUsage(), terrain.getNumCacheEntries());
    }
Ejemplo n.º 8
0
  public static void checkSanity() {
    long t = System.currentTimeMillis();

    try {
      r.lock();
      final int fileLength = (int) getRecords().length();
      assert fileLength % RECORD_SIZE == 0;
      int recordCount = fileLength / RECORD_SIZE;

      IntArrayList usedAttributeRecordIds = new IntArrayList();
      IntArrayList validAttributeIds = new IntArrayList();
      for (int id = 2; id < recordCount; id++) {
        int flags = getFlags(id);
        LOG.assertTrue(
            (flags & ~ALL_VALID_FLAGS) == 0,
            "Invalid flags: 0x" + Integer.toHexString(flags) + ", id: " + id);
        if ((flags & FREE_RECORD_FLAG) != 0) {
          LOG.assertTrue(
              DbConnection.myFreeRecords.contains(id),
              "Record, marked free, not in free list: " + id);
        } else {
          LOG.assertTrue(
              !DbConnection.myFreeRecords.contains(id),
              "Record, not marked free, in free list: " + id);
          checkRecordSanity(id, recordCount, usedAttributeRecordIds, validAttributeIds);
        }
      }
    } finally {
      r.unlock();
    }

    t = System.currentTimeMillis() - t;
    LOG.info("Sanity check took " + t + " ms");
  }
Ejemplo n.º 9
0
 /**
  * This method runs the Runnable and measures how long it takes.
  *
  * @param r is the Runnable for the task that we want to measure
  * @return the time it took to execute this task
  */
 public static long time(Runnable r) {
   long time = -System.currentTimeMillis();
   r.run();
   time += System.currentTimeMillis();
   System.out.println("Took " + time + "ms");
   return time;
 }
  private JComponent createLabelsPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(0, 2, 10, 1));

    // Creates a StyledLabel to warn up so that we don't include class loading time into the
    // performance test.
    // This is the same for all three cases.
    new JLabel("Bold Italic Underlined");

    long start = System.currentTimeMillis();
    for (int i = 0; i < COUNT; i++) {
      JLabel label = new JLabel("Bold Italic Underlined");
      panel.add(label);
    }
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                new PartialLineBorder(Color.gray, 1, true),
                " JLabel (Plain) Examples - use " + (System.currentTimeMillis() - start) + " ms ",
                TitledBorder.CENTER,
                TitledBorder.CENTER,
                null,
                Color.RED),
            BorderFactory.createEmptyBorder(6, 4, 4, 4)));
    return panel;
  }
Ejemplo n.º 11
0
  public final void runMovement() {
    if (!isShowing()) {
      return;
    }
    final int distance;
    final Rectangle bounds = getBounds();
    if (myAnchor == ToolWindowAnchor.LEFT || myAnchor == ToolWindowAnchor.RIGHT) {
      distance = bounds.width;
    } else {
      distance = bounds.height;
    }
    int count = 0;
    myOffset = 0;
    paintImmediately(
        0, 0, getWidth(), getHeight()); // first paint requires more time than next ones
    final long startTime = System.currentTimeMillis();

    while (true) {
      paintImmediately(0, 0, getWidth(), getHeight());
      final long timeSpent = System.currentTimeMillis() - startTime;
      count++;
      if (timeSpent >= myDesiredTimeToComplete) break;
      final double onePaintTime = (double) timeSpent / count;
      int iterations = (int) ((myDesiredTimeToComplete - timeSpent) / onePaintTime);
      iterations = Math.max(1, iterations);
      myOffset += (distance - myOffset) / iterations;
    }
  }
Ejemplo n.º 12
0
 /**
  * Wait until any key is pressed within the time indicated This method also checks action keys
  * (Cursor arrows, Home, etc.).
  *
  * @param timeout Maximum time to wait in milliseconds. If is 0 wait forever
  * @return The key pressed or a negative value if no key was pressed (NO_KEY or MOUSE_CLICK).
  * @see #getKeyPressedUntil(long)
  * @see #getKeyPressed()
  * @see #getMouseEvent()
  */
 public static int waitKeyPressed(long timeout) {
   if (timeout < 0) timeout = 0;
   if (timeout > 0) timeout += System.currentTimeMillis();
   int k;
   while ((k = frame.getKeyPressed()) == NO_KEY
       && (timeout <= 0 || System.currentTimeMillis() < timeout)) ;
   return k;
 }
Ejemplo n.º 13
0
 /**
  * Wait until a key is pressed within the time indicated This method reads only keys that are used
  * to edit text (letters, digits, space, enter, etc.).
  *
  * @param timeout Maximum time to wait in milliseconds. If is 0 wait forever
  * @return The key pressed or NO_CHAR ((char) 0) if no key was pressed in the timeout
  */
 public static char waitChar(long timeout) {
   // while( getChar()!=NO_CHAR ) ;
   if (timeout < 0) timeout = 0;
   if (timeout > 0) timeout += System.currentTimeMillis();
   char c = 0;
   while ((c = getChar()) == NO_CHAR && (timeout <= 0 || System.currentTimeMillis() < timeout)) ;
   return c;
 }
Ejemplo n.º 14
0
 private void repaintPanels(Iterable<TilePanel> panels) {
   long start = System.currentTimeMillis();
   for (TilePanel panel : panels) {
     game.notifyGameObservers(panel.getTile().getPosition());
   }
   long stop = System.currentTimeMillis();
   Logger.getLogger(BoardPanel.class).debug("Repaint time: " + (stop - start) / 1000.0);
 }
Ejemplo n.º 15
0
 private void measureThrougput(long size) {
   if ((System.currentTimeMillis() - startTimeThroughput) > oneSecond) {
     control.throughput.setText("" + (throughput / 1024) + " KB/sec");
     startTimeThroughput = System.currentTimeMillis();
     throughput = 0;
   } else {
     throughput += size;
   }
 }
Ejemplo n.º 16
0
  /**
   * The launching point
   *
   * <p>In development, pass the following on the JVM command line:
   * <tt>-Djava.util.logging.config.file=config/logging.properties</tt>
   *
   * <p>On Mac, add the following (otherwise SWT won't work): <tt>-XstartOnFirstThread</tt>
   */
  public static void main(String... args) {
    long startTime = System.currentTimeMillis();

    initSystemProperties();
    Display display;

    try {
      // this defines the Window class and app name on the Mac
      Display.setAppName(Version.NAME);
      display = Display.getDefault();
      LOG.finer("SWT initialized after " + (System.currentTimeMillis() - startTime));
    } catch (UnsatisfiedLinkError e) {
      JOptionPane.showMessageDialog(
          null,
          "Failed to load native code. Probably you are using a binary built for wrong OS or CPU - try downloading both 32-bit and 64-bit binaries");
      return;
    }

    // initialize Labels instance
    Labels.initialize(Locale.getDefault());
    // initialize Config instance
    Config globalConfig = Config.getConfig();
    LOG.finer("Labels and Config initialized after " + (System.currentTimeMillis() - startTime));

    ComponentRegistry componentRegistry = new ComponentRegistry();
    LOG.finer("ComponentRegistry initialized after " + (System.currentTimeMillis() - startTime));

    processCommandLine(args, componentRegistry);

    // create the main window using dependency injection
    MainWindow mainWindow = componentRegistry.getMainWindow();
    LOG.fine("Startup time: " + (System.currentTimeMillis() - startTime));

    while (!mainWindow.isDisposed()) {
      try {
        if (!display.readAndDispatch()) display.sleep();
      } catch (Throwable e) {
        if (e instanceof SWTException && e.getCause() != null) e = e.getCause();

        // display a nice error message
        String localizedMessage = getLocalizedMessage(e);
        Shell parent = display.getActiveShell();
        showMessage(
            parent != null ? parent : mainWindow.getShell(),
            e instanceof UserErrorException ? SWT.ICON_WARNING : SWT.ICON_ERROR,
            Labels.getLabel(e instanceof UserErrorException ? "text.userError" : "text.error"),
            localizedMessage);
      }
    }

    // save config on exit
    globalConfig.store();

    // dispose the native objects
    display.dispose();
  }
Ejemplo n.º 17
0
  public void waiting(int n) {

    long t0, t1;

    t0 = System.currentTimeMillis();

    do {
      t1 = System.currentTimeMillis();
    } while ((t1 - t0) < (n));
  }
    @Override
    protected Product doInBackground(com.bc.ceres.core.ProgressMonitor pm) throws Exception {
      final TargetProductSelectorModel model = getTargetProductSelector().getModel();
      pm.beginTask("Writing...", model.isOpenInAppSelected() ? 100 : 95);
      ProgressMonitorList.instance().add(pm); // NESTMOD
      saveTime = 0L;
      Product product = null;
      try {
        // free cache	// NESTMOD
        JAI.getDefaultInstance().getTileCache().flush();
        System.gc();

        executeStartTime = Calendar.getInstance().getTime();
        long t0 = System.currentTimeMillis();
        Operator operator = null;
        if (targetProduct.getProductReader() instanceof OperatorProductReader) {
          final OperatorProductReader opReader =
              (OperatorProductReader) targetProduct.getProductReader();
          if (opReader.getOperatorContext().getOperator() instanceof Output) {
            operator = opReader.getOperatorContext().getOperator();
          }
        }
        if (operator == null) {
          WriteOp writeOp =
              new WriteOp(targetProduct, model.getProductFile(), model.getFormatName());
          writeOp.setDeleteOutputOnFailure(true);
          writeOp.setWriteEntireTileRows(true);
          writeOp.setClearCacheAfterRowWrite(false);
          operator = writeOp;
        }
        final OperatorExecutor executor = OperatorExecutor.create(operator);
        executor.execute(SubProgressMonitor.create(pm, 95));

        saveTime = System.currentTimeMillis() - t0;
        File targetFile = model.getProductFile();
        if (model.isOpenInAppSelected() && targetFile.exists()) {
          product = ProductIO.readProduct(targetFile);
          if (product == null) {
            product = targetProduct; // todo - check - this cannot be ok!!! (nf)
          }
          pm.worked(5);
        }
      } finally {
        // free cache
        JAI.getDefaultInstance().getTileCache().flush();
        System.gc();

        pm.done();
        ProgressMonitorList.instance().remove(pm); // NESTMOD
        if (product != targetProduct) {
          targetProduct.dispose();
        }
      }
      return product;
    }
 public void mouseEntered(MouseEvent e) {
   if (!readOnly) {
     if (lastMouseExitTime > 0 && lastInsertTime > 0) {
       long waitTime = Math.abs(lastMouseExitTime - lastInsertTime);
       lastInsertTime = System.currentTimeMillis() - waitTime;
       lastMouseExitTime = -1;
     } else {
       lastInsertTime = System.currentTimeMillis();
     }
   }
 }
Ejemplo n.º 20
0
  /**
   * This method is the access point to the planning procedure. Initially, it adds all variables
   * from axioms to the set of found vars, then does the linear planning. If lp does not solve the
   * problem and there are subtasks, goal-driven recursive planning with backtracking is invoked.
   * Planning is performed until no new variables are introduced into the algorithm.
   */
  public EvaluationAlgorithm invokePlaning(Problem problem, boolean _computeAll) {
    long startTime = System.currentTimeMillis();

    computeAll = _computeAll;
    EvaluationAlgorithm algorithm = new EvaluationAlgorithm();

    PlanningContext context = problem.getCurrentContext();

    // add all axioms at the beginning of an algorithm
    Collection<Var> flattened = new HashSet<Var>();
    for (Iterator<Rel> axiomIter = problem.getAxioms().iterator(); axiomIter.hasNext(); ) {
      Rel rel = axiomIter.next();

      unfoldVarsToSet(rel.getOutputs(), flattened);

      // do not overwrite values of variables that come via args of compute() or as inputs of
      // independent subtasks
      if (!problem.getAssumptions().containsAll(flattened)
      // do not overwrite values of already known variables.
      // typically this is the case when a value of a variable
      // is given in a scheme via a properties window
      //                    && !problem.getKnownVars().containsAll( flattened )
      ) {
        algorithm.addRel(rel);
      }
      axiomIter.remove();
      context.getKnownVars().addAll(flattened);
      flattened.clear();
    }

    context.getFoundVars().addAll(context.getKnownVars());

    // remove all known vars with no relations
    for (Iterator<Var> varIter = context.getKnownVars().iterator(); varIter.hasNext(); ) {
      if (varIter.next().getRels().isEmpty()) {
        varIter.remove();
      }
    }

    // start planning
    if (problem.getRelsWithSubtasks().isEmpty()
        && linearForwardSearch(context, algorithm, computeAll)) {
      if (isLinearLoggingOn()) logger.debug("Problem solved without subtasks");
    } else if (!problem.getRelsWithSubtasks().isEmpty() && subtaskPlanning(problem, algorithm)) {
      if (isLinearLoggingOn()) logger.debug("Problem solved with subtasks");
    } else if (!computeAll) {
      if (isLinearLoggingOn()) logger.debug("Problem not solved");
    }

    if (!nested) {
      logger.info("Planning time: " + (System.currentTimeMillis() - startTime) + "ms.");
    }
    return algorithm;
  }
Ejemplo n.º 21
0
 private void chkFPS() {
   if (fpsCount == 0) {
     fpsTime = System.currentTimeMillis() / 1000;
     fpsCount++;
     return;
   }
   fpsCount++;
   long time = System.currentTimeMillis() / 1000;
   if (time != fpsTime) {
     lastFPS = fpsCount;
     fpsCount = 1;
     fpsTime = time;
   }
 }
Ejemplo n.º 22
0
 /**
  * Starts a pan-zoom animation.
  *
  * @param toX what x coordinate to zoom to
  * @param toY what y coordinate to zoom to
  * @param zoomTo the new zoom factor
  * @param duration_msec how long to animate
  * @param zoomPanAnimationInterpolationPower 1 means a linear interpolation will be done between
  *     the two animation endpoints. 2 would be quadratic, etc. A higher the number causes a faster
  *     beginning and a slower and smoother the ending.
  */
 public void startPanZoomAnimation(
     int toX,
     int toY,
     float zoomTo,
     long duration_msec,
     float zoomPanAnimationInterpolationPower) {
   this.zoomTo = zoomTo;
   this.panTo = new Vector2i(toX, toY);
   this.panFrom = drawOffset.clone();
   this.zoomFrom = zoom;
   this.zoomPanAnimationStartTime = System.currentTimeMillis();
   this.zoomPanAnimationEndTime = System.currentTimeMillis() + duration_msec;
   this.zoomPanAnimationInterpolationPower = zoomPanAnimationInterpolationPower;
 }
Ejemplo n.º 23
0
 /**
  * _more_
  *
  * @param range _more_
  * @param var _more_
  * @return _more_
  * @throws Exception _more_
  */
 protected float[] getFloatData(Range range, String var) throws Exception {
   long t1 = System.currentTimeMillis();
   float[] f =
       SqlUtil.readFloat(
           SqlUtil.getIterator(select("(" + var + ")", TABLE_DATA, "order by " + varTime)),
           1,
           (float) getMissingValue(var));
   long t2 = System.currentTimeMillis();
   //            System.err.println("length:" + f.length + " time:" + (t2-t1));
   if (f.length == 0) {
     throw new BadDataException("No observations found in data base");
   }
   return f;
 }
Ejemplo n.º 24
0
  public void run() {
    long lastTime = System.nanoTime();
    double nsPerTick = 1000000000D / 60D;

    int ticks = 0;
    int frames = 0;

    long lastTimer = System.currentTimeMillis();
    double delta = 0;

    init();

    while (Game.isRunning()) {
      long now = System.nanoTime();
      delta += (now - lastTime) / nsPerTick;
      lastTime = now;
      boolean shouldRender = false;

      while (delta >= 1) {
        ticks++;
        tick();
        delta -= 1;
        shouldRender = true;
      }

      try {
        Thread.sleep(2);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      if (shouldRender) {
        frames++;
        render();
      }

      if (System.currentTimeMillis() - lastTimer >= 1000) {
        lastTimer += 1000;
        getFrame()
            .setTitle(
                "JavaGame - Version "
                    + WordUtils.capitalize(game_Version).substring(1, game_Version.length()));
        fps = frames;
        tps = ticks;
        frames = 0;
        ticks = 0;
      }
    }
  }
Ejemplo n.º 25
0
  public void run() {
    Map read;
    boolean shouldRead = go_read;
    String command = null;
    long last = 0;

    try {
      /* swallow the banner if requested to do so */
      if (swallow) {
        readResponse();
      }

      while (shouldRead) {
        synchronized (listeners) {
          if (commands.size() > 0) {
            command = (String) commands.removeFirst();
          }
        }

        if (command != null) {
          _sendString(command);
          command = null;
          lastRead = System.currentTimeMillis();
        }

        long now = System.currentTimeMillis();
        if (this.window != null && !this.window.isShowing() && (now - last) < 1500) {
          /* check if our window is not showing... if not, then we're going to switch to a very reduced
          read schedule. */
        } else {
          read = readResponse();
          if (read == null || "failure".equals(read.get("result") + "")) {
            break;
          }

          processRead(read);
          last = System.currentTimeMillis();
        }

        Thread.sleep(100);

        synchronized (listeners) {
          shouldRead = go_read;
        }
      }
    } catch (Exception javaSucksBecauseItMakesMeCatchEverythingFuckingThing) {
      javaSucksBecauseItMakesMeCatchEverythingFuckingThing.printStackTrace();
    }
  }
Ejemplo n.º 26
0
 public void run() {
   while (true) {
     long d = System.currentTimeMillis() - lastTick;
     if (d > tickTime) {
       lastTick = System.currentTimeMillis();
       world.tick();
     } else {
       try {
         Thread.sleep(d);
       } catch (InterruptedException e) {
         // ignore
       }
     }
   }
 }
Ejemplo n.º 27
0
 @Override
 public void onFinished(long total, long done) {
   String content;
   endTime = System.currentTimeMillis();
   long cost = endTime - startTime;
   if (cost < 1000) {
     content = "processing-------done:" + done + "  total:" + total + "   " + "cost time: < 1s";
   } else if (cost < 1000 * 60) {
     content =
         "processing-------done:"
             + done
             + "  total:"
             + total
             + "   "
             + "cost time: "
             + (float) cost / 1000
             + "s";
   } else {
     long min = cost / 60000;
     content =
         "processing-------done:"
             + done
             + "  total:"
             + total
             + "   "
             + "cost time: "
             + min
             + "min"
             + (cost - min * 1000) / 1000
             + "s";
   }
   progressLabel.setText(content);
   jb[0].setVisible(true);
   JOptionPane.showMessageDialog(this, "Completed!!!");
 }
Ejemplo n.º 28
0
  @Override
  public void run() {
    while (true) {
      long temp = System.currentTimeMillis();
      if ((temp - timer) >= 16L) {
        timer = temp;
        if (screenShakeUpdate) {
          if (screenShakeCounter % 2 == 1) {
            screenShakeX = r.nextInt(SCREENSHAKESTRENGTH) - SCREENSHAKESTRENGTH / 2;
            screenShakeY = r.nextInt(SCREENSHAKESTRENGTH) - SCREENSHAKESTRENGTH / 2;
          } else {
            screenShakeX = 0;
            screenShakeY = 0;
          }

          screenShakeCounter++;
          if (screenShakeCounter > SCREENSHAKETIMELIMIT) {
            screenShakeUpdate = false;
            screenShakeCounter = 0;
            screenShakeX = 0;
            screenShakeY = 0;
          }
        }
        if (fadeUpdate) {
          fadeCounter++;
          if (fadeCounter >= FADETIMELIMIT) {
            oldbg = bg;
            fadeUpdate = false;
          }
        }

        repaint();
      }
    }
  }
  public static InputEvent getInputEvent(String actionName) {
    final Shortcut[] shortcuts =
        KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionName);
    KeyStroke keyStroke = null;
    for (Shortcut each : shortcuts) {
      if (each instanceof KeyboardShortcut) {
        keyStroke = ((KeyboardShortcut) each).getFirstKeyStroke();
        if (keyStroke != null) break;
      }
    }

    if (keyStroke != null) {
      return new KeyEvent(
          JOptionPane.getRootFrame(),
          KeyEvent.KEY_PRESSED,
          System.currentTimeMillis(),
          keyStroke.getModifiers(),
          keyStroke.getKeyCode(),
          keyStroke.getKeyChar(),
          KeyEvent.KEY_LOCATION_STANDARD);
    } else {
      return new MouseEvent(
          JOptionPane.getRootFrame(),
          MouseEvent.MOUSE_PRESSED,
          0,
          0,
          0,
          0,
          1,
          false,
          MouseEvent.BUTTON1);
    }
  }
Ejemplo n.º 30
0
  /**
   * Returns root node, fake parent suite for all tests and suites
   *
   * @param testsRoot
   * @return
   */
  public void onTestingStarted(@NotNull SMTestProxy.SMRootTestProxy testsRoot) {
    myAnimator.setCurrentTestCase(myTestsRootNode);
    myTreeBuilder.updateFromRoot();

    // Status line
    myStatusLine.setStatusColor(ColorProgressBar.GREEN);

    // Tests tree
    selectAndNotify(myTestsRootNode);

    myStartTime = System.currentTimeMillis();
    boolean printTestingStartedTime = true;
    if (myProperties instanceof SMTRunnerConsoleProperties) {
      printTestingStartedTime =
          ((SMTRunnerConsoleProperties) myProperties).isPrintTestingStartedTime();
    }
    if (printTestingStartedTime) {
      myTestsRootNode.addSystemOutput(
          "Testing started at " + DateFormatUtil.formatTime(myStartTime) + " ...\n");
    }

    updateStatusLabel(false);

    // TODO : show info - "Loading..." msg

    fireOnTestingStarted();
  }