Archi Forum

Archi Plug-ins => jArchi => Topic started by: Thomas Rohde on May 04, 2023, 11:09:24 AM

Title: Eclipse use of jArchi images
Post by: Thomas Rohde on May 04, 2023, 11:09:24 AM
I am doing some scripting, where I take the custom image of an element and displaying it in an Eclipse widget. I realise that jArchi ".image" does not return a "org.eclipse.swt.graphics.Image". Is there any way I can convert a jArchi image to an Eclipse image?
Title: Re: Eclipse use of jArchi images
Post by: Phil Beauvoir on May 04, 2023, 11:30:45 AM
Hi Thomas,

once an image is loaded in jArchi with object.image = model.createImage("cat.png") it is stored internally to the model and is referenced thereafter by its internal id so it's not possible to get the image data from jArchi to re-use it. However, if you have the original image stored somewhere you could load it with some JS:

const Image = Java.type("org.eclipse.swt.graphics.Image");
const Display = Java.type("org.eclipse.swt.widgets.Display");

var img = new Image(Display.current, "cat.png");

// Use the image

// Dispose the image when done
img.dispose();