コード例 #1
0
  /**
   * Loads the thumbnail for passed collection of pixels set.
   *
   * @param ids The collection of pixels set id.
   */
  private void loadThumbnails(List ids) {
    try {
      Map<Long, BufferedImage> m = service.getThumbnailSet(ctx, ids, maxLength);
      List<Object> result = new ArrayList<Object>();
      Iterator<Long> i = m.keySet().iterator();
      long pixelsID;
      BufferedImage thumbPix;
      DataObject obj;
      boolean valid = true;
      long imageID = -1;
      PixelsData pxd = null;
      while (i.hasNext()) {
        pixelsID = i.next();
        obj = input.get(pixelsID);
        if (obj instanceof ImageData) {
          imageID = ((ImageData) obj).getId();
          pxd = ((ImageData) obj).getDefaultPixels();
        } else if (obj instanceof PixelsData) {
          pxd = (PixelsData) obj;
          imageID = pxd.getImage().getId();
        }
        if (pxd != null) {
          thumbPix = (BufferedImage) m.get(pixelsID);
          if (thumbPix == null) thumbPix = createDefaultImage(pxd);
          result.add(new ThumbnailData(imageID, thumbPix, valid));
        }
      }
      currentThumbs = result;

    } catch (RenderingServiceException e) {
      context.getLogger().error(this, "Cannot retrieve thumbnail: " + e.getExtendedMessage());
    }
  }
コード例 #2
0
 /**
  * Loads the thumbnails for the passed collection of files.
  *
  * @param files The collection of files to handle.
  */
 private void loadFSThumbnails(List files) {
   List result = new ArrayList();
   try {
     ExperimenterData exp = (ExperimenterData) context.lookup(LookupNames.CURRENT_USER_DETAILS);
     long id = exp.getId();
     Map<DataObject, BufferedImage> m = service.getFSThumbnailSet(ctx, files, maxLength, id);
     Entry<DataObject, BufferedImage> entry;
     Iterator<Entry<DataObject, BufferedImage>> i = m.entrySet().iterator();
     BufferedImage thumb;
     DataObject obj;
     boolean valid = true;
     FileData f;
     while (i.hasNext()) {
       entry = i.next();
       obj = entry.getKey();
       thumb = entry.getValue();
       if (thumb == null) {
         thumb = Factory.createDefaultImageThumbnail(Factory.IMAGE_ICON);
       }
       if (obj.getId() > 0) result.add(new ThumbnailData(obj.getId(), thumb, valid));
       else result.add(new ThumbnailData(obj, thumb, valid));
     }
     currentThumbs = result;
   } catch (Exception e) {
     currentThumbs = result;
     context.getLogger().error(this, "Cannot retrieve thumbnail: " + e.getMessage());
   }
 }