Пример #1
0
  protected Dataset getCompleteData(IMonitor mon) throws Exception {

    IHierarchicalDataFile file = null;
    try {
      if (mon != null) mon.worked(1);
      file = HierarchicalDataFactory.getReader(path);

      final hdf.object.Dataset set = (hdf.object.Dataset) file.getData(fullPath);
      if (set.getStartDims() == null) set.getMetadata();

      /**
       * The diamond slicing can leave the dataset in memory, and the selection. Therefore if they
       * were slicing in the DExplore view before going here, the full selection is broken, there is
       * a sub slice selected.
       *
       * <p>TODO Get Peter to fix this some time.
       */
      loader.resetDims(set);

      final Object val = set.read();
      return H5Utils.getSet(val, set);

    } finally {
      if (file != null) file.close();
    }
  }
Пример #2
0
  /** { "Name", "Class", "Dims", "Type", "Size" }; */
  @Override
  public String getColumnText(Object element, int columnIndex) {

    if (!(element instanceof TreeNode)) return null;
    final TreeNode node = (TreeNode) element;

    HObject object = (HObject) ((DefaultMutableTreeNode) node).getUserObject();

    if (file.isClosed()) {
      try {
        this.file = HierarchicalDataFactory.getReader(file.getPath());

      } catch (Exception e) {
        logger.error("Cannot re-create link to " + file.getPath());
      }
    }

    try {
      object = (HObject) file.getData(object.getFullName());
    } catch (Exception e) {
      logger.error("Cannot re-create link to recorde " + object.getFullName());
    }

    if (object == null) return null;

    switch (columnIndex) {
      case 0:
        return object.getName();
      case 1:
        if (object instanceof Group) {
          return "Group";
        } else if (object instanceof Dataset) {
          return "Dataset";
        } else {
          return object.getClass().getConstructors()[0].getName();
        }
      case 2:
        if (object instanceof Dataset) {
          long[] shape;
          try {
            shape = HierarchicalDataUtils.getDims((Dataset) object);
          } catch (Exception e) {
            return "";
          }
          if (shape == null) return "";
          return Arrays.toString(shape);
        }
        return "";
      case 3:
        if (object instanceof Dataset) {
          return "" + ((Dataset) object).getDatatype().getDatatypeDescription();
        }
        return "";
      case 4:
        if (object instanceof Dataset) {
          long memSize;
          try {
            memSize = HierarchicalDataUtils.getSize((Dataset) object);
          } catch (Exception e) {
            return "";
          }
          if (memSize < 0) return "";
          return formatSize(memSize);
        }
        return "";
      default:
        return null;
    }
  }