Class EnumImageLoader

java.lang.Object
org.ka2ddo.yaac.gui.util.EnumImageLoader

public class EnumImageLoader extends Object
This class maintains a mapping of Enum value instances to ImageIcons, so enumerations can be identified in the UI by image picture.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • registerEnum

      public static void registerEnum(Class<? extends Enum> clazz)
      Register an entire enum class using the specified prefix when building resource names for localized string lookups.
      Parameters:
      clazz - Enum class whose elements should have images loaded
      See Also:
    • loadIcon

      public static ImageIcon loadIcon(String filename)
      Load an image into an ImageIcon from the specified relative pathname.
      Parameters:
      filename - String pathname relative to the base installation directory of YAAC
      Returns:
      ImageIcon from the specified file, or null if the file does not exist
    • getImageIcon

      public static ImageIcon getImageIcon(Enum e)
      Look up the ImageIcon for an enumeration.
      Parameters:
      e - Enum value to look up
      Returns:
      ImageIcon corresponding to this enum value, or null if no such icon
    • getEnumForName

      public static Enum getEnumForName(String name)
      Look up an enum by name for which we have an icon image. Note this method will log an error if two registered enums have instances with the same name, but will only return the first match found.
      Parameters:
      name - String name of enum
      Returns:
      Enum for this name, or null if no match