/**
  * Reads and returns a {@link TextureData} for an image from a specified file URL.
  *
  * @param fileUrl the URL of the image file to read.
  * @return a <code>TextureData</code> instance for the image.
  */
 protected TextureData readImage(URL fileUrl) {
   try {
     return TextureIO.newTextureData(fileUrl, this.isUseMipMaps(), null);
   } catch (Exception e) {
     String msg =
         Logging.getMessage(
             "layers.TextureLayer.ExceptionAttemptingToReadTextureFile", this.getImageSource());
     Logging.logger().log(java.util.logging.Level.SEVERE, msg, e);
     this.textureInitializationFailed = true;
     return null;
   }
 }
  /**
   * Creates this instance's {@link Texture} if the image source is a <code>BufferedImage<code>.
   *
   * @param dc the current draw context.
   *
   * @return the newly created texture, or null if the texture was not created.
   *
   * @throws IllegalStateException if the image source is null or not a <code>BufferedImage</code>.
   */
  protected Texture makeBufferedImageTexture(DrawContext dc) {
    if (this.getImageSource() == null || !(this.getImageSource() instanceof BufferedImage)) {
      String message = Logging.getMessage("generic.NotABufferedImage");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    try {
      TextureData td =
          TextureIO.newTextureData((BufferedImage) this.getImageSource(), this.isUseMipMaps());
      if (td == null) return null;

      this.setTextureData(td);

      return this.makeTextureFromTextureData(dc);
    } catch (Exception e) {
      String msg = Logging.getMessage("generic.IOExceptionDuringTextureInitialization");
      Logging.logger().log(java.util.logging.Level.SEVERE, msg, e);
      this.textureInitializationFailed = true;
      return null;
    }
  }