Class IconPack

  • Direct Known Subclasses:
    DefaultIconPack

    public abstract class IconPack
    extends Object
    Abstract class providing logic for fetching icons from the classpath

    Ultimately, this should only be called by the Images utility class

    Author:
    Alexander Leithner
    • Constructor Detail

      • IconPack

        public IconPack()
    • Method Detail

      • getProvidedVariants

        public abstract IconPack.VariantPool getProvidedVariants()
        Gets all variants this icon pack provides for at least one icon.

        This method is called by the Images utility class when deciding what icons to register to a given component. No guarantee regarding further usage is made.

        Returns:
        Information about what variant this icon pack provides.
      • getIcon

        public abstract Icon getIcon​(String name,
                                     IconPack.Variant variant,
                                     Images.IconSize size)
                              throws RuntimeException
        Gets a single icon with the given name in the given variant and size from the classpath.

        Note that the size parameter is to be regarded as a hint. If the icon pack deems it necessary to return another size for any given icon, the icon will be returned in this size instead. No guarantee is made that any icon return by this method is square

        Parameters:
        name - The name of the icon to retrieve
        variant - The variant to retrieve
        size - The size to retrieve
        Returns:
        The icon requested in the given variant, either in the wanted size or a similar size
        Throws:
        RuntimeException - If the icon could not be retrieved from the classpath or any other error occurs