Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to use image as the diagram element?
How to use image as the diagram element? [message #146446] Tue, 14 August 2007 05:18 Go to next message
Eclipse UserFriend
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 #146469 is a reply to message #146446] Tue, 14 August 2007 08:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: r.c.ladan.tue.nl

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?
>
One slightly dirty way is to replace the image files in
PROJ.edit/icons/full/obj16 with your own (they are 16x16 pixel GIF files).
Another way is to replace the "Default Image" children of "Creation
Tool" nodes in the gmftool file with "Bundle Image" children, for which
you can set the path to the image (I think these are relative to the
project).

HTH,
Rene
Re: How to use image as the diagram element? [message #146503 is a reply to message #146446] Tue, 14 August 2007 09:32 Go to previous message
Eclipse UserFriend
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
Previous Topic:Label offsets are ignored
Next Topic:Re: Please Help Newbie: Using JET With GMF
Goto Forum:
  


Current Time: Thu Oct 10 23:11:17 GMT 2024

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

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

Back to the top