public class IconUtilities extends Object
| Modifier and Type | Method and Description |
|---|---|
static Image |
alterSaturation(Image i,
double amount)
Adjust the saturation of an image.
|
static Icons |
createGrayedOutIcons(Icons icons,
double saturationAdjustment,
float alpha)
Creates and caches a version of the icons with less (or more) saturation and/or a change in
alpha.
|
static URL |
createIconUrl(Icon icon)
Takes an icon and saves it to disk so then returns the path to the image file.
|
static Icons |
getCategoryDefaultIcons(GeneiousActionOptions.Category category)
Get the default
Icons for the specified action category. |
static Image |
getColoredImage(Image image,
Color color)
Moves the colors in this image towards the given color.
|
static Icons |
getGrayedOutIconsOriginal(Icons icons)
Get the non-grayed out version of Icons, IF
createGrayedOutIcons(com.biomatters.geneious.publicapi.plugin.Icons, double, float)
was used to create the grayed out version. |
static Icons |
getIcons(String iconNameOrPath)
Create an
Icons from an image file on disk. |
static Icons |
getIcons(String smallIconNameOrPath,
String largeIconNameOrPath)
Create an
Icons from two image files on disk: a small and a large
version of the image (typically 16x16 pixels and 32x32 (for document icons) or 24x24 (for toolbar icons)). |
static Icons |
getIconsFromJar(Class aClass,
String iconNameOrPath)
Create and
Icons from an image file in a resource bundle (jar). |
static Icons |
getIconsFromJar(Class aClass,
String smallIconPath,
String largeIconPath)
Create and
Icons from two image files from a resource bundle (jar). |
static String |
getIconsName(Icons icons)
Get a string name of an icon for the purposes of lexographic comparison.
|
static Image |
getImage(String imageName)
Create an
Image from an image file on disk. |
static Image |
getImageFromJar(Class aClass,
String imageFilePath)
Create and
Image from an image file in a resource bundle (jar). |
static void |
waitForImageToLoad(Image image)
Waits until an image has finished loading or returns immediately if it is already loaded.
|
public static Image alterSaturation(Image i, double amount)
i - The image to filteramount - 0 means 0 saturation (black and white), 1 gives no change, and > 1 increases saturation. Negative values are awesome.public static void waitForImageToLoad(Image image)
image - the image to wait forpublic static String getIconsName(Icons icons)
icons - Icons to get the name forpublic static Icons getIcons(String iconNameOrPath)
Icons from an image file on disk.
If no directory path is specified to the image file then it assumed to be in the standard Geneious image
directory (resources/images)
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).iconNameOrPath - path to the image file (if this parameter contains a file sparator) or the name of an image
file in the standard Geneious image directory (resources/images) otherwise.public static Icons getIcons(String smallIconNameOrPath, String largeIconNameOrPath)
Icons from two image files on disk: a small and a large
version of the image (typically 16x16 pixels and 32x32 (for document icons) or 24x24 (for toolbar icons)).
If no directory path is specified to the image file then it assumed to be in the standard Geneious image
directory (resources/images)
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).smallIconNameOrPath - path to the small image file (if this parameter contains a file sparator) or the name of an image
file in the standard Geneious image directory (resources/images) otherwise.largeIconNameOrPath - path to the large image file (if this parameter contains a file sparator) or the name of an image
file in the standard Geneious image directory (resources/images) otherwise.public static Icons getIconsFromJar(Class aClass, String iconNameOrPath)
Icons from an image file in a resource bundle (jar).
The path to the image file is obtained as a resource of the given class.
If you wish to obtain an image packaged in the root of a jar file, the path must be preceeded with a '/'.
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).
For example, if you have bundled an image file "smiley.png" in the root of your plugin jar file, you can create Icons like this:
Icons smileyIcons = IconUtilities.getIconsFromJar(MyPlugin.class, "/smiley.png")
aClass - The class to get the image resource for (a class in the jar of interest)iconNameOrPath - Path to the image file, either absolute within the jar (if preceeded by a '/') or relative
to the specified class (if not preceeded by a '/').Class.getResource(String)public static Icons getIconsFromJar(Class aClass, String smallIconPath, String largeIconPath)
Icons from two image files from a resource bundle (jar).
The paths to the image files are obtained as resources of the given class.
If you wish to obtain an image packaged in the root of a jar file, the path must be preceeded with a '/'.
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).
For example, if you have two bundled image files "smiley16.png" and "smiley32.png" in the root of your plugin jar
file, you can create Icons like this:
Icons smileyIcons = IconUtilities.getIconsFromJar(MyPlugin.class, "/smiley16.png", "/smiley32.png");
aClass - The class to get the image resource for (a class in the jar of interest)smallIconPath - Path to the small image file, either absolute within the jar (if preceeded by a '/') or relative
to the specified class (if not preceeded by a '/').largeIconPath - Path to the large image file, either absolute within the jar (if preceeded by a '/') or relative
to the specified class (if not preceeded by a '/').Class.getResource(String)public static Image getImageFromJar(Class aClass, String imageFilePath)
Image from an image file in a resource bundle (jar). The path to the image is
obtained as a resource of the given class. If you wish to obtain an image packaged in the root of a jar file,
the path must be preceeded with a '/'.
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).
For example, if you have bundled an image file "smiley.png" in the root of your plugin jar file, you can load it like this:
Image smileyImage = IconUtilities.getImageFromJar(MyPlugin.class, "/smiley.png")
aClass - The class to get the image resource for (a class in the jar of interest)imageFilePath - Path to the image file, either absolute within the jar (if preceeded by a '/') or relative
to the specified class (if not preceeded by a '/').Class.getResource(String)public static Image getImage(String imageName)
Image from an image file on disk.
If no directory path is specified to the image file then it assumed to be in the standard Geneious image
directory (resources/images)
Supported formats include png, jpeg and gif (plus any others supported by the standard java toolkit).imageName - actual image file name from images folder (including extension).public static URL createIconUrl(Icon icon)
icon - Icon to create a path forpublic static Icons getGrayedOutIconsOriginal(Icons icons)
createGrayedOutIcons(com.biomatters.geneious.publicapi.plugin.Icons, double, float)
was used to create the grayed out version. If the icons are not grayed out then the icon passed in will be returned.icons - the Icons to get the non-grayed-out version oficons. were generated using createGrayedOutIcons(com.biomatters.geneious.publicapi.plugin.Icons,double,float)
then return the original icons they were generated from. Otherwise return icons.public static Icons createGrayedOutIcons(Icons icons, double saturationAdjustment, float alpha)
icons - Icons to adjustsaturationAdjustment - amount 0 means 0 saturation (black and white), 1 gives no change, and > 1 increases saturation. Negative values are awesome.alpha - 0 for transparent, 1 for no change (opaque), in between for translucent.public static Icons getCategoryDefaultIcons(GeneiousActionOptions.Category category)
Icons for the specified action category.category - GeneiousActionOptions.Category to get icons forpublic static Image getColoredImage(Image image, Color color)
image - the image to create a copy of for coloringcolor - the color to modify the image towards