|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uic.model.IconFactory
Icon factory creates Icon objects from image files found in one of the registered repositories.
This class keeps a jvm-wide list of icon repositories. Repositories have to be registered
in order to find the images, see the different add methods add a jar like jlfgr
, addRepository on path
,
add custom repositories
.
Example usage:
IconFactory icons = new IconFactory(); icons.addRepository("/usr/share/icons/default.kde"); // for debian systems icons.addRepository("/opt/kde3/share/icons/default.kde"); // for suse systems myExitButton.setIcon(icons.getIcon("actions/exit"));
ActionFactory
Nested Class Summary | |
protected static class |
IconFactory.IconRepository
An IconRepository class that uses known formats from http://kdelook.org icon packages. |
static interface |
IconFactory.Repository
This interface is used to query any repository for icons it might have to be used by the IconFactory. |
static class |
IconFactory.SizeComperator
This comperator is usable to sort image sizes in an existing collection for best quality. |
protected static class |
IconFactory.ZipFileRepository
A repository to allow things like the jlfg jar to be used |
Constructor Summary | |
IconFactory()
Sole constructor, new instanciations made will reuse already registered repositories. |
Method Summary | |
boolean |
addJar(String path)
Use the jar repository that follows the file layout as used in the java-look-and-feel-graphics jar. |
void |
addRepository(IconFactory.Repository repository)
Add a repository that should be queried for images. |
boolean |
addRepository(String path)
Add a repository layed out like the KDE Iconsets. |
ImageIcon |
getIcon(String name,
int size)
Create an icon with the name being the repository path like 'actions/exit'. |
ImageIcon |
getIcon(String name,
int size,
boolean canScale)
Create an icon with the name being the repository path like 'actions/exit'. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IconFactory()
Method Detail |
public boolean addJar(String path)
path
- path to the jar, if the path does not point to a correct jar the add will
be silently ignored, and false will be returned.
public boolean addRepository(String path)
path
- path to the respository directory, if the path is not correct
the add will be silently ignored, and false will be returned.
public void addRepository(IconFactory.Repository repository)
public ImageIcon getIcon(String name, int size)
name
- the name of the icon without filetype and including the path
from the root of the repository.size
- the size the widget should be in. If icon found does not matched
it will be scaled to fit.
public ImageIcon getIcon(String name, int size, boolean canScale)
name
- the name of the icon without filetype and including the path
from the root of the repository.size
- the size the widget should be in.canScale
- when true and the icon found does not match argument size it will
be scaled to fit.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |