/** Creates the images composing the grid. */
 private void createGridImagesAsTextures() {
   if (parent.getColorModel().equals(ImViewer.GREY_SCALE_MODEL)) {
     if (!hasGridImagesAsTexture()) {
       clearTextureMap(gridImagesAsTextures);
       gridImagesAsTextures = parent.getGridImagesAsTexture();
     }
   } else {
     clearTextureMap(gridImagesAsTextures);
     gridImagesAsTextures = parent.getGridImagesAsTexture();
   }
 }
 /** Removes references to images. */
 void discard() {
   combinedImage = null;
   displayedImage = null;
   displayedProjectedImage = null;
   projectedImage = null;
   renderedImage = null;
   clearList(gridImages);
   clearList(originalGridImages);
   clearTextureMap(gridImagesAsTextures);
   projectedImageAsTexture = null;
   renderedImageAsTexture = null;
   System.gc(); // force garbage collection
 }
 /**
  * Sets the rendered image.
  *
  * @param image The image to set.
  */
 void setRenderedImageAsTexture(TextureData image) {
   if (renderedImageAsTexture != null) renderedImageAsTexture.flush();
   renderedImageAsTexture = image;
   if (renderedImageAsTexture != null) {
     if (init) {
       int imageWidth = image.getWidth();
       if (imageWidth < ImViewer.MINIMUM_SIZE) {
         ratio = 1;
         gridRatio = 1;
         setUnitBar(false);
       }
       if (imageWidth * ratio > ImViewer.MAXIMUM_SIZE)
         ratio = (double) ImViewer.MAXIMUM_SIZE / imageWidth;
       init = false;
     }
   }
   // displayedImage = null;
   // combinedImage = null;
   clearTextureMap(gridImagesAsTextures);
 }