Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Image is not displayed after reopen the plugin
Image is not displayed after reopen the plugin [message #1027539] Wed, 27 March 2013 04:39 Go to next message
Emerson Simbolon is currently offline Emerson SimbolonFriend
Messages: 12
Registered: April 2012
Junior Member
I add an Image to the PictogramElement and it works.
index.php/fa/14169/0/
Component c = GraphBTUtil.getComponentByRef(model, layout.getCRef());
        org.eclipse.swt.graphics.Image im = GraphBTUtil.getComponentImageDescription(c);
        try{
        	GraphitiUIPlugin.getDefault().getImageRegistry().put("GRAPHBT-IMAGE-"+layout.getCRef(), im);
        } catch (Exception e) {
        	
        }
        Image image = gaService.createImage(containerShape, "GRAPHBT-IMAGE-"+layout.getCRef());

        int width = im.getBounds().width;
        int height = im.getBounds().height; 
        layout.setHeight(height);
        layout.setWidth(width);
        layout.setX(x);
        layout.setY(y);
        rectangle.setLineWidth(1);
        gaService.setLocationAndSize(image, x, y, width, height);


After I close and reopen it, the image is not displayed.
index.php/fa/14170/0/

Please give me idea for the strange behavior.

Note: I also try to remove the image when the editor is closed and add the image as the editor is opened to imitate the behavior when the image firstly created. But it also didn't work.


Thanks

Emerson
  • Attachment: G1.JPG
    (Size: 27.83KB, Downloaded 759 times)
  • Attachment: G2.JPG
    (Size: 22.91KB, Downloaded 814 times)
Re: Image is not displayed after reopen the plugin [message #1027697 is a reply to message #1027539] Wed, 27 March 2013 09:31 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Emerson,

what do you mean with close and reopen? The diagram or Eclipse?

The way you do the image registration only works as long as you plugin is
loaded, after e.g. restrating Eclipse that image won't be rgistered anymore.
In order to make that work you should define an ImageProvider for your
plugin and register the image there. You can then simply add the image as
you do it by referencing the contant from the image provider which will be
available automatically after loading the diagram.

There's a section on images inthe tutorial:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2Fimages.htm&cp=30_1_6

Michael
Re: Image is not displayed after reopen the plugin [message #1029107 is a reply to message #1027697] Fri, 29 March 2013 06:30 Go to previous messageGo to next message
Emerson Simbolon is currently offline Emerson SimbolonFriend
Messages: 12
Registered: April 2012
Junior Member
Yes, I mean by restarting eclipse. So, how do I get the ImageProvider instance that I already registered in
the extension? I can not put the image on "addAvailableImages" method, as the image only need to be registered
when it added to the canvas.
Re: Image is not displayed after reopen the plugin [message #1032048 is a reply to message #1029107] Tue, 02 April 2013 14:01 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Emerson,

using that dynamically is a not well supported thing. There's only an
internal way to get the image provider, you may use
ExtensionManager.getSingleton().getImageProvidersForDiagramTypeProviderId(providerId)

Would you open an enhancement bugzilla for this?

Adding images dynamically to the image provider needs some infomation to be
stored in the diagram where to retrieve the image from. Parsing that
infomation in the init method of either the editor or the diagram type
provider should enable you to re-add the images to the image provider at
startup of an editor.

Does that help?

Michael
Re: Image is not displayed after reopen the plugin [message #1033820 is a reply to message #1032048] Thu, 04 April 2013 17:24 Go to previous messageGo to next message
Emerson Simbolon is currently offline Emerson SimbolonFriend
Messages: 12
Registered: April 2012
Junior Member
Hi Wenz,

It still not working. It even not displaying any image since it is firstly registered.

I add this method to the ImageProvider so I can add image publicly:

	public void addImage(String ref,String path) {
		addImageFilePath(ref, path);
	}


In the AddComponent module:
GraphBTImageProvider imP = GraphBTUtil.getImageProvider();
    	String path = GraphBTUtil.getImageAbsolutePath(ProjectUtil.RESOURCE_LOCATION+"/"+c.getComponentRef()+".jpg");
    	System.out.println("Path "+path);
    	imP.addImage(path, path); //register image by ID: path, and filePath: path
        Image image = gaService.createImage(containerShape, path);


In the pageActivated:
try{
imP.addImage(path, path);
} catch (Exception e) {
}
PictogramElement pe = Graphiti.getLinkService().getPictogramElements(getDiagramTypeProvider().getDiagram(), l).get(0);
Image image = Graphiti.getGaCreateService().createImage(pe, path);
image.setHeight(l.getHeight());
image.setWidth(l.getWidth());


Even when it firstly added, the image is not displayed.

[Updated on: Thu, 04 April 2013 18:31]

Report message to a moderator

Re: Image is not displayed after reopen the plugin [message #1033892 is a reply to message #1033820] Thu, 04 April 2013 19:11 Go to previous messageGo to next message
Emerson Simbolon is currently offline Emerson SimbolonFriend
Messages: 12
Registered: April 2012
Junior Member
The bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404936
Enhancement request: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404937
Re: Image is not displayed after reopen the plugin [message #1034394 is a reply to message #1033820] Fri, 05 April 2013 11:40 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sorry, that method exists only in Graphiti 0.10.0 so far...

You may use getImageProviders on that same class and sort the right one out.

Michael
Re: Image is not displayed after reopen the plugin [message #1048861 is a reply to message #1027539] Thu, 25 April 2013 03:29 Go to previous messageGo to next message
klausnew dfdgs is currently offline klausnew dfdgsFriend
Messages: 7
Registered: April 2013
Junior Member
yes, i have used , wonderful
Re: Image is not displayed after reopen the plugin [message #1048862 is a reply to message #1048861] Thu, 25 April 2013 03:30 Go to previous messageGo to next message
klausnew dfdgs is currently offline klausnew dfdgsFriend
Messages: 7
Registered: April 2013
Junior Member
or you can google on the web
Re: Image is not displayed after reopen the plugin [message #1063127 is a reply to message #1027539] Wed, 12 June 2013 12:13 Go to previous message
Karol Duke is currently offline Karol DukeFriend
Messages: 1
Registered: June 2013
Junior Member
Hello

This is my favorite plugin of all time! The Flip Image is easy to use and it has improved the appearance of my blog by 110%! Thanks Much

I have been waiting for a plugin like Flip Image to come along! I was amazed that it was as easy to use as it is, and it has greatly improved the look of my website.


The Flip Image Plugin


Thanks.


Previous Topic:Diagrams without resource for layout data
Next Topic:Diagram Validation Decoration
Goto Forum:
  


Current Time: Tue Mar 19 02:20:19 GMT 2024

Powered by FUDForum. Page generated in 0.02618 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top