コード例 #1
0
 private void readIndexMap() throws IOException {
   MappedByteBuffer mapOffset = makeReadOnlyBuffer(8, 8);
   if (mapOffset.getInt() != MultipageTiffWriter.INDEX_MAP_OFFSET_HEADER) {
     ReportingUtils.logError("Image map offset header incorrect");
     indexMap_ = null;
     return;
   }
   long offset = unsignInt(mapOffset.getInt());
   MappedByteBuffer mapHeader = makeReadOnlyBuffer(offset, 8);
   int headerCode = mapHeader.getInt();
   if (headerCode != MultipageTiffWriter.INDEX_MAP_HEADER) {
     ReportingUtils.logError("Image index map header incorrect");
     indexMap_ = null;
     return;
   }
   int numMappings = mapHeader.getInt();
   MappedByteBuffer mapData = makeReadOnlyBuffer(offset + 8, 24 * numMappings);
   for (int i = 0; i < numMappings; i++) {
     int channel = mapData.getInt();
     int slice = mapData.getInt();
     int frame = mapData.getInt();
     int position = mapData.getInt();
     long imageOffset = mapData.getLong();
     indexMap_.put(MDUtils.generateLabel(channel, slice, frame, position), imageOffset);
   }
 }
コード例 #2
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);
      }
    }
コード例 #3
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");
      }
    }
コード例 #4
0
ファイル: LabelsPage.java プロジェクト: oeway/Eva-ImageJ
 public void readFromHardware() {
   LabelTableModel labelTableModel = (LabelTableModel) labelTable_.getModel();
   Device selectedDevice = labelTableModel.getCurrentDevice();
   if (selectedDevice != null) {
     try {
       selectedDevice.getSetupLabelsFromHardware(core_);
       labelTableModel.setData(model_, selectedDevice.getName());
       labelTableModel.fireTableStructureChanged();
     } catch (Exception e) {
       ReportingUtils.logError(e);
     }
   }
 }
コード例 #5
0
 public JSONObject readSummaryMD() throws IOException {
   MappedByteBuffer mdInfo = makeReadOnlyBuffer(16, 8);
   if (mdInfo.getInt() != MultipageTiffWriter.SUMMARY_MD_HEADER) {
     ReportingUtils.logError("Summary Metadata Header Incorrect");
     return null;
   }
   long length = unsignInt(mdInfo.getInt());
   try {
     return readJSONObject(24, length);
   } catch (JSONException ex) {
     ReportingUtils.showError("Error reading summary metadata");
     return null;
   }
 }
コード例 #6
0
  public TaggedImage readImage(String label) {
    if (indexMap_.containsKey(label)) {
      try {
        long byteOffset = indexMap_.get(label);
        IFDData data = readIFD(byteOffset);
        Object pixels = readPixels(data);
        JSONObject md = readMMMetadata(data);
        return new TaggedImage(pixels, md);
      } catch (IOException ex) {
        ReportingUtils.logError(ex);
        return null;
      }

    } else {
      // label not in map--maybe parse whole file?
      return null;
    }
  }
コード例 #7
0
ファイル: LabelsPage.java プロジェクト: oeway/Eva-ImageJ
  public boolean enterPage(boolean next) {
    DevTableModel tm = (DevTableModel) devTable_.getModel();
    tm.setData(model_);
    try {
      try {
        model_.loadStateLabelsFromHardware(core_);
      } catch (Throwable t) {
        ReportingUtils.logError(t);
      }

      // default the selection to the first row
      if (devTable_.getSelectedRowCount() < 1) {
        TableModel m2 = devTable_.getModel();
        if (0 < m2.getRowCount()) devTable_.setRowSelectionInterval(0, 0);
      }

    } catch (Exception e) {
      ReportingUtils.showError(e);
      return false;
    }

    resetLabels();
    return true;
  }