Image is not displayed after reopen the plugin [message #1027539] |
Wed, 27 March 2013 04:39 |
Emerson Simbolon Messages: 12 Registered: April 2012 |
Junior Member |
|
|
I add an Image to the PictogramElement and it works.
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.
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 783 times) -
Attachment: G2.JPG
(Size: 22.91KB, Downloaded 844 times)
|
|
|
|
|
|
Re: Image is not displayed after reopen the plugin [message #1033820 is a reply to message #1032048] |
Thu, 04 April 2013 17:24 |
Emerson Simbolon 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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04311 seconds