コード例 #1
0
    @Override
    public void newImageUpdate(JSONObject tags) {
      if (tags == null) {
        return;
      }
      updateLabels(tags);
      try {
        if (vad_.acquisitionIsRunning() && vad_.getNextWakeTime() > 0) {
          final long nextImageTime = vad_.getNextWakeTime();
          if (System.nanoTime() / 1000000 < nextImageTime) {
            final java.util.Timer timer = new java.util.Timer("Next frame display");
            TimerTask task =
                new TimerTask() {

                  public void run() {
                    double timeRemainingS = (nextImageTime - System.nanoTime() / 1000000) / 1000;
                    if (timeRemainingS > 0 && vad_.acquisitionIsRunning()) {
                      setStatusLabel(
                          "Next frame: "
                              + NumberUtils.doubleToDisplayString(1 + timeRemainingS)
                              + " s");
                    } else {
                      timer.cancel();
                      setStatusLabel("");
                    }
                  }
                };
            timer.schedule(task, 2000, 100);
          }
        }

      } catch (Exception ex) {
        ReportingUtils.logError(ex);
      }
    }
コード例 #2
0
    private void updateLabels(JSONObject tags) {
      // Z position label
      String zPosition = "";
      try {
        zPosition = NumberUtils.doubleStringCoreToDisplay(tags.getString("ZPositionUm"));
      } catch (Exception e) {
        try {
          zPosition = NumberUtils.doubleStringCoreToDisplay(tags.getString("Z-um"));
        } catch (Exception e1) {
          // Do nothing...
        }
      }
      zPosLabel_.setText("Z Position: " + zPosition + " um        ");

      // time label
      try {
        int ms = (int) tags.getDouble("ElapsedTime-ms");
        int s = ms / 1000;
        int min = s / 60;
        int h = min / 60;

        String time =
            twoDigitFormat(h)
                + ":"
                + twoDigitFormat(min % 60)
                + ":"
                + twoDigitFormat(s % 60)
                + "."
                + threeDigitFormat(ms % 1000);
        timeStampLabel_.setText("Elapsed time: " + time + "      ");
      } catch (JSONException ex) {
        ReportingUtils.logError("MetaData did not contain ElapsedTime-ms field");
      }
    }