|
|
|
|
Re: How insere an image [message #221802 is a reply to message #221765] |
Wed, 18 March 2009 14:01 |
BG Messages: 45 Registered: July 2009 |
Member |
|
|
Then you can do it this way
To your gmfgraph model
1 Add a figuredescriptor
2 Add a child node "Custom figure"
3 Now if u check the properties of custom figure in properties view
4 There u have three option Descriptor,Name and Qualified class name
5 for Qualified class name provide the class which reads your custom figure
eg: "com.bosch.rtc.flowVinci.diagram.edit.parts.NormalFigure"
And the class will look some thing like this
public class NormalFigure extends Figure {
//name for portcontainer
private WrapLabel fFigureShortNameFigure;
public NormalFigure(String filepath) {
createContents();
add(new ImageFigure(getPortContainerImage(filepath)),new
GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); }
protected Image getPortContainerImage(String filepath) {
return getImageImage(filepath); //$NON-NLS-1$
}
protected Image getImageImage(String path) {
Image image = JFaceResources.getImageRegistry().get(path);
if (image == null) {
ImageDescriptor descriptor =
AbstractUIPlugin.imageDescriptorFromPlugin("com.bosch.rtc.flowVinci.diagram.custom ",
path); //$NON-NLS-1$
if (descriptor == null) {
descriptor = ImageDescriptor.getMissingImageDescriptor();
}
JFaceResources.getImageRegistry().put(path, image =
descriptor.createImage());
}
return image;
}
private void createContents() {
fFigureShortNameFigure = new WrapLabel();
fFigureShortNameFigure.setText("");
this.add(fFigureShortNameFigure);
}
public WrapLabel getFigurePortContainerShortNameImage() {
return fFigureShortNameFigure;
}
}
Let me know incase if you have need further clarification on this
|
|
|
Powered by
FUDForum. Page generated in 0.03434 seconds