Get Font Image on the fly [message #1827795] |
Sun, 24 May 2020 09:56 |
|
Hello,
I have a spécific need to create font image from image stored in database on the fly and I do not know if this is possible.
I have an object named group that has an image and I am creating tiles for each instance, I saw that eclipse handle much better font icons than normal icons in case of default tiles
method
getconfiguredOverViewIcon()
so I would like to implement a methode that basicly get the binaryresource of the image from databse and create the font icon when called.
is this possible ?
Kind Regard
|
|
|
Re: Get Font Image on the fly [message #1827903 is a reply to message #1827795] |
Tue, 26 May 2020 15:17 |
|
Hi,
the icons are resolved using IIconProviderServices. You could implement a custom icon provider which loads your icons from the database, from the filesystem or from memory, whatever you prefer. You don't need to convert your images to font icons, just return a new IconSpec with the image as content (which is a byte[]).
You can either extend from AbstractIconProviderService which uses an internal cache, in this case, override "findIconSpec". If you have a lot of different icons or the icons can change you maybe don't want to use a cache, in that case, just implement the interface directly and override "getIconSpec".
In both cases you could use a prefix for these kind of icons and abort if the name does not contain the prefix.
@Override
public IconSpec getIconSpec(String iconName) {
if (!iconName.startsWith(PREFIX)) {
return null;
}
// load icon here
}
|
|
|
Powered by
FUDForum. Page generated in 0.02963 seconds