示例#1
0
 /** Creates the images composing the grid. */
 private void createGridImages() {
   // if (combinedImage == null) return;
   if (originalGridImages == null) originalGridImages = new ArrayList<BufferedImage>();
   clearList(gridImages);
   if (ImViewer.GREY_SCALE_MODEL.equals(parent.getColorModel())) {
     createGridImagesForGreyScale();
     return;
   }
   List l = parent.getActiveChannels();
   int maxC = parent.getMaxC();
   switch (l.size()) {
     case 0:
       for (int i = 0; i < maxC; i++) gridImages.add(null);
       break;
     case 1:
     case 2:
     case 3:
       if (isImageMappedRGB(l) && !parent.isCompressed()) {
         combinedImage = null;
         combinedImage = Factory.magnifyImage(gridRatio, renderedImage);
         int w = combinedImage.getWidth();
         int h = combinedImage.getHeight();
         DataBuffer buf = combinedImage.getRaster().getDataBuffer();
         List<ChannelData> list = parent.getSortedChannelData();
         Iterator<ChannelData> i = list.iterator();
         int index;
         while (i.hasNext()) {
           index = i.next().getIndex();
           if (parent.isChannelActive(index)) {
             if (parent.isChannelRed(index)) {
               gridImages.add(
                   Factory.createBandImage(
                       buf, w, h, Factory.RED_MASK, Factory.BLANK_MASK, Factory.BLANK_MASK));
             } else if (parent.isChannelGreen(index)) {
               gridImages.add(
                   Factory.createBandImage(
                       buf, w, h, Factory.BLANK_MASK, Factory.GREEN_MASK, Factory.BLANK_MASK));
             } else if (parent.isChannelBlue(index)) {
               gridImages.add(
                   Factory.createBandImage(
                       buf, w, h, Factory.BLANK_MASK, Factory.BLANK_MASK, Factory.BLUE_MASK));
             }
           } else {
             gridImages.add(null);
           }
         }
       } else {
         retrieveGridImages();
       }
       break;
     default:
       retrieveGridImages();
   }
 }
示例#2
0
 /**
  * Sets the ratio of the grid image.
  *
  * @param gridRatio The value to set.
  */
 void setGridRatio(double gridRatio) {
   // if (ratio == 1) return; //We don't want to be too small.
   double max = ZoomGridAction.MAX_ZOOM_FACTOR;
   if (gridRatio > max) return;
   this.gridRatio = gridRatio;
   if (ImViewerAgent.hasOpenGLSupport()) return;
   if (CollectionUtils.isEmpty(originalGridImages)) {
     try {
       createGridImages();
     } catch (Exception e) {
       handleGridImageCreationException(e);
     }
     return;
   }
   int n = originalGridImages.size();
   clearList(gridImages);
   int maxC = parent.getMaxC();
   switch (n) {
     case 0:
       for (int i = 0; i < maxC; i++) gridImages.add(null);
       break;
     case 1:
     case 2:
     case 3:
       // TODO: Review that code.
       if (isImageMappedRGB(parent.getActiveChannels())) {
         try {
           createGridImages();
         } catch (Exception e) {
           handleGridImageCreationException(e);
         }
       } else {
         combinedImage = null;
         combinedImage = Factory.magnifyImage(gridRatio, renderedImage);
         Iterator<BufferedImage> i = originalGridImages.iterator();
         while (i.hasNext()) {
           gridImages.add(Factory.magnifyImage(gridRatio, i.next()));
         }
       }
       break;
     default:
       combinedImage = null;
       combinedImage = Factory.magnifyImage(gridRatio, renderedImage);
       Iterator<BufferedImage> i = originalGridImages.iterator();
       while (i.hasNext()) {
         gridImages.add(Factory.magnifyImage(gridRatio, i.next()));
       }
   }
 }
示例#3
0
 /**
  * Returns <code>true</code> if the rendered image is an RGB image, <code>false</code> otherwise.
  *
  * @return See above.
  */
 boolean isRenderedImageRGB() {
   return isImageMappedRGB(parent.getActiveChannels());
 }