Пример #1
0
  /**
   * Find image and return it. Resolves URL string to absolute URL.
   *
   * @throws IOException if url is invalid
   */
  public Image getImage(String url) throws IOException {
    URL resolvedURL = resourceLoader.resolveUrl(null, url);

    if (resolvedURL == null) throw new IOException("Couldn't resolve url:" + url);

    return this.getImage(resolvedURL);
  }
Пример #2
0
  /**
   * Returns Icon or broken image icon. Creates ImageIcon directly from URL, works with animated
   * GIFs as the icon is not changed
   */
  public Icon createIconOrBroken(ClassLoader optClassLoader, String url) {
    logger.debugPrintf("createIconOrDefault:%s\n", url);
    // Find image and create icon. No Rendering!

    URL resolvedUrl = resourceLoader.resolveUrl(optClassLoader, url);

    Icon icon = null;
    if (resolvedUrl != null) icon = new ImageIcon(resolvedUrl);

    if (icon != null) return icon;

    logger.debugPrintf("Returning broken icon for:%s\n", url);
    return getBrokenIcon();
  }
Пример #3
0
  /**
   * Try to find a specified image, but do no throw an (IOL)Exception if it can't be found. Method
   * will return 'null' if the case an image can't be found.
   */
  public Image findImage(ClassLoader extraLoader, String iconURL) {
    URL resolvedurl = resourceLoader.resolveUrl(extraLoader, iconURL);

    // return url
    if (resolvedurl != null) {
      logger.debugPrintf("findIcon:found Icon:%s\n", resolvedurl);

      // Basic checks whether the icon is a valid icon ?
      try {
        Image image = loadImage(resolvedurl, true);

        if (image != null) {
          logger.debugPrintf("findIcon:returning non null icon:%s\n", resolvedurl);
          return image;
        }
      } catch (IOException e) {
        logger.logException(PLogger.DEBUG, e, "Exception when loading image:%s\n", iconURL);
      }
    }

    logger.warnPrintf("Couldn't find (icon) image:%s\n", iconURL);

    return null;
  }