How to use image as the diagram element? [message #146446] |
Tue, 14 August 2007 01:18  |
Eclipse User |
|
|
|
Originally posted by: tedwong.cse.unsw.edu.au
Hi,
I have a simple question which is how to use image as the diagram
element? I looked into Taipan example, it puts ship image files on the
editor which is what I am looking for. But the example doesn't have
..gmfmap so I can't reproduce it in my own example. Can anyone please
give me an example of how to do it?
Thanks
|
|
|
|
Re: How to use image as the diagram element? [message #146503 is a reply to message #146446] |
Tue, 14 August 2007 05:32  |
Eclipse User |
|
|
|
Originally posted by: 5d5.mail.ru
Add CustomFigure to gmfgraph that refers to a class like this:
public class ShipShape extends Figure {
private WrapLabel label;
private IFigure smallCargo;
private IFigure largeCargo;
public ShipShape() {
GridLayout layout = new GridLayout(2, false);
setLayoutManager(layout);
add(new ImageFigure(getShipImage()), new GridData(SWT.BEGINNING,
SWT.BEGINNING, false, false, 1, 2));
add(label = new WrapLabel(), new GridData(SWT.BEGINNING,
SWT.BEGINNING, false, false, 1, 1));
add(smallCargo = new Figure(), new GridData(SWT.FILL, SWT.BEGINNING,
true, false, 1, 1));
smallCargo.setLayoutManager(new StackLayout());
add(largeCargo = new Figure(), new GridData(SWT.FILL, SWT.FILL, true,
true, 2, 1));
largeCargo.setLayoutManager(new StackLayout());
}
protected Image getShipImage() {
return getImageImage("images/ship.png"); //$NON-NLS-1$
}
protected Image getImageImage(String path) {
Image image = JFaceResources.getImageRegistry().get(path);
if (image == null) {
ImageDescriptor descriptor =
AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gmf.examples.taipan ",
path); //$NON-NLS-1$
if (descriptor == null) {
descriptor = ImageDescriptor.getMissingImageDescriptor();
}
JFaceResources.getImageRegistry().put(path, image =
descriptor.createImage());
}
return image;
}
public WrapLabel getLabel() {
return label;
}
public IFigure getSmallCargo() {
return smallCargo;
}
public IFigure getLargeCargo() {
return largeCargo;
}
}
Ted Wong wrote:
> Hi,
>
> I have a simple question which is how to use image as the diagram
> element? I looked into Taipan example, it puts ship image files on the
> editor which is what I am looking for. But the example doesn't have
> .gmfmap so I can't reproduce it in my own example. Can anyone please
> give me an example of how to do it?
>
> Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.05449 seconds