Class Images

    • Constructor Detail

      • Images

        public Images()
    • Method Detail

      • get

        public static URL get​(String name)
        Get a single icon from the classpath (must be PNG or GIF); no icon packs involved
        Parameters:
        name - The file to retrieve
        Returns:
        A URL referring to the requested icon on the classpath.
      • getDefaultIconSizeOr

        public static Images.IconSize getDefaultIconSizeOr​(ViewerPropertiesManager propertiesManager,
                                                           Images.IconSize elseValue)
        Get the current setting for the icon size or the given "else" value if preference is unset or is invalid

        This method is equivalent to calling getDefaultIconSizeOr(propertiesManager.getPreferences(), elseValue)

        Parameters:
        propertiesManager - The Properties Manager to retrieve the preferences from
        elseValue - The value to return if preference is unset or is invalid
        Returns:
        The current preference for the icon size or the given default value
      • getDefaultIconSizeOr

        public static Images.IconSize getDefaultIconSizeOr​(Preferences preferences,
                                                           Images.IconSize elseValue)
        Get the current setting for the icon size or the given "else" value if preference is unset or is invalid
        Parameters:
        preferences - The preference store to retrieve the preference from
        elseValue - The value to return if preference is unset or is invalid
        Returns:
        The current preference for the icon size or the given default value
      • applyIcons

        public static void applyIcons​(AbstractButton button,
                                      String iconName,
                                      Images.IconSize size)
        Apply normal, pressed, rollover and disabled variants of the given icon in the given size to the given button

        Pressed, rollover and disabled icons are only registered if the current icon pack supports those variants

        Parameters:
        button - The button to register the icons to
        iconName - The icon to register
        size - The size of the icon to register
      • applyIcon

        public static void applyIcon​(AbstractButton button,
                                     String iconName,
                                     IconPack.Variant variant,
                                     Images.IconSize size)
        Apply the given icon in the given variant and size to the given button

        No check is made whether the current icon pack provides the variant asked for. If it doesn't, calling this method may either fail with a runtime exception or a corrupted icon being displayed by the button.

        Parameters:
        button - The button to register the icon to
        iconName - The icon to register
        variant - The wanted variant of the given icon
        size - The wanted size
      • getSingleIcon

        public static Icon getSingleIcon​(String iconName,
                                         IconPack.Variant variant,
                                         Images.IconSize size)
                                  throws RuntimeException
        Get a single icon in the given variant and size from the current icon pack

        If the icon pack encounters an error trying to create the icon, it may throw a RuntimeException, which will not be caught by this method but passed to the callee.

        Parameters:
        iconName - The icon to retrieve from the current icon pack
        variant - The variant of the icon to retrieve
        size - The size in which to retrieve the icon
        Returns:
        The icon as fetched by the icon pack
        Throws:
        RuntimeException - If the icon pack could not find or could not load the requested icon