How to use a custom icons? [message #1734135] |
Sat, 04 June 2016 17:48  |
Eclipse User |
|
|
|
I need some help to load a custom image in my CustomShapeFeatureContainer.
I did not found out how to register custom icons located in the /icons/large/ folder.
I guessed the CustomTaskImageProvider.registerAvailableImages(); automatically registers all images in this folder. But it seems not to be the case.
What is necessary to be able to load a icon with something like this:
img = CustomTaskImageProvider.createImage(customTaskDescriptor, ga,
"inbox.png", 24, 24);
All my attempts resulted in a red-box-icon which seems to indicate that I have not registered my image to Eclipse.
===
Ralph
|
|
|
Re: How to use a custom icons? [message #1735014 is a reply to message #1734135] |
Tue, 14 June 2016 16:19   |
Eclipse User |
|
|
|
Hi Ralph, try this:
String imageId = customTaskDescriptor.getImageId("inbox.png", CustomTaskImageProvider.IconSize.LARGE);
if (!registered) {
String filename = "/icons/large/inbox.png";
URL url = getClass().getClassLoader().getResource(filename);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
CustomTaskImageProvider.registerImage(imageId, descriptor);
registered = true;
}
Image img = Graphiti.getGaService().createImage(ga, imageId);
img.setProportional(false);
img.setWidth(24);
img.setHeight(24);
img.setStretchH(true);
img.setStretchV(true);
Graphiti.getGaService().setLocation(img, 50, 25);
|
|
|
|
Powered by
FUDForum. Page generated in 0.04510 seconds