/**
  * Gets the highest resolution image that fits the given size.
  *
  * @param link The link that describes the image
  * @param width The width the image should have (at least).
  * @param height The height the image should have (at least).
  * @return The image or a null image.
  */
 public Image getImage(ImageLink link, float width, float height) {
   if (link == null) {
     return NullImage.getInstance();
   } else if (link instanceof DirectImageLink) {
     return getDirectImage((DirectImageLink) link);
   } else {
     OriginalImageLink olink = (OriginalImageLink) link;
     if (olink.getType() == EImageLinkType.LANDSCAPE) {
       return getLandscapeImage(olink.getFile(), olink.getSequence());
     } else {
       return getDetailedImage(olink, width, height);
     }
   }
 }
 /**
  * Expects a valid sequence number.
  *
  * @param link
  * @param sequenceNumber must be an integer from 0 to 2.
  * @return the image matching the specified indexes.
  */
 private Image getSequencedImage(OriginalImageLink link, int sequenceNumber) {
   if (link.getType() == EImageLinkType.SETTLER) {
     return getSettlerSequence(link.getFile(), link.getSequence())
         .getImageSafe(link.getImage() + sequenceNumber);
   } else {
     return getGuiImage(link.getFile(), link.getSequence() + sequenceNumber);
   }
 }
 /**
  * Returns a GUI or SETTLER type image and if available a higher resolution version. This is also
  * based on whether the image's dimensions in pixels will fit into both the specified width and
  * height. This is so that an image is always scaled up as downsizing an image can introduce
  * artifacts and it would be wasteful to be calculating the translation of excess pixels from a
  * large image to a smaller one. However should the smallest image be oversized it will still be
  * returned.
  */
 private Image getDetailedImage(OriginalImageLink link, float width, float height) {
   Image image = getSequencedImage(link, 0);
   if (!HIGHRES_IMAGE_FILE_NUMBERS.contains(
       link.getFile())) { // Higher resolution images are only available in some files.
     return image;
   }
   int sequenceNumber = 0;
   Image higherResImg = image;
   while (higherResImg.getWidth() < width && higherResImg.getHeight() < height) {
     image = higherResImg;
     if (++sequenceNumber > LAST_SEQUENCE_NUMBER) {
       break;
     }
     higherResImg = getSequencedImage(link, sequenceNumber);
   }
   return image;
 }