Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Connection between custom figures
Connection between custom figures [message #490034] Wed, 07 October 2009 01:04 Go to next message
Eclipse UserFriend
Originally posted by: asif.tmcp.gmail.com

Hi,

I am trying to implement custom figure in a GMF based editor.

I have over-ridden the corresponding.
*.diagram.edit.parts.<Class>editpart.java CreateNodeShape as follows:

URL url = null;

url = FileLocator.find(SolmodDiagramEditorPlugin.getInstance().get Bundle(),
new Path("images/ipdslam.svg"), null);

RenderedImage img = RenderedImageFactory.getInstance(url);

primaryShape = new ScalableImageFigure(img, true,true, true);

return primaryShape;



The shape gets created but the problem is that
1>. There are no connection points to this shape. Hence this class cannot be
connected to any thing else in the diagram.

2>. After I draw this shape, the diagram editor doesn't allow me to draw
anything else.



What am I missing here?



Kind REgards,

asif
Re: Connection between custom figures [message #490060 is a reply to message #490034] Wed, 07 October 2009 07:02 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

if it is "just" to have an image for the figure, I can advice you to use SVGFigure. Your image needs to be in .svg but like that you don't need a custom figure and connections will works.


Regards,

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Connection between custom figures [message #490182 is a reply to message #490060] Wed, 07 October 2009 17:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: asif.tmcp.gmail.com

Hi ,

Thanks for the response.
If i understand you correctly the following are the steps
1>. "GMFMap" create a Custom Figure Descriptor.
2>. With Child as an SVG Figure.
3>. Then in this child provide the "Document URI" as the path to the SVG
figure.
4>. Provide a label for the name

I have done the above but the problem persists.

The problems:
1>. The figure is drawn at the top left hand corner of the canvas
2>. There are no connection points to the figure
3>. Nothing else can be drawn on the canvas after this is drawn.


Question :-
What steps am i missing?
Do I have to define anything else like layout??
Is there a specific size constraint for the svg?
Can i still provide the labels in this node element? Where will they appear?
Is there a good document for the same?

Regards,
asif



"Aurelien Pupier" <aurelien.pupier@gmail.com> wrote in message
news:hahedj$e1d$1@build.eclipse.org...
> Hi,
>
> if it is "just" to have an image for the figure, I can advice you to use
> SVGFigure. Your image needs to be in .svg but like that you don't need a
> custom figure and connections will works.
>
>
> Regards,
>
> Aurelien Pupier
Re: Connection between custom figures [message #490201 is a reply to message #490182] Wed, 07 October 2009 19:08 Go to previous messageGo to next message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi,

If you want just the figure you might wanna try this:

Instead of using the RectangleIFigure class to extend in your XXXFigure int the XXXEditPart, you can extend the class ImageFigure and set the image on that figure. I think this should work and you can set any image format, since the setImage takes a SWT image.

Best regards, hope that works for you,
Artur
Re: Connection between custom figures [message #490239 is a reply to message #490201] Thu, 08 October 2009 01:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: asif.tmcp.gmail.com

I have tried another approach.

This is how my gmfgraph appears
Canvas
-- Figure Gallery CustomFigure ( Implementation :
org.eclipse.gmf.runtime.lite.svg)
-- Figure Descriptor Custom1Figure
-- SVGFigure Node1Figure
-- FlowLayout False
-- Label Node1NameFigure
-- Child Access getFigureNode1NameFigure
-- Node Node1 ( Custom1Figure)


Node1Editpart.java contains the following code

public class Custom1Figure extends ImageFigure {

/**
* @generated
*/
private WrappingLabel fFigureHiX5635NameFigure;

/**
* @generated
*/
public CustomFigure() {

FlowLayout layoutThis = new FlowLayout();
layoutThis.setStretchMinorAxis(false);
layoutThis.setMinorAlignment(FlowLayout.ALIGN_LEFTTOP);

layoutThis.setMajorAlignment(FlowLayout.ALIGN_LEFTTOP);
layoutThis.setMajorSpacing(5);
layoutThis.setMinorSpacing(5);
layoutThis.setHorizontal(true);

this.setLayoutManager(layoutThis);

this.setURI(" file:/D:/dev_wksd/Sol.Mod.wksd/eclipse.wksd/com.nsn.gmf.solu tionmodeling.graphed.diagram/images/sd.svg ");
createContents();
}


Now the problem still persists.

1>. Once the figure is drawn the canvas is frozen. No other figure can be
drawn.
2>. This figure has no connection point.

Please help.

Kind Regards,
asif




"Artur Kronenberg" <addur737@yahoo.de> wrote in message
news:haiov0$qmb$1@build.eclipse.org...
> Hi,
>
> If you want just the figure you might wanna try this:
>
> Instead of using the RectangleIFigure class to extend in your XXXFigure
> int the XXXEditPart, you can extend the class ImageFigure and set the
> image on that figure. I think this should work and you can set any image
> format, since the setImage takes a SWT image.
> Best regards, hope that works for you,
> Artur
Re: Connection between custom figures [message #490384 is a reply to message #490239] Thu, 08 October 2009 14:04 Go to previous messageGo to next message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi,

I notived you have a Wrappinglabel in your figure? Was your edit part generated as "normal" editpart like e.g. a rectangle.

Am I right that since you want to use an image only right now you don't use the wrappinglabel anymore? I think this might result into a nullpointer exception when the generated code still tries to set a name on the label, but the label doesn't exist. This would result into your frozen canvas and the inability to draw any other nodes on it or connections.

Can you check your log and see if this might be the case?

Best regards,
Artur
Re: Connection between custom figures [message #490647 is a reply to message #490239] Fri, 09 October 2009 14:56 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Asif,

> 1>. Once the figure is drawn the canvas is frozen. No other figure can
> be
> drawn.
> 2>. This figure has no connection point.
> Please help.
It looks like the figure you've specified (file:/D:/dev_wksd/Sol.Mod.wksd/eclipse.wksd/com.nsn.gmf.sol utionmodeling.graphed.diagram/images/sd.svg)
was not drawn properly..
Do you have any exceptions in the .log file?.. Can you execute this diagram
editor in a debugger and stop it then figure was drawn to see why canvas
was frozen?

In general you are going in a proper way right now. Idea is:
1. Create FigureDescriptor = fd
2. Create RectangleFigure (root figure in fd) = rf.
3. set appropriate (stack?) layout for rf.
4. create SVG figure with proper image path specified in rf.
5. create label figure in rf.
6. create accessor for label figure.

So, I suggest not nesting any figures into SVG figure - i remember some problems
around that. Instead I propose creating new root figure, set stack (or any
other applicable layout for it) and place SVG figure together with all other
child figures into this root figure.

Talking about orignal problem - it looks like an .svg file was not processed
properly by GMF.. In other words, I suppose you'll ave exactly same problem
in the end, so I suggest you debugging a bit to see why canvas was frozen.

-----------------
Alex Shatalin
Re: Connection between custom figures [message #490759 is a reply to message #490647] Sat, 10 October 2009 10:09 Go to previous message
Eclipse UserFriend
Originally posted by: asif.tmcp.gmail.com

Hi ,

I somehow solved the problem.
Actually while looking around I also noticed that part of the solution is
there in the documentation itself and in Aureliens previous post
" http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg19637.html "
.. My mistake.
What I missed was setting the background and foreground color.
Thanks a lot for pointing me in the right direction.

Now I have come across a peculiar problem.
I will launch a separate thread for that.

Thanks once again.

Regards,
asif


"Alex Shatalin" <shatalin@gmail.com> wrote in message
news:b79abbae192178cc1718a6d1b514@news.eclipse.org...
> Hello Asif,
>
>> 1>. Once the figure is drawn the canvas is frozen. No other figure can
>> be
>> drawn.
>> 2>. This figure has no connection point.
>> Please help.
> It looks like the figure you've specified
> (file:/D:/dev_wksd/Sol.Mod.wksd/eclipse.wksd/com.nsn.gmf.sol utionmodeling.graphed.diagram/images/sd.svg)
> was not drawn properly..
> Do you have any exceptions in the .log file?.. Can you execute this
> diagram editor in a debugger and stop it then figure was drawn to see why
> canvas was frozen?
> In general you are going in a proper way right now. Idea is:
> 1. Create FigureDescriptor = fd
> 2. Create RectangleFigure (root figure in fd) = rf.
> 3. set appropriate (stack?) layout for rf.
> 4. create SVG figure with proper image path specified in rf.
> 5. create label figure in rf.
> 6. create accessor for label figure.
>
> So, I suggest not nesting any figures into SVG figure - i remember some
> problems around that. Instead I propose creating new root figure, set
> stack (or any other applicable layout for it) and place SVG figure
> together with all other child figures into this root figure.
> Talking about orignal problem - it looks like an .svg file was not
> processed properly by GMF.. In other words, I suppose you'll ave exactly
> same problem in the end, so I suggest you debugging a bit to see why
> canvas was frozen.
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:Missing .diagram Help!!!!!
Next Topic:adding pins to a figure
Goto Forum:
  


Current Time: Tue Apr 23 15:37:03 GMT 2024

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

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

Back to the top