public interface IconService extends ThemeService<IconTheme>
To use the API, you must add (in the order that the locations should be
searched) at lease one Base directory using the #addBase(File)
method.
You should also select a theme using #setSelectedTheme(IconTheme). If
no theme is selected, the first theme found is used.
To find an icon file, use findIcon(String, int). Only supply the
filename without the prefix (for example, user-home, not
user-home.png). Specify a size in pixels to locate the icon that
closest matches (use Integer.MAX_VALUE to get the biggest available
and Integer.MIN_VALUE to get the smallest).
Themes are keyed by their internal name. This is the file name of the directory the theme definition file is located in.
If an icon is not found in the selected theme, the themes parent will then be searched, and then its parent etc until a theme with no parent is reached.
If the icon is not found, the hicolor theme will then be searched in the same manner. Finally, if the icon is still not found, then the root of each base directory will be searched for any image files that are prefixed with the required name.
When no icon file is found using any of the above methods,
findIcon(String, int) will either return null or the
location of the image-missing special image (if that can be found).
See the specification in the link above for a complete description of the search algorithm.
| Modifier and Type | Method and Description |
|---|---|
org.apache.commons.vfs2.FileObject |
findIcon(String name,
int size)
Find the closest matching icon.
|
Iterator<String> |
iconNames()
Iterator over all the available icon names in the currently selected
theme for a given size.
|
Iterator<org.apache.commons.vfs2.FileObject> |
icons(int size)
Iterator over all the available icons in the currently selected theme for
a given size.
|
boolean |
isIconExists(String name,
int size)
Find the closest matching icon.
|
void |
postInit()
Must be called after construction to set the initial theme.
|
void |
setReturnMissingImage(boolean b)
Set whether the special Missing image is returned when no other
matches is found.
|
getSelectedTheme, setSelectedThemeaddBase, getAllEntities, getBases, getEntities, getEntity, removeBasevoid postInit()
org.apache.commons.vfs2.FileObject findIcon(String name, int size) throws IOException
IconService for a complete description of the search algorithm.
null will only be returned if no matching icon can be found
and the image-missing icon cannot be found eithername - name of iconsize - closest pixel sizeIOExceptionboolean isIconExists(String name, int size) throws IOException
IconService for a complete description of the search algorithm.name - name of iconsize - closest pixel sizenull if no icon can be foundIOExceptionvoid setReturnMissingImage(boolean b)
true and this image isn't found, an
IOException will be thrown.returnMissingImage - return Missing imageIterator<org.apache.commons.vfs2.FileObject> icons(int size)
size - preferred sizeCopyright © 2016. All rights reserved.