public class DefaultIconService extends AbstractThemeService<IconTheme> implements IconService
IconService. Four image types are
supported. PNG, GIF, XPM and SVG.
Icon locations are also cached in memory, keyed on
[iconName]_[preferredSize]. Use clearCache() to remove all cached
locations.
| Modifier and Type | Field and Description |
|---|---|
protected String |
defaultThemeName |
static String[] |
SUPPORTED_EXTENSIONS
Support file extensions
|
bases, basesList| Constructor and Description |
|---|
DefaultIconService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBase(org.apache.commons.vfs2.FileObject base)
Add a directory to the list of those that should be searched.
|
void |
clearCache() |
org.apache.commons.vfs2.FileObject |
findIcon(String name,
int size)
Find the closest matching icon.
|
protected IconTheme |
getDefaultTheme() |
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 |
removeBase(org.apache.commons.vfs2.FileObject base)
Remove a directory from the list that is is searched.
|
protected Collection<IconTheme> |
scanBase(org.apache.commons.vfs2.FileObject base) |
void |
setDefaultThemeName(String defaultThemeName) |
void |
setReturnMissingImage(boolean returnMissingImage)
Set whether the special Missing image is returned when no other
matches is found.
|
void |
setSelectedTheme(IconTheme theme)
Set the currently selected theme.
|
getSelectedThemecheckAndAddBase, checkAndAddBase, getAllEntities, getBases, getBasesInReverse, getEntities, getEntity, listDirsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSelectedThemegetAllEntities, getBases, getEntities, getEntitypublic static final String[] SUPPORTED_EXTENSIONS
protected String defaultThemeName
public DefaultIconService()
throws IOException,
ParseException
IOExceptionParseExceptionpublic void setDefaultThemeName(String defaultThemeName)
public final void postInit()
IconServicepostInit in interface IconServiceprotected IconTheme getDefaultTheme()
public void addBase(org.apache.commons.vfs2.FileObject base)
throws IOException
FreedesktopServiceaddBase in interface FreedesktopService<IconTheme>addBase in class AbstractFreedesktopService<IconTheme>base - base directoryIOException - if location is invalid in some waypublic void removeBase(org.apache.commons.vfs2.FileObject base)
FreedesktopServiceremoveBase in interface FreedesktopService<IconTheme>removeBase in class AbstractFreedesktopService<IconTheme>base - base directory to remove from the list that is searched#addBase(File)public void setSelectedTheme(IconTheme theme)
ThemeServicesetSelectedTheme in interface ThemeService<IconTheme>setSelectedTheme in class AbstractThemeService<IconTheme>theme - selected themepublic Iterator<org.apache.commons.vfs2.FileObject> icons(int size)
IconServiceicons in interface IconServicesize - preferred sizepublic Iterator<String> iconNames()
IconServiceiconNames in interface IconServicepublic org.apache.commons.vfs2.FileObject findIcon(String name, int size) throws IOException
IconServiceIconService 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 eitherfindIcon in interface IconServicename - name of iconsize - closest pixel sizeIOExceptionpublic boolean isIconExists(String name, int size) throws IOException
IconServiceIconService for a complete description of the search algorithm.isIconExists in interface IconServicename - name of iconsize - closest pixel sizenull if no icon can be foundIOExceptionpublic void setReturnMissingImage(boolean returnMissingImage)
IconServicetrue and this image isn't found, an
IOException will be thrown.setReturnMissingImage in interface IconServicepublic void clearCache()
protected Collection<IconTheme> scanBase(org.apache.commons.vfs2.FileObject base) throws IOException
scanBase in class AbstractFreedesktopService<IconTheme>IOExceptionCopyright © 2016. All rights reserved.