PIRL.Viewers

## Class Icons

- java.lang.Object
- - PIRL.Viewers.Icons

    public class Icons
    extends Object

The Icons class provides static methods to load ImageIcons.

### Field Summary

Fields
`static String` `DEFAULT_ICON_DIRECTORY_NAME`
`static String` `ID`

### Method Summary

Methods
`static Class` `Class_Relative()` Gets the Class to which the current `directory` is relative.
`static String` `Directory()` Gets the pathname of the directory where icon image files are to be found.
`static String` `Directory(String directory_path)` Sets the name of the directory where icon image files are to be found.
`static String` `Directory(String directory_path, Class the_class)` Sets the name of the directory where icon image files may be found relative to the location of a class.
`static ImageIcon` `Load_Icon(String source)` Loads an ImageIcon from a source.
`static void` `main(String[] arguments)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### ID

    public static final String ID

See Also:
  Constant Field Values

#### DEFAULT_ICON_DIRECTORY_NAME

    public static final String DEFAULT_ICON_DIRECTORY_NAME

See Also:
  Constant Field Values

### Method Detail

#### Load_Icon

    public static ImageIcon Load_Icon(String source)

Loads an ImageIcon from a source.

If the source is null or the empty String, nothing is done and null is returned.

First, an attempt is made to construct a URL from the source String. If this succeeds the URL is used to try and load an ImageIcon. No other attempts are made to find the source.

Next the source is treated as a file pathname. If this pathname is absolute or the source is not `class-relative` an attempt will be made to load an ImageIcon from the pathname. If the pathname is relative it is prepended with the icon `directory` or `class-relative directory` pathname, whichever is current. If the resultant pathname is for a normal file (rather than a directory) and read access is permitted by any existing security manager the pathname is used to try and load an ImageIcon.

If an ImageIcon is not yet loaded the pathname from the previous attempt is used to try and locate a system resource. This resource may be found relative to the CLASSPATH or inside a jar file. If this succeeds in producing a URL it is used to try and load an ImageIcon.

Parameters:
  `source` - The URL or pathname for the icon image source.
Returns:
  An ImageIcon, or null if one can not be found or loaded.

#### Directory

    public static String Directory(String directory_path)

Sets the name of the directory where icon image files are to be found.

N.B.: The directory pathname is marked as being not `class-relative`.

Parameters:
  `directory_path` - The pathname for the directory. If null or empty the `DEFAULT_ICON_DIRECTORY_NAME` will be used.
Returns:
  The previous directory pathname.

#### Directory

    public static String Directory(String directory_path,
                   Class the_class)

Sets the name of the directory where icon image files may be found relative to the location of a class.

If the directory name is null or empty the `DEFAULT_ICON_DIRECTORY_NAME` will be used. If the directory name is an absolute pathname, the class location is not used. Otherwise the directory pathname to the class location is prepended to the directory name and the resultant `directory pathname` is marked as being `class-relative`.

Parameters:
  `directory_path` - The pathname for the icons directory. If this is a relative pathname it will be relative to the location of the class.
  `the_class` - The Class location to use as the base for a relative directory pathname. Ignored if null.
Returns:
  The previous directory pathname.

#### Class_Relative

    public static Class Class_Relative()

Gets the Class to which the current `directory` is relative.

Returns:
  The last Class used to set a `class-relative` directory pathname. This will be null if the current `directory pathname` is not class-relative.

#### Directory

    public static String Directory()

Gets the pathname of the directory where icon image files are to be found.

Returns:
  The directory name.

#### main

    public static void main(String[] arguments)